Closed gedeagas closed 3 years ago
Can you prepare a repro project? Something is wrong with the way your project is being built, because it should never load chunk with such URI - noop://
.
Also make sure you're building with dev=false
from Gradle. npx react-native webpack-bundle ...
works because you're passing --dev false
manually, but it looks like the build from Gradle is passing dev
as true
.
Also make sure you're building with
dev=false
from Gradle.npx react-native webpack-bundle ...
works because you're passing--dev false
manually, but it looks like the build from Gradle is passingdev
astrue
.
let me double check again. And i will try to create a repro project.
Thanks for the swift response @zamotany
@zamotany i can't make the repro yet but i just added a logger in the webpack config.
The build from Gradle is indeed on production mode.
I even manually disabled the hmr.
entry: [
...ReactNative.getInitializationEntries(reactNativePath, {
hmr: false,
}),
entry,
],
I'm getting the same error in release builds. ( both android and iOS )
It seems like the local chunks are not included in the apk.
When I inspect the iOS .app
file there is only a main.jsbundle
.
I have checked the dev
variable in the config and its false
.
Fatal Exception: com.facebook.react.common.c: ChunkLoadError: Loading chunk 9557 failed.
(resolution: 9557)
repack: 2.5.1,
react-native: 0.65.1,
webpack: 5.65.0,
It seems like the local chunks are not included in the apk.
Have you specified localChunks
property in OutputPlugin
in your Webpack config?
I think so...
new ReactNative.OutputPlugin({
platform,
devServerEnabled: devServer.enabled,
remoteChunksOutput: path.join(__dirname, "build", platform, "remote"),
localChunks: /\.chunk\.(js)?bundle$/,
}),
Maybe I should have mentioned that we use monorepo and we have multiple targets/flavors.
@DanijelBojcic localChunks
matches only chunk name
(or id
if can cannot be obtained), so /\.chunk\.(js)?bundle$/
won't match anything. If you want to match everything you should provide /.*/
instead. If you want only specific chunks I suggest to:
/* webpackChunkName: "myChunk" */
in import()
localChunks: ['myChunk']
or localChunks: [/myChunk/]
@zamotany how to generate the apk and the ipa to include the local chunks
Local chunks should be included in the apk/ipa by default. Are you getting any errors?
I have the same problem
after setting localChunks
to [/.*/]
it seems the chunks make their way into the apk, but it seems to me that despite using webpackChunkName
in import()
, and using chunkFilename: '[name].chunk.bundle',
in webpack config, chunks still get named randomly (like 462.chunk.bundle
)
So it fails
I get a different error in logs though:
'ChunkManager.resolveChunk error:', 'No remote chunk resolver was provided. Did you forget to add `ChunkManager
.configure({ resolveRemoteChunk: ... })`?'
Environment
Android 10. React Natvie 64.2
Description
So my build is finished successfully, the main bundle is generated but somehow the chunk is not getting copied to the APK resulting in ChunkLoadError.
When I run manually with this command, the chuck is in the correct assets folder.
npx react-native webpack-bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle
So I suppose the problem is that the bundle is not getting copied by react-native Gradle because the APK doesn't have any of the chunks that they are supposed to have.