Registry / serialization / fluent-transpiler

fluent-transpiler

JSON →
library0.4.1jsnpmunverified

fluent-transpiler is a build-time tool that compiles Fluent (.ftl) localization files into optimized, tree-shakable JavaScript ES modules. Current stable version is 0.4.1. It supports single and multiple locales, allows selective message inclusion/exclusion, and offers variable naming conventions (camelCase, PascalCase, etc.). Unlike runtime i18n libraries like @fluent/react or react-intl, fluent-transpiler produces zero-runtime code, ideal for modern bundlers with tree shaking. Requires Node >=24 and ships TypeScript definitions.

npm install fluent-transpiler
INSTALL
IMPORT
SIG · FLUENT-TRANSPILER
F
fluent-transpiler
serializationjavascriptv0.4.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.

fluentTranspiler
import { fluentTranspiler } from 'fluent-transpiler'
const fluentTranspiler = require('fluent-transpiler')
Package is ESM-only; CommonJS require will fail. The default export does not exist; use named import.
compile
import { compile } from 'fluent-transpiler/compile'
The compile function is available as a named export from the main entry point, but may also be accessed from a subpath export in future versions. Use import { compile } from 'fluent-transpiler'.
FluentTranspiler
import { FluentTranspiler } from 'fluent-transpiler'
import FluentTranspiler from 'fluent-transpiler'
The class is a named export, not a default export. TypeScript users should import the type directly: import type { FluentTranspiler } from 'fluent-transpiler'.
Type imports
import type { FluentTranspilerOptions } from 'fluent-transpiler'
For TypeScript, use import type for options interfaces; they are re-exported from the package.

Reads an FTL file, compiles it to a JS module using fluent-transpiler, and writes the output.

import { readFileSync, writeFileSync } from 'node:fs'; import { compile } from 'fluent-transpiler'; const ftlContent = readFileSync('messages/en-CA.ftl', 'utf8'); const jsCode = compile(ftlContent, { locale: 'en-CA', variableNotation: 'camelCase' }); writeFileSync('messages/en-CA.js', jsCode, 'utf8'); console.log('Transpilation complete.');
fluent-transpiler --version
Debug
Known issues
gotchaBy default, comments in FTL files are omitted from the output. Use --comments or the comments option to include them.
fix
Pass { comments: true } in options or use CLI flag --comments.
affects: >=0.1.0
gotchaThe output includes only messages that are not excluded. If --include-key is used, only those keys are included. If --exclude-key is used, specified keys are removed.
fix
Review include/exclude options to ensure the desired messages are present in the output.
affects: >=0.1.0
gotchaVariable names are converted to camelCase by default. This may conflict with original FTL variable names. Use --variable-notation to change.
fix
Set variableNotation option to an appropriate value (e.g., 'snakeCase') to match your naming conventions.
affects: >=0.1.0
deprecatedSLSA 3 and OpenSSF Scorecard badges are present; no known security incidents. Package uses npm provenance.
fix
No action needed; these are positive indicators.
affects: >=0.4.0
Errors
Common errors & fixes
Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'fluent-transpiler'
Using CommonJS require() in a Node.js version that doesn't support ESM, or the package is installed as devDependency but not available at runtime.
fix
Use ES modules (import) and ensure the package is installed as a dependency (npm i -D is for devDependencies; if needed at runtime, use npm i).
SyntaxError: The requested module 'fluent-transpiler' does not provide an export named 'default'
Attempting a default import when the package only exports named exports.
fix
Change to named import: import { compile } from 'fluent-transpiler'.
TypeError: ftlContent is not a string
Passing a file path instead of the actual FTL content string to compile().
fix
Read the .ftl file content first: const ftlContent = readFileSync('file.ftl', 'utf8'); then compile(ftlContent, options).
Upgrade
Version history
0.4.1latest on npm
Audit
Dependencies
@fluent/syntaxrequiredUsed to parse and validate .ftl files before transpilation
Agent activity
2 hits · last 30 days
node
2
Resources
fluent-transpiler — npm install fluent-transpiler · libregistry