babel-preset-fbjs

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

Babel preset for Facebook projects, version 3.4.0, stable. It includes transforms for modern JavaScript, Flow, and JSX (React), with options for auto-import, inline requires, module rewriting, and DEV stripping. Differentiators: official Facebook tooling for internal consistency, customizable via configure API, but tightly coupled to Facebook's ecosystem. Release cadence is infrequent.

error Cannot find module 'babel-preset-fbjs/configure'
cause Incorrect path; missing subpath export or used wrong casing.
fix
Use require('babel-preset-fbjs/configure') exactly.
error Error: Plugin/Preset files are not allowed to export objects, only functions.
cause Passed preset object directly instead of string or function.
fix
Use preset as string: presets: ['babel-preset-fbjs']
gotcha This preset is designed for Facebook's internal projects. It may not be suitable general-purpose use.
fix Consider using @babel/preset-env for standard projects.
deprecated Some transforms like stripDEV only work with specific Babel versions.
fix Check Babel core compatibility.
gotcha Inline requires option is experimental and may cause runtime issues.
fix Avoid using inlineRequires: true in production.
gotcha ES module import of babel-preset-fbjs fails; it lacks ESM wrapper.
fix Use CommonJS require() instead of ESM import.
npm install babel-preset-fbjs
yarn add babel-preset-fbjs
pnpm add babel-preset-fbjs

Transpile JavaScript code using babel-preset-fbjs preset via the Babel API.

const babel = require('@babel/core');
const code = `const x = 1;`;
babel.transformSync(code, {
  presets: ['babel-preset-fbjs']
});