I’m trying to use repack in React Native to split my codebase into multiple bundles, but I’m facing some challenges. I’ve installed repack following the documentation and attempted some configurations, but encountered issues.
Specifically, I’d like to know how to properly configure and use repack to achieve the following:
- How do I set up repack in my React Native project to generate multiple bundles?
- What’s the correct way to configure the entry point and output directory for repack?
- Are there any examples or best practices available to guide me in using repack for multi-bundle packaging?
I’ve consulted the official repack documentation, but it lacks sufficient integration details and practical configuration examples for React Native. Therefore, I’m seeking advice and guidance from experienced developers in the community.
Here’s an example of my current repack configuration file:
entry: {
main: [
'./scripts/preModule.ts',
...Repack.getInitializationEntries(
path.resolve(context, 'node_modules/react-native'),
{hmr: devServer?.hmr && isDev}
),
'./pages/entry/src/index.tsx',
],
demo: [
'./scripts/preModule.ts',
...Repack.getInitializationEntries(
path.resolve(context, 'node_modules/react-native'),
{hmr: devServer?.hmr && isDev}
),
'./pages/demo/src/index.tsx'],
},
output: {
clean: false,
path: resolveDist(platform),
filename: devServer ? '[name].index.bundle' : `[name].${getBundleName(platform)}`,
publicPath: Repack.getPublicPath({platform, devServer, host}),
},
const getBundleName = platform => `project.${platform}.jsbundle`
When I run bundle command, I got this: ERROR in Conflict: Multiple assets emit different content to the same filename pikachu.ios.jsbundle.map.
Any suggestions or help regarding how to configure repack correctly for generating multiple bundles would be greatly appreciated. Thank you for your assistance!