"Shared Angular" Documentation Seems Incorrect?
chucknelson opened this issue · comments
The current documentation around Shared Angular doesn't seem to be correct, or at least not with Angular 12, which I'm using.
The last paragraph talks about the need for "POST_R3" / Ivy-compatible versions of the Angular libraries if your app is using Ivy, but I don't think the esm-bundle
ones given actually provide that. For example, looking at the esm-bundle/angular__core repo, I don't see anywhere Ivy code would be generated, since ngcc
isn't called from what I can tell.
How I've tried to "confirm" this issue:
- Tried a simple single-spa-enabled Angular 12 app, works fine in a root config with no shared Angular dependencies / import maps.
- Added
@angular/core
as an external in the Angular 12 app, add it as an import map in the root config, pointing to theesm-bundle
version (also added RxJS, which it needs as an import map it seems?) - app fails to load in the browser, showing errorUncaught NullInjectorError: StaticInjectorError(Platform: core)[CompilerFactory]: NullInjectorError: No provider for CompilerFactory!
- Do the same thing, but now using my own Webpack'd version of
@angular/core
- same error - Run
ngcc
on my@angular/core
dependency, Webpack it again - app works as expected using the shared@angular/core
import map
To bundle my own ngcc
-compiled Angular libraries, I used the example repo in this issue's comment, single-spa/single-spa-angular#349 (comment). The only key difference I noticed with this method was the fact that ngcc
was called via postinstall
, so then the packed code was truly Ivy-compatible code.
Am I missing something in the docs? Or maybe the ngcc
step needs to be added to the Angular esm-bundle
repos?
Other related issues:
single-spa-angular isn't well maintained as I'm the only maintainer for it and I don't read through the issues for it or contribute fixes to it. I do review pull requests for it. Sharing Angular isn't easy due to complexities with Ivy and ng-packagr. I didn't read through your issue fully, but wish you luck in trying to get it to work.