{"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,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","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,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}