webpack-external-import icon indicating copy to clipboard operation
webpack-external-import copied to clipboard

Unhandled Rejection (ChunkLoadError):

Open ghost opened this issue 5 years ago • 6 comments

I'm getting this error when I try to use it with CRA

Unhandled Rejection (ChunkLoadError): Loading chunk mod failed. (missing: http://localhost:3000/static/js/mod.chunk.js)

ghost avatar Apr 09 '20 11:04 ghost

I get this error too. Has anyone managed to resolve it?

rickihastings avatar Jul 09 '20 15:07 rickihastings

After much digging, if anyone else encounters this issue, the fix is very easy, and is down to this line here: https://github.com/facebook/create-react-app/blob/fa648daca1dedd97aec4fa3bae8752c4dcf37e6f/packages/react-scripts/config/webpack.config.js#L216

config.output.jsonpFunction = 'webpackJsonp';

rickihastings avatar Jul 09 '20 19:07 rickihastings

I'm not using CRA, and still have OP's error, changing it to the default config.output.jsonpFunction = 'webpackJsonp' ; does not solve it

mihaisavezi avatar Aug 04 '20 11:08 mihaisavezi

My situation is as follows. 2 apps, one provider, one consumer. I am exposing 'xxx-web-v2' from provider to consumer.


// consumer/webpack.config.js
 runtimeChunk: 'single',
 ... 
 new URLImportPlugin({
      manifestName: "xxx-app-child",
      fileName: "importManifest.js",
      publicPath: `http://localhost:8000/`,
      useExternals: {
        'xxx-web-v2': '"xxx-web-v2"',
 },

// provider/webpack.config.js

 new URLImportPlugin({
          manifestName: "xxx-app-parent",
          fileName: "importManifest.js",
          provideExternals: {
            appConfig: '__APP_ENVIRONMENT',
            "xxx-web-v2": 'umd xxx-web-v2', // YES
          },
          // otherwise ended up in infinite loop
          hashDigest: 'hex',
          hashDigestLength: 5,
          hashFunction: 'sha512'
        })

mihaisavezi avatar Aug 04 '20 12:08 mihaisavezi

I struggled to properly get this working in the end. There seemed to be constant problems and the whole solution didn't feel very nice.

I went with ModuleFederation in webpack 5, but I believe that's still in beta right now.

rickihastings avatar Aug 04 '20 19:08 rickihastings

Yeah, made it work, but I need a lot of external dependencies, and provideExternals/UseExternals doesn't support the array format. externals = [{...}, () => {...},'string']

mihaisavezi avatar Aug 05 '20 15:08 mihaisavezi