Trying to share external npm library among MFE application using "@nrwl/angular": "^14.4.0",
created a base module-federation.config.js and added the library
const coreLibraries = new Set([
'@ckeditor/ckeditor5-build-classic',
'@ckeditor/ckeditor5-angular',
]);
module.exports = {
shared: (libraryName, defaultConfig) => {
if (coreLibraries.has(libraryName)) {
console.log(libraryName); // The library never occurs here
return defaultConfig;
}
return false;
},
};
In the coreLibraries.has(libraryName) condition the library is not present and hence facing the exception as
ERROR Error: Uncaught (in promise): CKEditorError: ckeditor-duplicated-modules
Read more: https://ckeditor.com/docs/ckeditor5/latest/support/error-codes.html#error-ckeditor-duplicated-modules
CKEditorError: ckeditor-duplicated-modules
Read more: https://ckeditor.com/docs/ckeditor5/latest/support/error-codes.html#error-ckeditor-duplicated-modules
at ckeditor.js:6:316950
at ckeditor.js:6:315303
at ckeditor.js:6:217
at ckeditor.js:6:80
at 9949 (ckeditor.js:6:1)
at __webpack_require__ (bootstrap:19:1)
at 8210 (core.mjs:1831:1)
at __webpack_require__ (bootstrap:19:1)
at 373 (entry.component.html:7:63)
at __webpack_require__ (bootstrap:19:1)
at resolvePromise (zone.js:1211:31)
at resolvePromise (zone.js:1165:17)
at zone.js:1278:17
at _ZoneDelegate.invokeTask (zone.js:406:31)
at Object.onInvokeTask (core.mjs:26510:33)
at _ZoneDelegate.invokeTask (zone.js:405:60)
at Zone.runTask (zone.js:178:47)
at drainMicroTaskQueue (zone.js:585:35)
The issue occurred because in other mfe the module is included multiple times
In the package.json I have the below dependencies
"dependencies": {
"@ckeditor/ckeditor5-angular": "^4.0.0",
"@ckeditor/ckeditor5-build-classic": "^34.2.0"
}
During the build, there is no logs on the console, because @ckeditor/ckeditor5-angular is not present.
How do we shared npm libraries in all mfs , it is suppose to be done by module-federation.config.js