Registry / web-framework / fable-splitter

fable-splitter

JSON →
library2.2.1jsnpmunverified

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.

npm install fable-splitter
INSTALL
IMPORT
SIG · FABLE-SPLITTER
F
fable-splitter
web-frameworkjavascriptv2.2.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
✓ const splitter = require('fable-splitter')
✗ import splitter from 'fable-splitter'
fable-splitter is CommonJS only; ESM import not supported.
run
✓ const { run } = require('fable-splitter')
✗ import { run } from 'fable-splitter'
run is a named export in CommonJS; ESM import will fail.
getConfig
✓ const { getConfig } = require('fable-splitter')
✗ import { getConfig } from 'fable-splitter'
getConfig is another named export; use destructuring require.

Shows how to programmatically compile an F# project using fable-splitter's JS API with Babel configuration.

const { run } = require('fable-splitter'); const config = { entry: 'src/App.fsproj', outDir: 'out', babel: { presets: [['@babel/preset-env', { modules: 'commonjs' }]] }, allFiles: false, fable: { define: ['DEBUG'], typedArrays: true, clampByteArrays: false }, onCompiled: () => console.log('Done!') }; run(config).catch(err => console.error(err));
fable-splitter --version
Debug
Known issues
breakingIn 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`).
fix
Upgrade fable-compiler to >=2.1.0 and call `npx fable-splitter` directly.
affects: >=2.0.0 <2.1.0
deprecatedFable 5.x is in release candidate; fable-splitter may be replaced or significantly changed. Check Fable 5 migration guide.
fix
Stay on fable-splitter 2.x for stable releases, or migrate to Fable 5's built-in CLI when stable.
affects: >=5.0.0-rc.1 <5.0.0
gotchaThe `--commonjs` flag is required if you want CommonJS module output; otherwise, Fable outputs ES modules by default.
fix
Add `--commonjs` to CLI or set `modules: 'commonjs'` in Babel config.
affects: >=2.0.0
gotchaPath resolution macros `${entryDir}` and `${outDir}` are only replaced in string literals, not in variables or interpolated strings.
fix
Use `${entryDir}` directly in F# string literals, not in runtime string concatenation.
affects: >=2.0.0
Errors
Common errors & fixes
Cannot find module 'fable-compiler'
fable-compiler is a peer dependency and must be installed separately.
fix
Run `npm install fable-compiler` alongside `fable-splitter`.
TypeError: run is not a function
Importing using ESM syntax (import) instead of CommonJS require.
fix
Use `const { run } = require('fable-splitter')` instead of `import { run } from 'fable-splitter'`.
Error: Unknown command: fable-splitter
Attempting to run `dotnet fable fable-splitter` with Fable 2.1+.
fix
Call `npx fable-splitter` directly; the dotnet-fable CLI is no longer needed.
SyntaxError: Unexpected token 'export'
Running a Fable-compiled file that uses ES module syntax in a Node.js environment without CommonJS.
fix
Add `--commonjs` flag or configure Babel to transform modules to CommonJS.
Upgrade
Version history
2.2.1latest on npm
Audit
Dependencies
fable-compilerrequiredPeer dependency required for F# to JS compilation
Agent activity
4 hits · last 30 days
node
4
Resources
fable-splitter — npm install fable-splitter · libregistry