10

My host is throwing this error.

enter image description here

NOTE: I tried accessing this directly in the browser https://localhost:5007/accom-web/dist/js/assets/browser-bundle/remoteEntryTest.js and I'm served the remoteEntryTest.js file.

This is my webconfig in host.

enter image description here

This is webconfig of remote application.

enter image description here

Optimization config for remote application is below.

optimization: {
    runtimeChunk: false,
    emitOnErrors: true,
    splitChunks: {
       minSize: 256000,
       minChunks: 1,
       maxAsyncRequests: 10,
       automaticNameDelimiter: '-',
       cacheGroups: {
           chunks: 'initial',
           .....
       },
    },
    .....
}

I looked at the GitHub issues regarding this too but didn't help much.

https://github.com/module-federation/module-federation-examples/issues/307 https://github.com/module-federation/module-federation-examples/issues/1273 https://github.com/module-federation/module-federation-examples/issues/692

Any suggestions on this how to fix it?

2
  • any solution for this error ? Commented Dec 6, 2022 at 11:51
  • same issue, any solution for this error please? Commented Jan 16, 2023 at 7:38

3 Answers 3

11

I had a similar issue with specifying shared dependencies on a remote. I ended up having to disable splitChucks after reviewing your Github references. I'm sure you tried that as well but this got my remote working again recently.

optimization: {
        splitChunks: false,
    },
Sign up to request clarification or add additional context in comments.

6 Comments

hi @jaskru where to add optimization
@GopinathKaliappan Inside webpack config.
What if need both SplitChunks as well as Remote??
What about Vite?, it doesn't have that option.
@xzegga did you find solution for vite?
|
0

Change the URL https to http in remotes. It works for me

Comments

0

Before the below version of webpack, we can provide any name in "remotes" like {mycomponent : "mycomponent@https://module.domain.com/remoteEntry.js"}.

Remote webpack.config.js

new ModuleFederationPlugin({
    name : 'module_name_1',
    filename : 'remoteEntry.js',
    exposes : {
        './Component1'  : './src/screens/ComponentsOne',
        './Component2'  : './src/screens/ComponentsTwo',
   }
})
"webpack": "^5.99.8",
"webpack-cli": "^6.0.1",
"webpack-dev-server": "^5.2.1"

But after the below version, remote name and local should be same.

"webpack": "^5.102.0",
"webpack-cli": "^6.0.1",
"webpack-dev-server": "^5.2.2"

Local webpack.config.js

new ModuleFederationPlugin({
    name : 'allmodules',
    remotes : {
        module_name_1  : 'module_name_1@https://module.domain.com/remoteEntry.js'
    }
})

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.