Coder Social home page Coder Social logo

ChunkLoadError on Android about repack HOT 12 CLOSED

callstack avatar callstack commented on May 27, 2024
ChunkLoadError on Android

from repack.

Comments (12)

zamotany avatar zamotany commented on May 27, 2024 1

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://.

from repack.

zamotany avatar zamotany commented on May 27, 2024 1

@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:

  1. Use /* webpackChunkName: "myChunk" */ in import()
  2. Set localChunks: ['myChunk'] or localChunks: [/myChunk/]

from repack.

zamotany avatar zamotany commented on May 27, 2024

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.

from repack.

gedeagas avatar gedeagas commented on May 27, 2024

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.

let me double check again. And i will try to create a repro project.

Thanks for the swift response @zamotany

from repack.

gedeagas avatar gedeagas commented on May 27, 2024

@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.
Screen Shot 2021-07-17 at 12 47 22 AM

I even manually disabled the hmr.

entry: [
    ...ReactNative.getInitializationEntries(reactNativePath, {
      hmr: false,
    }),
    entry,
  ],

from repack.

DanijelBojcic avatar DanijelBojcic commented on May 27, 2024

I'm getting the same error in release builds. ( both android and iOS )

Description

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.

Crashlytics stack trace:

Fatal Exception: com.facebook.react.common.c: ChunkLoadError: Loading chunk 9557 failed.
(resolution: 9557)

Versions:

repack: 2.5.1,
react-native: 0.65.1,
webpack: 5.65.0,

from repack.

zamotany avatar zamotany commented on May 27, 2024

It seems like the local chunks are not included in the apk.

Have you specified localChunks property in OutputPlugin in your Webpack config?

from repack.

DanijelBojcic avatar DanijelBojcic commented on May 27, 2024

I think so...

  new ReactNative.OutputPlugin({
      platform,
      devServerEnabled: devServer.enabled,
      remoteChunksOutput: path.join(__dirname, "build", platform, "remote"),
      localChunks: /\.chunk\.(js)?bundle$/,
    }),

from repack.

DanijelBojcic avatar DanijelBojcic commented on May 27, 2024

Maybe I should have mentioned that we use monorepo and we have multiple targets/flavors.

from repack.

andreszuluaga-wolox avatar andreszuluaga-wolox commented on May 27, 2024

@zamotany how to generate the apk and the ipa to include the local chunks

from repack.

zamotany avatar zamotany commented on May 27, 2024

Local chunks should be included in the apk/ipa by default. Are you getting any errors?

from repack.

jd1378 avatar jd1378 commented on May 27, 2024

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: ... })`?'

from repack.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.