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.
Common errors
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']
Warnings
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.
Install
npm install babel-preset-fbjs yarn add babel-preset-fbjs pnpm add babel-preset-fbjs Imports
- default wrong
import preset from 'babel-preset-fbjs'; // ESM not supportedcorrectmodule.exports = require('babel-preset-fbjs'); // or in .babelrc: 'fbjs' - configure wrong
import configure from 'babel-preset-fbjs/configure'; // ESM not supportedcorrectconst configure = require('babel-preset-fbjs/configure'); - plugins wrong
const {plugins} = require('babel-preset-fbjs').plugins; // incorrect pathcorrectconst {plugins} = require('babel-preset-fbjs/plugins');
Quickstart
const babel = require('@babel/core');
const code = `const x = 1;`;
babel.transformSync(code, {
presets: ['babel-preset-fbjs']
});