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.

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.
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.
npm install fb-babel-plugin-utils
yarn add fb-babel-plugin-utils
pnpm add fb-babel-plugin-utils

Shows importing the default export and using a utility to check JSX element type.

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