babel-plugin-fbt-runtime

raw JSON →
1.0.0 verified Sat Apr 25 auth: no javascript

Secondary Babel transform for the FBT internationalization framework, version 1.0.0. This plugin complements babel-plugin-fbt by transpiling fbt._(...) calls into runtime payloads consumable by the fbt runtime. It is required for end-to-end usage of the fbt library in production. The package has no release cadence; it is a companion to the broader fbt ecosystem maintained by Facebook. Alternative: no direct alternative for this specific transform step.

error Error: Cannot find module 'babel-plugin-fbt-runtime'
cause Package not installed in project.
fix
npm install --save-dev babel-plugin-fbt-runtime
error TypeError: fbt._ is not a function
cause Missing the runtime transform; fbt._ calls are not transpiled.
fix
Add 'babel-plugin-fbt-runtime' to your Babel plugins after babel-plugin-fbt.
breaking This plugin must come after babel-plugin-fbt in the plugins array.
fix Ensure order: first babel-plugin-fbt, then babel-plugin-fbt-runtime.
deprecated The package is not actively maintained; consider alternatives like i18next or react-intl.
fix Migrate to a more modern i18n solution.
gotcha You must also install babel-plugin-fbt as a peer dependency; otherwise, the transform will fail at runtime.
fix Run: npm install babel-plugin-fbt --save-dev
npm install babel-plugin-fbt-runtime
yarn add babel-plugin-fbt-runtime
pnpm add babel-plugin-fbt-runtime

Setup Babel to use both fbt plugins: primary and runtime transforms.

// .babelrc
{
  "plugins": [
    ["module:babel-plugin-fbt", { "extraOptions": {} }],
    "babel-plugin-fbt-runtime"
  ]
}

// or babel.config.js
module.exports = {
  plugins: [
    [require('babel-plugin-fbt'), { /* options */ }],
    require('babel-plugin-fbt-runtime')
  ]
};