Esprima-FB

raw JSON →
15001.1001.0-dev-harmony-fb verified Fri May 01 auth: no javascript deprecated

A Facebook-specific fork of the Esprima JavaScript parser, version 15001.1001.0-dev-harmony-fb, that adds full support for JSX syntax extensions on top of ECMAScript 5.1 and experimental ES6/Harmony features. Unlike standard Esprima, this fork enables parsing JSX as used by React and JSXDOM. It maintains compatibility with Mozilla Parser AST format and includes syntax location tracking. Its versioning scheme maps to upstream Esprima harmony branches with Facebook modifications. No longer actively maintained; replaced by modern parsers like Babel.

error SyntaxError: Unexpected token <
cause JSX parsing not enabled; missing { jsx: true } option.
fix
Add { jsx: true } as second argument to parse().
error Cannot find module 'esprima-fb'
cause Package not installed or removed from npm.
fix
Install the package: npm install esprima-fb --save
deprecated Esprima-FB is no longer maintained; use Babel parser or acorn-jsx instead.
fix Migrate to @babel/parser or acorn with acorn-jsx plugin.
breaking JSX parsing in esprima-fb requires explicitly setting { jsx: true } option; not default.
fix Always pass { jsx: true } to parse() when parsing JSX code.
breaking The AST format may differ from official ESTree spec; incompatible with some tools.
fix Use a modern parser that follows the latest ESTree specification.
npm install esprima-fb
yarn add esprima-fb
pnpm add esprima-fb

Parses JSX code into an AST using esprima-fb with location tracking.

import { parse } from 'esprima-fb';
const code = `const element = <div className="foo">Hello</div>;`;
const ast = parse(code, { jsx: true, loc: true });
console.log(JSON.stringify(ast, null, 2));