-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Description
Bug report
What is the current behavior?
In an esm package, I have two modules, one imports another by self referencing
{
"name": "my-pkg",
"type": "module",
"exports": {
"./module-a": "./module-a.js",
"./module-b": "./module-b.js"
}
}// module-a.js
export function a() {}// module-b.js
import { a } from "my-pkg/module-a";
export function b() {
return a();
}In another app, I use module federation and share the two modules:
// Partial webpack.config.js
new ModuleFederationPlugin({
shared: {
"my-pkg/module-a": {
singleton: true,
version: "1.0.0"
},
"my-pkg/module-b": {
singleton: true,
version: "1.0.0"
},
}
});When I start the dev-server, it reports a warning of:
WARNING in shared module my-pkg/module-a
No required version specified and unable to automatically determine one. Unable to find required version for "my-pkg" in description file (.../packages/my-pkg/package.json). It need to be in dependencies, devDependencies or peerDependencies.
And according to the warning, I added the package itself as a dependency, the warning disappears:
{
"name": "my-pkg",
"type": "module",
"exports": {
"./module-a": "./module-a.js",
"./module-b": "./module-b.js"
},
"dependencies": {
"my-pkg": "*" // It's weird to do this...
}
}If the current behavior is a bug, please provide the steps to reproduce.
It's a bit complex in my real repo, I can provide a minimal repro if you require, when I got time.
What is the expected behavior?
No warnings. It should use the description file (my-pkg/package.json) itself to determine the required version, since it's a self referencing.
Other relevant information:
webpack version: 5.75.0
Node.js version: 16.15.0
Operating System: MacOS
Additional tools: