For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /api/utils/get-module-paths.md.

getModulePaths

A helper function that generates regular expressions for matching module paths across different package manager formats (npm, yarn, pnpm, bun). You can use these regex patterns in your Rspack/webpack configuration to properly resolve modules regardless of which package manager you use.

Parameters

type GetModulePaths = (moduleNames: string[]) => RegExp[];

moduleNames

  • Type: string[]
  • Required: true

Array of module names to generate path patterns for.

Example

rspack.config.cjs
const Repack = require("@callstack/repack");

module.exports = {
  module: {
    rules: [
      {
        include: Repack.getModulePaths([
          "react-native",
          "react-native-macos",
          "react-native-windows",
        ]),
      },
    ],
  },
};

Need React or React Native expertise you can count on?