createResolveRequest
import { createResolveRequest } from "react-native-bundle-discovery";Creates a Metro resolveRequest that removes unnecessary React Native modules from release bundles
(dev builds are not affected). The CLI recommends these options when they apply to your bundle.
Options
| Option | Type | Default | Description |
|---|---|---|---|
removeUTFSequence | boolean | false | Remove the unused react-native/Libraries/UTFSequence.js module. |
removePromisePolyfill | boolean | false | Remove the react-native/Libraries/Promise.js polyfill. Enable only if you use Hermes. |
removeNewRenderer | boolean | false | Remove the Fabric renderer. Enable only if the New Architecture is disabled. |
removePromisePolyfill relies on Hermes' built-in Promise: React Native loads Promise.js only when Hermes' Promise isn't available. With JSC, global.Promise would be replaced with an empty module.
Example
const { createResolveRequest } = require("react-native-bundle-discovery");
const config = {
resolver: {
resolveRequest: createResolveRequest({
removeUTFSequence: true,
removePromisePolyfill: true, // Hermes only
}),
},
};