angular: Ivy: NGCC incorrectly compiles the "@ngxs/router-plugin" as UMD
🐞 bug report
Affected Package
Is this a regression?
Yes
Description
The NGCC incorrectly compiles the @ngxs/router-plugin
as UMD.
🔬 Minimal Reproduction
https://github.com/arturovt/ivy-ngxs-router-plugin-umd-repro
- clone and install dependencies
- check the
postinstall
script
Or open the node_modules/@ngxs/router-plugin/bundles/ngxs-router-plugin.umd
file in your IDE and see the generated code at the end of the factory(....)
function. This has to be something like global...modules.ngxsFeature.module
.
Providing screenshot below (this is how it looks like on my PC):
🌍 Your Environment
Angular Version:
Angular CLI: 9.0.0-rc.4
Node: 12.11.1
OS: linux x64
Angular: 9.0.0-rc.4
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Ivy Workspace: Yes
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.900.0-rc.4
@angular-devkit/build-angular 0.900.0-rc.4
@angular-devkit/build-optimizer 0.900.0-rc.4
@angular-devkit/build-webpack 0.900.0-rc.4
@angular-devkit/core 9.0.0-rc.4
@angular-devkit/schematics 9.0.0-rc.4
@ngtools/webpack 9.0.0-rc.4
@schematics/angular 9.0.0-rc.4
@schematics/update 0.900.0-rc.4
rxjs 6.5.3
typescript 3.6.4
webpack 4.41.2
UPD
I could guess that it emits such code due to the inability to compile this package at all. The compiler behaves differently, because:
- in 80% of cases it compiles without errors and generates such code
- in 20% of cases it throws during compilation with:
Error: Error on worker #1: Error: Failed to compile entry-point @ngxs/router-plugin due to compilation errors:
node_modules/@ngxs/router-plugin/bundles/ngxs-router-plugin.umd.js(1034,34): error TS-991010: Value at position 0 in the NgModule.imports of NgxsRouterPluginModule is not a reference: [object Object]
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 2
- Comments: 20 (19 by maintainers)
OK so now that #34356 has landed, I believe that #34254 should be enough to fix this package, assuming that you are using the latest
dev
version of the package. Hopefully it will be merged this week and appear in the next RC next week.Updating Angular to use the artifacts from https://github.com/angular/angular/pull/34254 removes this error and the ngcc processing seems to complete without error.
That being said I now see that it adds an incorrect export into the
node_modules/@ngxs/store/ngxs-store.d.ts
file:It is confusing the public export from this file:
with the exports from the referenced files.