Registry / web-framework / babel-plugin-syntax-hermes-parser

babel-plugin-syntax-hermes-parser

JSON →
library0.35.0jsnpmunverified

The `babel-plugin-syntax-hermes-parser` is a Babel plugin designed to switch Babel's default parser, `@babel/parser`, to `hermes-parser`. This provides significant performance benefits due to `hermes-parser` being compiled to WASM from C++, resulting in faster parsing. Additionally, it offers comprehensive syntax support for Flow, making it particularly useful for projects leveraging Flow type annotations. The current stable version, 0.35.0, indicates active development within the Babel and Hermes ecosystems, likely released in tandem with updates to the underlying `hermes-parser` or Babel itself. Its key differentiator lies in its speed and robust Flow support, distinguishing it from other parser options.

npm install babel-plugin-syntax-hermes-parser
INSTALL
IMPORT
SIG · BABEL-PLUGIN-SYNTA
B
babel-plugin-syntax-hermes-parser
web-frameworkjavascriptv0.35.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

babel-plugin-syntax-hermes-parser
{ "plugins": ["babel-plugin-syntax-hermes-parser"] }
import 'babel-plugin-syntax-hermes-parser'; // This is a Babel config plugin, not for direct JS import
This plugin is configured in `babel.config.json` or equivalent Babel configuration files, not imported directly into JavaScript code. It should be listed in the `plugins` array.
parserOpts
{ "plugins": ["babel-plugin-syntax-hermes-parser"], "parserOpts": { "allowReturnOutsideFunction": true } }
{ "babel-plugin-syntax-hermes-parser": { "allowReturnOutsideFunction": true } }
Parser-specific options for `hermes-parser` are passed via the global `parserOpts` key in your Babel configuration, not directly as options to the plugin entry itself. This ensures they are applied correctly by Babel.

This `babel.config.json` snippet demonstrates how to enable the Hermes parser plugin and configure basic parser options, such as allowing Flow syntax and controlling specific parsing behaviors.

{ "plugins": [ "babel-plugin-syntax-hermes-parser" ], "parserOpts": { "allowReturnOutsideFunction": false, "flow": "all" } }
Debug
Known issues
breakingWhen switching to `babel-plugin-syntax-hermes-parser`, ensure that other parser-related Babel plugins (e.g., `@babel/plugin-syntax-flow`, `@babel/plugin-syntax-typescript`) are either removed or configured carefully to avoid conflicts. Having multiple parser plugins for the same syntax might lead to unexpected errors or parsing failures.
fix
Review your Babel configuration and remove redundant syntax plugins. The Hermes parser is designed to handle common JavaScript syntax and Flow types natively, often making other syntax plugins unnecessary.
affects: >=0.1.0
gotchaThe primary benefit of this plugin is its performance due to the underlying `hermes-parser` being compiled to WASM. Ensure your build environment and tooling correctly handle WASM artifacts. In some edge cases or restrictive environments, WASM loading might present issues, though this is rare in modern Node.js/browser environments.
fix
Verify that your build tools (e.g., Webpack, Rollup) are configured to correctly bundle and serve WASM modules. Most modern setups handle this by default.
affects: >=0.1.0
gotchaWhile the plugin provides excellent Flow support, if your project exclusively uses TypeScript, integrating `babel-plugin-syntax-hermes-parser` might be an unnecessary dependency, and could potentially introduce subtle incompatibilities if not carefully managed alongside TypeScript-specific Babel plugins. It's optimized for Flow's specific syntax.
fix
For TypeScript-only projects, consider sticking with `@babel/plugin-transform-typescript` or similar TypeScript-focused solutions. Evaluate the performance benefits against potential configuration complexity for your specific use case.
affects: >=0.1.0
Errors
Common errors & fixes
Error: Cannot find plugin "babel-plugin-syntax-hermes-parser" relative to file "<path>/babel.config.json"
The package `babel-plugin-syntax-hermes-parser` was not installed or is not resolvable in the current project's `node_modules`.
fix
Run `npm install --save-dev babel-plugin-syntax-hermes-parser` or `yarn add --dev babel-plugin-syntax-hermes-parser` in your project directory.
Error: Duplicated parser plugin for 'flow' (or other syntax) at <file_path>
Multiple Babel plugins are attempting to parse the same syntax feature (e.g., Flow types). This often happens when `babel-plugin-syntax-hermes-parser` is enabled alongside another plugin like `@babel/plugin-syntax-flow`.
fix
Remove the redundant syntax plugin from your Babel configuration. `babel-plugin-syntax-hermes-parser` natively supports Flow syntax, making `@babel/plugin-syntax-flow` unnecessary.
TypeError: 'parserOpts' must be an object of options.
The `parserOpts` in `babel.config.json` is either missing or incorrectly formatted (e.g., null, array, or primitive) when the plugin expects an object of configuration.
fix
Ensure `parserOpts` is an object, even if empty, in your Babel configuration. For example: `"parserOpts": {}` or `"parserOpts": { "flow": "all" }`.
Upgrade
Version history
0.35.0latest on npm
Audit
Dependencies
hermes-parserrequiredThis plugin acts as a bridge, making Babel use the `hermes-parser` internally.
Agent activity
18 hits · last 30 days
node
16
OpenAI (training)
2
Resources
babel-plugin-syntax-hermes-parser — npm install babel-plugin-syntax-hermes-parser · libregistry