Webpack 5 ModeFederation error when shared package version is not in semver
See original GitHub issueBug report
What is the current behavior? One of our packages has version ‘dev’ set in package.json as it is internal not released yet package.
....
"dependencies": {
"{PACKAGE_NAME}": "dev",
}
....
When I try to configure ModeFederationPlugin for our main app I configure shared modules as follows:
const packageJson = require('../package.json');
const packageName = packageJson.name;
const packageDeps = packageJson.dependencies;
new ModuleFederationPlugin({
....
shared: {
...packageDeps,
react: {
singleton: true,
eager: true,
requiredVersion: packageDeps.react,
},
'react-dom': {
singleton: true,
eager: true,
requiredVersion: packageDeps['react-dom'],
},
},
....
}),
When I run webpack it gives me next error:
ERROR in resolving fallback for shared module ($PACKAGE_NAME}
Module not found: Error: Can't resolve 'dev' in '{PATH_TO_FILE_USING_PACKAGE}'
If the current behavior is a bug, please provide the steps to reproduce.
- Add package with version different from semantic versioning standard to dependencies of the project
- Try to add
ModuleFederationPlugin
to the webpack config of the app with the following config:
const packageJson = require('../package.json');
const packageName = packageJson.name;
const packageDeps = packageJson.dependencies;
new ModuleFederationPlugin({
name: packageName,
remotes: {},
shared: {
...packageDeps,
angular: {
singleton: true,
eager: true,
requiredVersion: packageDeps.angular,
},
react: {
singleton: true,
eager: true,
requiredVersion: packageDeps.react,
},
'react-dom': {
singleton: true,
eager: true,
requiredVersion: packageDeps['react-dom'],
},
},
}),
- Run webpack and see the errors in the console
What is the expected behavior?
I assume that if webpack can resolve node_modules with non-semantic versioning then ConsumeSharedPlugin
should also be able to
If any additional info is needed for me, please let me know
Other relevant information: webpack version: 5.24.4 Node.js version: v14.15.0 Operating System: macOS Catalina Version 10.15.7 Additional tools:
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (6 by maintainers)
Top Results From Across the Web
Document webpack change: Versioned shared modules for ...
The new system is based on versions of shared modules. In group of federated builds all parts will agree on the highest version...
Read more >Getting Out of Version-Mismatch-Hell with Module Federation
This shows that Module Federation uses different versions for both applications.
Read more >webpack reads wrong dependency versions from package ...
Inside my Module Federation setup I have a host application that consumes a few remote apps. They all share the angular ...
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 >Semantic Versioning 2.0.0 | Semantic Versioning
0. Summary. Given a version number MAJOR.MINOR.PATCH, increment the: MAJOR version when you make incompatible API changes; MINOR ...
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
We have logic to detect
singleton
problems with multiple versions, so each package should have valid (parsable by semver) versionIssue was closed because of inactivity.
If you think this is still a valid issue, please file a new issue with additional information.