{"id":25935,"library":"metro-hermes-compiler","title":"Metro Hermes Compiler","description":"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.","status":"active","version":"0.73.10","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/facebook/metro","tags":["javascript"],"install":[{"cmd":"npm install metro-hermes-compiler","lang":"bash","label":"npm"},{"cmd":"yarn add metro-hermes-compiler","lang":"bash","label":"yarn"},{"cmd":"pnpm add metro-hermes-compiler","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Runs in Node.js; uses FileSystem and child_process APIs","package":"node","optional":false}],"imports":[{"note":"Default and named exports are both available; ESM is primary.","symbol":"compile","correct":"import { compile } from 'metro-hermes-compiler'"},{"note":"There is no default export; use named imports.","wrong":"import metroHermesCompiler from 'metro-hermes-compiler'","symbol":"default","correct":"import { compile } from 'metro-hermes-compiler'"},{"note":"CJS require is deprecated; use ESM imports.","wrong":"const { compileFromSource } = require('metro-hermes-compiler')","symbol":"compileFromSource","correct":"import { compileFromSource } from 'metro-hermes-compiler'"}],"quickstart":{"code":"import { compile } from 'metro-hermes-compiler';\nimport { readFileSync, writeFileSync } from 'fs';\n\nconst source = readFileSync('input.js', 'utf8');\nconst bytecode = compile(source, {\n  sourceURL: 'input.js',\n  sourceMap: true,\n  optimize: true\n});\nwriteFileSync('output.hbc', bytecode);\nconsole.log('Compiled to Hermes bytecode.');","lang":"typescript","description":"Compiles a JavaScript file to Hermes bytecode using the compile function, with source map and optimization enabled."},"warnings":[{"fix":"Use compiled output directly as a Buffer instead of accessing .buffer.","message":"The compile function now returns a Buffer instead of an object with a buffer property.","severity":"breaking","affected_versions":">=0.73.0"},{"fix":"Replace compileFromSource calls with compile and adjust parameters if needed.","message":"The 'compileFromSource' function has been deprecated in favor of 'compile'.","severity":"deprecated","affected_versions":">=0.73.0"},{"fix":"Upgrade Node.js to version 14 or later.","message":"Node.js versions below 14 are no longer supported.","severity":"breaking","affected_versions":">=0.70.0"},{"fix":"Ensure sufficient memory (at least 512MB heap) for the Node process.","message":"The WASM binary is large (~30MB) and may cause high memory usage during compilation.","severity":"gotcha","affected_versions":"all"},{"fix":"Always include sourceMap and optimize boolean options in the config object.","message":"Options 'sourceMap' and 'optimize' were added as required; omitting them causes errors.","severity":"breaking","affected_versions":">=0.70.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run `npm install metro-hermes-compiler` or add it to package.json.","cause":"Package not installed or missing from node_modules.","error":"Error: Can't resolve 'metro-hermes-compiler'"},{"fix":"Use `import { compile } from 'metro-hermes-compiler'` (not `import ... from` as default).","cause":"Incorrect import — using default export instead of named.","error":"TypeError: compile is not a function"},{"fix":"Ensure the package is installed and import path is correct (use 'metro-hermes-compiler' not a relative path).","cause":"Webpack or bundler cannot locate the package; possibly not installed or incorrectly aliased.","error":"Module not found: Can't resolve 'metro-hermes-compiler' in '/path/to/project'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}