Unable to resolve specifier 'lodash/fp' imported from ...
alaindeurveilher opened this issue · comments
Alain D'EURVEILHER commented
Hello,
I am trying to build up a MFE application with Native Federation (v17.1.7)
I have a shell.
I have a remote defined in a different repository.
In my remote I have a service which uses some functions from lodash/fp
My shell does not use lodash/fp, so lodash is naturally not present in its package.json file.
Now, when I load the remote in the shell I get the following error on runtime in the console:
_angular_core-17_3_0-dev.js:3806 ERROR Error: Unable to resolve specifier 'lodash/fp' imported from http://localhost:5202/Routes.js
at throwUnresolved (es-module-shims.js:445:11)
at _resolve (es-module-shims.js:402:71)
at es-module-shims.js:850:32
at Array.map (<anonymous>)
at es-module-shims.js:846:45
at _ZoneDelegate.invoke (zone.js:368:26)
at _Zone.run (zone.js:130:43)
at zone.js:1260:36
at _ZoneDelegate.invokeTask (zone.js:403:31)
at _Zone.runTask (zone.js:174:47)
Example:
- In my remote:
import { getOr } from 'lodash/fp';
...
let message: string = getOr(path, path, I18S[this.language()]);
- I even tried to add something explicitely in the federation.config.js file of the remote:
shared: {
...shareAll({ singleton: true, strictVersion: true, requiredVersion: 'auto' }),
...share({
'lodash/fp': { singleton: true, strictVersion: true, requiredVersion: 'auto' },
}),
},
But it did not solve the problem.
- Also my remoteEntry.json file does not list anywhere 'lodash/fp'. Only 'lodash':
{
"packageName": "lodash",
"outFileName": "lodash-4_17_21-dev.js",
"requiredVersion": "^4.17.21",
"singleton": true,
"strictVersion": true,
"version": "4.17.21",
"dev": {
"entryPoint": "C:/Users/XXXX/workspace/mfe-app/node_modules/lodash/lodash.js"
}
...
{
"packageName": "/@id/lodash",
"outFileName": "lodash-4_17_21-dev.js",
"requiredVersion": "^4.17.21",
"singleton": true,
"strictVersion": true,
"version": "4.17.21",
"dev": {
"entryPoint": "C:/Users/XXXX/workspace/mfe-app/node_modules/lodash/lodash.js"
}
Could you please help fixing the issue?
Thank you.
Manfred Steyer commented
It's a commonjs vs. esm issue. Please look here:
#460