Open Antarus66 opened 4 years ago
This is something that people have done before, and I hope to create an example showing it at some point in the future. If you join our slack workspace there are several people there who can guide you on this.
@Antarus66 you might be interested inhttps://indepth.dev/webpack-5-module-federation-a-game-changer-in-javascript-architecture/ :)
@Antarus66 did you solve this problem? I have the same.
@joeldenning I'm facing a similar issue. Any example of sharing dependencies between angular apps? tried searching, couldn't get much information on this. TIA :)
Angular's Ivy Compiler forbids runtime sharing of dependencies, which is why this example does not use it. If you use View Engine, you can do runtime sharing. More info about Ivy compiler at https://twitter.com/Joelbdenning/status/1253781652486017024
Understand. Thanks for sharing the detailed information :)
Works when I removed @ at the beginning of the angular dependencies names:
const singleSpaAngularWebpack = require('single-spa-angular/lib/webpack').default
const webpackMerge = require("webpack-merge");
module.exports = (angularWebpackConfig, options) => {
const singleSpaWebpackConfig = singleSpaAngularWebpack(angularWebpackConfig, options);
const externalsConfig = {
externals: {
"zone.js": "Zone",
"rxjs": "rxjs",
"rxjs/operators": "rxjs/operators",
"moment": "moment",
"angular/core": "@angular/core",
"angular/common": "@angular/common",
"angular/compiler": "@angular/compiler",
"angular/forms": "@angular/forms",
"angular/platform-browser": "@angular/platform-browser",
"angular/platform-browser-dynamic": "@angular/platform-browser-dynamic",
"angular/animations": "@angular/animations",
"angular/router": "@angular/router"
},
};
const mergedConfig = webpackMerge.smart(singleSpaWebpackConfig, externalsConfig);
return mergedConfig;
}
I am wondering, if i have some import like this for moment
import 'moment'
I have added moment's cdn to my import map
How do I use methods in moment like moment.now()
. It currently says "moment cannot be found"
I keep getting this error when trying to share angular dependencies like rxjs
or @angular/core
:
Cannot use import statement outside a module
I have tried to disable Ivy but no changes, I'm using angular 9
Could someone share their experience of sharing Angular deps between several single-spa applications?
I made a recommended setup like in this repo:
https://github.com/polyglot-microfrontends/shared-dependencies
It works for some libs but doesn't work for Angular.
What I've done for the moment:
It works fine for dependencies except of @angular/* On application loading I see: