SM Metro Bundler CLI
sm-metro-bundler-cli is a command-line interface tool designed to customize React Native bundling processes, specifically by adjusting module ID references to use strings instead of incremental numbers. It extends the functionality of the official Metro Bundler CLI. This tool is built upon and specifically compatible with React Native version 0.50.3, a version released in late 2017. Its primary differentiator is the modification of module ID referencing and the inclusion of commands (`init`, `upgrade`, `validate`) for managing project structures based on private templates (`sm-react-native-templates`), indicating a highly specialized use case, likely within a specific organizational context. The current stable version is 1.0.8, and given its reliance on an outdated React Native version, it does not appear to follow a regular release cadence or receive active updates for modern React Native development.
Common errors
-
Cannot find module 'metro' or 'metro-bundler-cli'
cause The underlying Metro bundler or the specific `metro-bundler-cli` dependency is not installed or discoverable in the expected path by the `sm-metro-bundler-cli` executable.fixEnsure `metro` and potentially `metro-bundler-cli` are installed either globally or as local dependencies in your project: `npm install --global metro` or `npm install metro`. -
Error: React Native version mismatch. Expected 0.50.3 but found X.Y.Z
cause Attempting to use `sm-metro-bundler-cli` with a React Native project that uses a version significantly different from 0.50.3, leading to incompatibility within the bundling process.fixThis package is designed for React Native 0.50.3 projects. For newer React Native versions, use the official `@react-native/community/cli` or directly configure `metro` as appropriate for your version, rather than `sm-metro-bundler-cli`.
Warnings
- breaking This CLI is explicitly built "Based on React Native 0.50.3". Using it with newer versions of React Native (e.g., 0.60.x and above) will lead to severe compatibility issues and likely outright failure, as Metro Bundler itself has evolved significantly.
- gotcha The `init`, `upgrade`, and `validate` commands reference a private repository (`sm-react-native-templates`). These commands are likely non-functional or problematic outside of the original developer's specific corporate environment, leading to unexpected errors or missing templates.
- deprecated The modification of module IDs for 'bundle splitting' or 'stable module IDs' as described in the reference `metro-bundler-cli` (which this project builds upon) might be superseded or handled differently in modern Metro Bundler versions. The techniques used here may not be optimal or necessary for current React Native development workflows.
Install
-
npm install sm-metro-bundler-cli -
yarn add sm-metro-bundler-cli -
pnpm add sm-metro-bundler-cli
Quickstart
npm install --global sm-metro-bundler-cli sm-metro-bundler bundle \ --entry-file index.js \ --bundle-output dist/business.jsbundle \ --assets-dest dist \ --platform ios \ --dev false # Example of using a custom command (template source is private) sm-metro-bundler init MyNewProject