{"id":25596,"library":"fluent-transpiler","title":"fluent-transpiler","description":"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.","status":"active","version":"0.4.1","language":"javascript","source_language":"en","source_url":"https://github.com/willfarrell/fluent-transpiler","tags":["javascript","Fluent","@fluent","ftl","localization","l10n","internationalization","i18n","ast","typescript"],"install":[{"cmd":"npm install fluent-transpiler","lang":"bash","label":"npm"},{"cmd":"yarn add fluent-transpiler","lang":"bash","label":"yarn"},{"cmd":"pnpm add fluent-transpiler","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used to parse and validate .ftl files before transpilation","package":"@fluent/syntax","optional":false}],"imports":[{"note":"Package is ESM-only; CommonJS require will fail. The default export does not exist; use named import.","wrong":"const fluentTranspiler = require('fluent-transpiler')","symbol":"fluentTranspiler","correct":"import { fluentTranspiler } from 'fluent-transpiler'"},{"note":"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'.","wrong":null,"symbol":"compile","correct":"import { compile } from 'fluent-transpiler/compile'"},{"note":"The class is a named export, not a default export. TypeScript users should import the type directly: import type { FluentTranspiler } from 'fluent-transpiler'.","wrong":"import FluentTranspiler from 'fluent-transpiler'","symbol":"FluentTranspiler","correct":"import { FluentTranspiler } from 'fluent-transpiler'"},{"note":"For TypeScript, use import type for options interfaces; they are re-exported from the package.","wrong":null,"symbol":"Type imports","correct":"import type { FluentTranspilerOptions } from 'fluent-transpiler'"}],"quickstart":{"code":"import { readFileSync, writeFileSync } from 'node:fs';\nimport { compile } from 'fluent-transpiler';\n\nconst ftlContent = readFileSync('messages/en-CA.ftl', 'utf8');\nconst jsCode = compile(ftlContent, {\n  locale: 'en-CA',\n  variableNotation: 'camelCase'\n});\nwriteFileSync('messages/en-CA.js', jsCode, 'utf8');\nconsole.log('Transpilation complete.');","lang":"typescript","description":"Reads an FTL file, compiles it to a JS module using fluent-transpiler, and writes the output."},"warnings":[{"fix":"Pass { comments: true } in options or use CLI flag --comments.","message":"By default, comments in FTL files are omitted from the output. Use --comments or the comments option to include them.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Review include/exclude options to ensure the desired messages are present in the output.","message":"The 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.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Set variableNotation option to an appropriate value (e.g., 'snakeCase') to match your naming conventions.","message":"Variable names are converted to camelCase by default. This may conflict with original FTL variable names. Use --variable-notation to change.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"No action needed; these are positive indicators.","message":"SLSA 3 and OpenSSF Scorecard badges are present; no known security incidents. Package uses npm provenance.","severity":"deprecated","affected_versions":">=0.4.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"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).","cause":"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.","error":"Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'fluent-transpiler'"},{"fix":"Change to named import: import { compile } from 'fluent-transpiler'.","cause":"Attempting a default import when the package only exports named exports.","error":"SyntaxError: The requested module 'fluent-transpiler' does not provide an export named 'default'"},{"fix":"Read the .ftl file content first: const ftlContent = readFileSync('file.ftl', 'utf8'); then compile(ftlContent, options).","cause":"Passing a file path instead of the actual FTL content string to compile().","error":"TypeError: ftlContent is not a string"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}