You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Undetermined shared module version when importing a file from the module directly #13457
When importing a file directly from a module (i.e. import "react-dom/test-utils") when it's configured to be shared via ModuleFedrationPlugin a warning with a nonsensical instruction may be emitted when running a build:
WARNING in shared module react-dom
No required version specified and unable to automatically determine one. Unable to find required version for "react-dom" in description file (/home/user/test/node_modules/react-dom/package.json). It need to be in dependencies, devDependencies or peerDependencies.
If the current behavior is a bug, please provide the steps to reproduce.
Expected, you want to share react-dom, but request react-dom/test-utils, change on "react-dom/test-utils": { singleton: true },, but I think we need improve error message here
Maybe, but in my case it was a dependency of a dependency that imported react-dom/test-utils and I can't deduce that from the error message. And I want react-dom, not react-dom/test-utils, as the former is what I care about and what is imported everywhere.
I just tried adding both react-dom and react-dom/test-utils to the shared config and the error is still shown. Using only react-dom/test-utils is not an option as I need react-dom to be shared.
I have the same issue happening with @angular/common .
shared module @angular/common - Warning: No required version specified and unable to automatically determine one. Unable to find required version for "@angular/common" in description file (.../node_modules/@angular/common/package.json). It need to be in dependencies, devDependencies or peerDependencies.
In the package.json file there is no entry for @angular/common under those properties.
Reacted by vicmuresanu, Piyush Sonagara and Ali Asadi
WARNING in shared module react
No required version specified and unable to automatically determine one. Unable to find required version for "react" in description file (/Users/deepaknegi/Desktop/projects/email-template-ui/node_modules/@emotion/react/jsx-runtime/package.json). It need to be in dependencies, devDependencies or peerDependencies.
I had the same issue with “deep-object-diff” and solved it with this. Notice the required version and version. new ModuleFederationPlugin({ …, shared: { …packageJSONDeps, “deep-object-diff”: { singleton: true, version: packageJSONDeps[“deep-object-diff”], requiredVersion: packageJSONDeps[“deep-object-diff”] }}}
Therefore, the presence of an additional files is not even required, but can only break the logic of determining versions and names.
I don't think we are making a mistake here, rather the opposite, we are allowing this problem to be caught. The only solution is to specify the version manually, you can read the package.json of @sentry/browser so you don't have to write it manually.
I would advise you to open an issue in this repository and refer to this issue, such problems will most likely appear in any bundlers (which support module federation), and even most likely in other tools.
From npm docs - any published package.json, it doesn't matter where placed should have this information. Moreover, you can publish a whole mono repo and have multiple packages in a package. I can change this logic here but it will most likely break other examples and will be a breaking change
@eemeli - Yeah I see, because changing the resolver logic can be dangerous without spec/docs and because developers close this issue I would interpret this as mandatory fields always for any published projects
Activity
alexander-akait commentedon May 27, 2021
Expected, you want to share
react-dom, but requestreact-dom/test-utils, change on"react-dom/test-utils": { singleton: true },, but I think we need improve error message hereHornwitser commentedon May 27, 2021
Maybe, but in my case it was a dependency of a dependency that imported
react-dom/test-utilsand I can't deduce that from the error message. And I wantreact-dom, notreact-dom/test-utils, as the former is what I care about and what is imported everywhere.I just tried adding both
react-domandreact-dom/test-utilsto the shared config and the error is still shown. Using onlyreact-dom/test-utilsis not an option as I needreact-domto be shared.arrgson commentedon Jun 22, 2021
I have the same issue happening with @angular/common .
shared module @angular/common - Warning: No required version specified and unable to automatically determine one. Unable to find required version for "@angular/common" in description file (.../node_modules/@angular/common/package.json). It need to be in dependencies, devDependencies or peerDependencies.In the package.json file there is no entry for @angular/common under those properties.
brendonco commentedon Jul 1, 2021
@sokra does webpack version 5.41.1 fix this issue?
alexander-akait commentedon Jul 1, 2021
No, you can send a fix
flyyuan commentedon Jul 28, 2021
same problem.
webpack-bot commentedon Oct 27, 2021
This issue had no activity for at least three months.
It's subject to automatic issue closing if there is no activity in the next 15 days.
deepaknegi10 commentedon Nov 8, 2021
Getting similar issue, any fixes?
WARNING in shared module react
No required version specified and unable to automatically determine one. Unable to find required version for "react" in description file (/Users/deepaknegi/Desktop/projects/email-template-ui/node_modules/@emotion/react/jsx-runtime/package.json). It need to be in dependencies, devDependencies or peerDependencies.
30 remaining items
Bairon29 commentedon Oct 16, 2024
I had the same issue with “deep-object-diff” and solved it with this. Notice the required version and version.
new ModuleFederationPlugin({ …, shared: { …packageJSONDeps, “deep-object-diff”: { singleton: true, version: packageJSONDeps[“deep-object-diff”], requiredVersion: packageJSONDeps[“deep-object-diff”] }}}krutoo commentedon Oct 18, 2024
@alexander-akait here is the example of problem:
https://github.com/krutoo/module-federation-dual-packages
alexander-akait commentedon Oct 21, 2024
@krutoo Yeah, because there is a bug in
@sentry/browser, look atnode_modules/@sentry/browser/build/npm/esm/package.json:{"type":"module","sideEffects":false}No
nameandversion.From docs:
https://docs.npmjs.com/cli/v10/configuring-npm/package-json
The package is published, and it is necessary to specify these fields, even if it is used for switching the
type.They already have:
Therefore, the presence of an additional files is not even required, but can only break the logic of determining versions and names.
I don't think we are making a mistake here, rather the opposite, we are allowing this problem to be caught. The only solution is to specify the version manually, you can read the
package.jsonof@sentry/browserso you don't have to write it manually.I would advise you to open an issue in this repository and refer to this issue, such problems will most likely appear in any bundlers (which support module federation), and even most likely in other tools.
krutoo commentedon Oct 22, 2024
@alexander-akait but name and version is defined in root package.json
according to this logic, all information from the root package.json should be duplicated
I did this in my packages and specified the version, but then module federation complained about the lack of dependency versions
alexander-akait commentedon Oct 22, 2024
@krutoo
No,
package.jsondo not inherit information from the previous oneAny
package.jsonshould havenameandversionif it is published, even for nested, this is the rulekrutoo commentedon Oct 22, 2024
@alexander-akait
@sentry/nodehas exactly same structure and same nested package.json, when you import it in Node.js .mjs file it works fineI think the rule you are talking about applies only to the main
package.jsonalexander-akait commentedon Oct 22, 2024
From npm docs - any published
package.json, it doesn't matter where placed should have this information. Moreover, you can publish a whole mono repo and have multiple packages in a package. I can change this logic here but it will most likely break other examples and will be a breaking changeeemeli commentedon Oct 22, 2024
The npm docs on this are misleading, and unfortunately my attempt to clarify them was recently closed by @wraithgar: npm/documentation#134.
alexander-akait commentedon Oct 23, 2024
@eemeli - Yeah I see, because changing the resolver logic can be dangerous without spec/docs and because developers close this issue I would interpret this as mandatory fields always for any published projects
fix(mf): resolve version from parent package for secondary entry points
fix(mf): resolve version from parent package for secondary entry points
fix(mf): resolve version from parent package for secondary entry points
fix(mf): resolve version from parent package for secondary entry points
fix(mf): resolve version from parent package for secondary entry points
fix(mf): resolve version from parent package for secondary entry points