FB Babel Plugin Utils
raw JSON → 0.13.1 verified Sat Apr 25 auth: no javascript
A collection of shared utility functions used internally by Facebook for building Babel 7 transforms. Version 0.13.1 is the latest stable release, but the package is not intended for public consumption and has no explicit release cadence. It is tightly coupled with Facebook's internal toolchain and the `fbt` (Facebook Translation) ecosystem. Unlike general-purpose Babel utility libraries (e.g., `@babel/helper-plugin-utils`), this package provides internal helpers specific to Facebook's transform infrastructure. It is not recommended for external use.
Common errors
error Cannot find module 'fb-babel-plugin-utils' ↓
cause Package not installed or not in node_modules.
fix
Run npm install fb-babel-plugin-utils --save-dev
error fbBabelPluginUtils.isJSXElement is not a function ↓
cause The export does not exist or was incorrectly imported.
fix
Check the available exports by inspecting the package's index.js or TypeScript definitions.
error TypeError: t.JSXElement is not a function ↓
cause Incorrect usage of @babel/types; JSXElement is a node type, not a builder.
fix
Use t.jsxElement(...) or t.jSXElement(...) depending on the version.
Warnings
breaking This package is intended for internal Facebook use only; breaking changes can occur without notice. ↓
fix Do not depend on this package for public projects; consider using @babel/helper-plugin-utils instead.
deprecated The package may use deprecated Babel 7 APIs that could break in future Babel versions. ↓
fix Monitor Babel compatibility updates; migrate to standard helpers if needed.
gotcha Exports are undocumented; relying on any specific export is risky as internals can change. ↓
fix Pin to a specific version and test thoroughly after upgrades.
Install
npm install fb-babel-plugin-utils yarn add fb-babel-plugin-utils pnpm add fb-babel-plugin-utils Imports
- default wrong
const fbBabelPluginUtils = require('fb-babel-plugin-utils')correctimport fbBabelPluginUtils from 'fb-babel-plugin-utils' - someExport wrong
const { someExport } = require('fb-babel-plugin-utils')correctimport { someExport } from 'fb-babel-plugin-utils' - types wrong
import types from 'fb-babel-plugin-utils/types'correctimport { types } from 'fb-babel-plugin-utils'
Quickstart
import fbBabelPluginUtils from 'fb-babel-plugin-utils';
import { types as t } from '@babel/core';
// Example usage: check if a node is a JSX element
const isJsxElement = fbBabelPluginUtils.isJSXElement(t.JSXElement());
console.log(isJsxElement); // true