webpack module federation doesn't work after vue-cli@5.0.0-beta.3
See original GitHub issueVersion
5.0.0-rc.0
Reproduction link
Environment info
System:
OS: Windows 10 10.0.18363
CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
Binaries:
Node: 14.17.4 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.17 - ~\AppData\Roaming\npm\yarn.CMD
npm: 7.24.1 - C:\Program Files\nodejs\npm.CMD
Browsers:
Chrome: 95.0.4638.69
Edge: Spartan (44.18362.1533.0)
npmGlobalPackages:
@vue/cli: Not Found
Steps to reproduce
serve the app-one
project.
server the consumer
project.
open the consumer server. You will see that it says it cannot load the remoteScript which probably is because of an error in the generated script and it doesn’t happen in vue-cli@5.0.0-beta.3
What is expected?
It is expected that the remote script runs to the end and initiate the remote namespace to be used inside the consumer project.
What is actually happening?
The remote namespace at the end of the script is always undefined. this part is also probably generated by webpack but I think the error is happening where vue-cli injects some additional codes in there right before the last line.
I have also a working example which you can check https://github.com/farhadnowzari/vue-cli-module-federation-working-example.
Issue Analytics
- State:
- Created 2 years ago
- Comments:13 (2 by maintainers)
Top Results From Across the Web
Webpack module federation error: Cannot destructure ...
I am currently modifying the configuration file a Vue app (acting here as a host app) to implement the plugin of webpack ......
Read more >Module Federation - webpack
This object is used as a shared scope in the remote container and is filled with the provided modules from a host. It...
Read more >tysonrm - npm
This Webpack plugin extracts data from the Webpack build, and in particular a build that uses the `ModuleFederationPlugin`, and posts it to the ......
Read more >Setting up remote components and services with webpack ...
Setting up remote components and services with webpack module federation ... Add run script to your package.json to run the server. { "name":...
Read more >Micro-frontends: Module Federation with WebPack 5
Is there a solution to this problem? There is, there are strategies to break that main.js file into chunks of smaller files in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi, I’m having a similar issue, might be the same problem. I created 4 projects from scratch.
The 2 that were created by vue-cli are not working with vue-cli 5.0.0. rc.0, and the 2 that are not are working perfectly fine.
I started with vue-cli 5.0.0. rc.0 and then I tried switching to the beta-3 version suggested here and got it to work.
That being said, I only managed to get this working on vue-cli-service using defineAsyncComponent, however, on the other non cli created projects, I had no problem using regular import…
The configuration provided for the host app in vue.config.js:
The configuration provided for the consumer app in vue.config.js:
I’m getting the following error:
I got it to work with vue-cli@5.0.0-rc.0. I have opened an issue also on stackoverflow and this answer did the job. https://stackoverflow.com/a/69900302/14206887
So the consumer’s app
vue.config.js
configureWebpack section looks like this:Note the
optimization
property where the splitChunks is set tofalse
Now the question, is it a webpack issue or a vue-cli issue? because on vue-cli@5.0.0-bete.3 it seems to be fine and it doesn’t need this
splitChunks:false