Registry / devops / metro-hermes-compiler

metro-hermes-compiler

JSON →
library0.73.10jsnpmunverified

An experimental Node.js package providing a high-level API to interface with the Hermes bytecode compiler (HBC). Hermes is an open-source JavaScript engine optimized for React Native apps. This package integrates the compiler as a WebAssembly binary generated via Emscripten, enabling conversion of JavaScript/JSX into Hermes bytecode (.hbc) for improved startup performance on mobile. The current stable version is 0.73.10, with regular releases as part of Metro's release cadence (monthly minor updates). Unlike alternatives like Babel alone, this compiler is purpose-built for Hermes, producing optimized bytecode targeting React Native's Hermes runtime.

npm install metro-hermes-compiler
INSTALL
IMPORT
SIG · METRO-HERMES-COMPI
M
metro-hermes-compiler
devopsjavascriptv0.73.10
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

compile
import { compile } from 'metro-hermes-compiler'
Default and named exports are both available; ESM is primary.
default
import { compile } from 'metro-hermes-compiler'
import metroHermesCompiler from 'metro-hermes-compiler'
There is no default export; use named imports.
compileFromSource
import { compileFromSource } from 'metro-hermes-compiler'
const { compileFromSource } = require('metro-hermes-compiler')
CJS require is deprecated; use ESM imports.

Compiles a JavaScript file to Hermes bytecode using the compile function, with source map and optimization enabled.

import { compile } from 'metro-hermes-compiler'; import { readFileSync, writeFileSync } from 'fs'; const source = readFileSync('input.js', 'utf8'); const bytecode = compile(source, { sourceURL: 'input.js', sourceMap: true, optimize: true }); writeFileSync('output.hbc', bytecode); console.log('Compiled to Hermes bytecode.');
Debug
Known issues
breakingThe compile function now returns a Buffer instead of an object with a buffer property.
fix
Use compiled output directly as a Buffer instead of accessing .buffer.
affects: >=0.73.0
deprecatedThe 'compileFromSource' function has been deprecated in favor of 'compile'.
fix
Replace compileFromSource calls with compile and adjust parameters if needed.
affects: >=0.73.0
breakingNode.js versions below 14 are no longer supported.
fix
Upgrade Node.js to version 14 or later.
affects: >=0.70.0
gotchaThe WASM binary is large (~30MB) and may cause high memory usage during compilation.
fix
Ensure sufficient memory (at least 512MB heap) for the Node process.
affects: all
breakingOptions 'sourceMap' and 'optimize' were added as required; omitting them causes errors.
fix
Always include sourceMap and optimize boolean options in the config object.
affects: >=0.70.0
Errors
Common errors & fixes
Error: Can't resolve 'metro-hermes-compiler'
Package not installed or missing from node_modules.
fix
Run `npm install metro-hermes-compiler` or add it to package.json.
TypeError: compile is not a function
Incorrect import — using default export instead of named.
fix
Use `import { compile } from 'metro-hermes-compiler'` (not `import ... from` as default).
Module not found: Can't resolve 'metro-hermes-compiler' in '/path/to/project'
Webpack or bundler cannot locate the package; possibly not installed or incorrectly aliased.
fix
Ensure the package is installed and import path is correct (use 'metro-hermes-compiler' not a relative path).
Upgrade
Version history
0.73.10latest on npm
Audit
Dependencies
noderequiredRuns in Node.js; uses FileSystem and child_process APIs
Agent activity
2 hits · last 30 days
node
2
Resources
metro-hermes-compiler — npm install metro-hermes-compiler · libregistry