Re.Pack is designed to alter the bundle generated by Webpack to make it runnable in React Native. As such, it's extremely specific to React Native and the code produced by it, will not work on Web.
You should never use Re.Pack when creating a bundle for Web!
Instead, you should create 2 separate Webpack configs, for example:
webpack.config.react-native.{js,mjs,cjs}
- Configured Webpack for React Native and uses Re.Pack.webpack.config.web.{js,mjs,cjs}
- Configures Webpack for Web without Re.Pack.If you need to share common config, you can create webpack.config.base.{js,mjs,cjs}
for the common options and import it inside webpack.config.react-native.{js,mjs,cjs}
and webpack.config.web.{js,mjs,cjs}
.
Make sure you specify --webpack-config <path>
when running react-native webpack-start
or react-native webpack-bundle
and --config <path>
when running Webpack CLI for Web.