React Native Bundle Discovery

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

OptionTypeDefaultDescription
removeUTFSequencebooleanfalseRemove the unused react-native/Libraries/UTFSequence.js module.
removePromisePolyfillbooleanfalseRemove the react-native/Libraries/Promise.js polyfill. Enable only if you use Hermes.
removeNewRendererbooleanfalseRemove 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

metro.config.js
const { createResolveRequest } = require("react-native-bundle-discovery");

const config = {
  resolver: {
    resolveRequest: createResolveRequest({
      removeUTFSequence: true,
      removePromisePolyfill: true, // Hermes only
    }),
  },
};

On this page