fluent-compiler (v0.1.0, stable pre-release) is a JavaScript transpiler for Project Fluent's FTL format. It compiles FTL messages into ES6 modules that export FluentBundle-compatible objects, shifting compilation from runtime to build time. Unlike the core `fluent` package (which ships a ~10kB runtime compiler), `fluent-compiler` outputs pre-compiled code with a ~1.2kB runtime dependency, reducing browser bundle size. It supports locale identifiers, optional AST input from `fluent-syntax`, configurable runtime imports, and Unicode isolation marks. Suitable for Node.js >=8.9.0 and build pipelines (Webpack, Rollup). Note: The runtime API is based on a draft PR (#360) and may change.
npm install fluent-compilerNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows end-to-end usage: compile FTL to JS, then import and use the pre-compiled bundle with format().
Pin to exact version and test thoroughly before upgrading. Monitor Fluent.js PR #360 for API changes.
Always use `bundle.addResource(resource, { allowOverrides: true })` for adding compiled resources.Use `import` or `import()` to consume the generated module. If using CJS, compile with a tool like Babel or set up Node.js for ESM.
Install `fluent-syntax` as a dependency if you plan to pass string sources. Alternatively, parse with `fluent-syntax` yourself and pass the AST.
Run `npm install fluent-syntax` or ensure it's listed in dependencies.
Call `compile('it', source)` or `compile(['it', 'en'], source)` or `compile(undefined, source)`.Use `import` statement or dynamic `import()`. If in Node.js CJS, rename file to .mjs or set type: module in package.json.
Set `runtimeGlobals` option to include only those available, or provide polyfills.