{"id":25567,"library":"fable-splitter","title":"fable-splitter","description":"File splitter for Fable, the F# to JavaScript compiler. This package provides a CLI and JS API to compile F# files into individual JavaScript modules. Current stable version is 2.2.1 (with Fable 5.x in release candidate). It relies on fable-compiler (peer dependency ^2.5.1) for actual compilation. Key differentiators: supports Fable 2.1+ direct invocation (no need for dotnet-fable), offers watch mode, Babel integration, and path resolution macros. Not to be confused with fable-compiler itself; fable-splitter handles file splitting and output management.","status":"active","version":"2.2.1","language":"javascript","source_language":"en","source_url":"https://github.com/fable-compiler/Fable/blob/master/src/fable-splitter","tags":["javascript","fable","fsharp","F#"],"install":[{"cmd":"npm install fable-splitter","lang":"bash","label":"npm"},{"cmd":"yarn add fable-splitter","lang":"bash","label":"yarn"},{"cmd":"pnpm add fable-splitter","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency required for F# to JS compilation","package":"fable-compiler","optional":false}],"imports":[{"note":"fable-splitter is CommonJS only; ESM import not supported.","wrong":"import splitter from 'fable-splitter'","symbol":"default","correct":"const splitter = require('fable-splitter')"},{"note":"run is a named export in CommonJS; ESM import will fail.","wrong":"import { run } from 'fable-splitter'","symbol":"run","correct":"const { run } = require('fable-splitter')"},{"note":"getConfig is another named export; use destructuring require.","wrong":"import { getConfig } from 'fable-splitter'","symbol":"getConfig","correct":"const { getConfig } = require('fable-splitter')"}],"quickstart":{"code":"const { run } = require('fable-splitter');\n\nconst config = {\n  entry: 'src/App.fsproj',\n  outDir: 'out',\n  babel: {\n    presets: [['@babel/preset-env', { modules: 'commonjs' }]]\n  },\n  allFiles: false,\n  fable: {\n    define: ['DEBUG'],\n    typedArrays: true,\n    clampByteArrays: false\n  },\n  onCompiled: () => console.log('Done!')\n};\n\nrun(config).catch(err => console.error(err));","lang":"javascript","description":"Shows how to programmatically compile an F# project using fable-splitter's JS API with Babel configuration."},"warnings":[{"fix":"Upgrade fable-compiler to >=2.1.0 and call `npx fable-splitter` directly.","message":"In Fable 2.0, fable-splitter was called via dotnet-fable (e.g. `dotnet fable fable-splitter`). Starting from Fable 2.1, call fable-splitter directly (e.g. `npx fable-splitter`).","severity":"breaking","affected_versions":">=2.0.0 <2.1.0"},{"fix":"Stay on fable-splitter 2.x for stable releases, or migrate to Fable 5's built-in CLI when stable.","message":"Fable 5.x is in release candidate; fable-splitter may be replaced or significantly changed. Check Fable 5 migration guide.","severity":"deprecated","affected_versions":">=5.0.0-rc.1 <5.0.0"},{"fix":"Add `--commonjs` to CLI or set `modules: 'commonjs'` in Babel config.","message":"The `--commonjs` flag is required if you want CommonJS module output; otherwise, Fable outputs ES modules by default.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Use `${entryDir}` directly in F# string literals, not in runtime string concatenation.","message":"Path resolution macros `${entryDir}` and `${outDir}` are only replaced in string literals, not in variables or interpolated strings.","severity":"gotcha","affected_versions":">=2.0.0"}],"env_vars":null,"search_vec":"'2.1':57 '2.2.1':33 '2.5.1':49 '5':36 'actual':51 'api':20 'babel':69 'candid':40 'cli':17 'compil':12,22,46,52,82 'confus':78 'current':29 'depend':48 'differenti':54 'direct':58 'dotnet':64 'dotnet-f':63 'f':9,23,96 'fabl':2,7,35,45,56,65,81,85,94 'fable-compil':44,80 'fable-splitt':1,84 'file':4,24,88 'fsharp':95 'handl':87 'individu':26 'integr':70 'invoc':59 'javascript':11,27,93 'js':19 'key':53 'macro':74 'manag':92 'mode':68 'modul':28 'need':61 'offer':66 'output':91 'packag':14 'path':72 'peer':47 'provid':15 'releas':39 'reli':42 'resolut':73 'split':89 'splitter':3,5,86 'stabl':30 'support':55 'version':31 'watch':67 'x':37","created_at":"2026-05-01T13:45:26.408115+00:00","updated_at":"2026-05-01T13:45:26.408115+00:00","problems":[{"fix":"Run `npm install fable-compiler` alongside `fable-splitter`.","cause":"fable-compiler is a peer dependency and must be installed separately.","error":"Cannot find module 'fable-compiler'"},{"fix":"Use `const { run } = require('fable-splitter')` instead of `import { run } from 'fable-splitter'`.","cause":"Importing using ESM syntax (import) instead of CommonJS require.","error":"TypeError: run is not a function"},{"fix":"Call `npx fable-splitter` directly; the dotnet-fable CLI is no longer needed.","cause":"Attempting to run `dotnet fable fable-splitter` with Fable 2.1+.","error":"Error: Unknown command: fable-splitter"},{"fix":"Add `--commonjs` flag or configure Babel to transform modules to CommonJS.","cause":"Running a Fable-compiled file that uses ES module syntax in a Node.js environment without CommonJS.","error":"SyntaxError: Unexpected token 'export'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"fable-splitter","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/fable-compiler/Fable","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/fable-splitter","openapi_spec":null,"status_page":null,"smithery":null,"categories":["web-framework"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-05-01","next_check":"2026-07-30","install_tag":null}}