Registry / devops / react-native-esbuild

react-native-esbuild

JSON →
library0.6.0jsnpmunverified

A fast bundler and dev server for React Native that leverages esbuild instead of Metro. Current stable version is 0.6.0, with updates supporting React Native 0.72. Typically released every few months. Key differentiators: 10-50x faster bundling, tree shaking resulting in ~21% smaller bundles, drop-in replacement for Metro, support for custom transformers and environment variables. Peer dependencies include @babel/core >=7.0.0 and esbuild >=0.17. Compatible with out-of-tree platforms (macOS, Windows) and offers interactive mode.

npm install react-native-esbuild
INSTALL
IMPORT
SIG · REACT-NATIVE-ESBUI
R
react-native-esbuild
devopsjavascriptv0.6.0
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.

commands
const { commands } = require('react-native-esbuild');
import { commands } from 'react-native-esbuild';
CommonJS require is standard for react-native.config.js; ESM import may not work depending on Node configuration.
createEsbuildCommands
const { createEsbuildCommands } = require('react-native-esbuild');
import createEsbuildCommands from 'react-native-esbuild';
Named export; default import does not work.
babelPlugin
const { babelPlugin } = require('react-native-esbuild');
const babelPlugin = require('react-native-esbuild/babelPlugin');
babelPlugin is a named export from the main entry, not a separate file.

Shows how to configure react-native-esbuild as a CLI plugin, with optional custom esbuild configuration and Babel plugin, then run start or bundle commands.

// Configure react-native-esbuild as a CLI plugin // File: react-native.config.js const { commands, createEsbuildCommands, babelPlugin } = require('react-native-esbuild'); // Option 1: Use default commands module.exports = { commands }; // Option 2: Customize with createEsbuildCommands const customCommands = createEsbuildCommands((config) => ({ ...config, plugins: config.plugins.concat( babelPlugin({ filter: /src\/my-babel-components\/.+\.tsx?$/ }) ) })); module.exports = { commands: customCommands }; // Then run: // npx react-native esbuild-start --port 8081 // npx react-native esbuild-bundle --platform android --dev false
react-native-esbuild --version
Debug
Known issues
deprecatedesmCustomMainFieldResolverPlugin is deprecated and no longer needed with esbuild >= 0.17.
fix
Remove usage of esmCustomMainFieldResolverPlugin; esbuild 0.17+ handles main fields automatically.
affects: >=0.5.0
gotchaThe dev server must be started with 'react-native esbuild-start' instead of 'react-native start' (Metro). Using the wrong command will launch Metro instead of esbuild.
fix
Update package.json scripts: change 'start' script to 'react-native esbuild-start' and ensure --no-packager is appended to ios/android scripts.
affects: >=0.1.0
breakingVersion 0.4.0 introduced a flow/reanimated syntax-aware loader that may change behavior for files containing Flow or Reanimated code; previous versions may have failed silently.
fix
If using Flow or Reanimated, ensure your files are properly annotated; the loader now actively processes these syntaxes and may throw errors for malformed code.
affects: >=0.4.0
gotchaSource map support was fixed in 0.4.0; earlier versions experienced crashes related to source maps.
fix
Upgrade to 0.4.0 or later to avoid source map crashes.
affects: <0.4.0
breakingSupport for out-of-tree platforms (macOS, Windows) was added in 0.3.0; previous versions only supported iOS and Android.
fix
If using Windows or macOS targets, upgrade to 0.3.0 or later.
affects: <0.3.0
Errors
Common errors & fixes
Error: Cannot find module 'react-native-esbuild'
Package is not installed or not in node_modules.
fix
Run 'yarn add react-native-esbuild esbuild' or 'npm install react-native-esbuild esbuild'.
TypeError: commands is not iterable
Incorrectly importing commands as an array instead of an object with a commands key.
fix
Use correct import: const { commands } = require('react-native-esbuild'); not import commands from 'react-native-esbuild';
error: No platform specified
Missing --platform argument in esbuild-bundle.
fix
Add --platform android or --platform ios to the bundle command.
Error: esbuild version must be >=0.17
Outdated esbuild version installed.
fix
Update esbuild to >=0.17: 'yarn upgrade esbuild --latest' or 'npm install esbuild@latest'.
Upgrade
Version history
0.6.0latest on npm
Audit
Dependencies
@babel/coreoptionalPeer dependency for Babel transformations
esbuildrequiredPeer dependency, the core bundler engine
Agent activity
4 hits · last 30 days
node
4
Resources
react-native-esbuild — npm install react-native-esbuild · libregistry