question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ivy: NGCC incorrectly compiles the "@ngxs/router-plugin" as UMD

See original GitHub issue

🐞 bug report

Affected Package

@angular/compiler-cli

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):

image

🌍 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]

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:20 (19 by maintainers)

github_iconTop GitHub Comments

2reactions
petebacondarwincommented, Dec 12, 2019

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.

2reactions
petebacondarwincommented, Dec 11, 2019

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:

export {Ι΅l as NgxsRootModule} from './src/modules/ngxs-root.module';
export {Ι΅x as NgxsFeatureModule} from './src/modules/ngxs-feature.module';

It is confusing the public export from this file:

export { NgxsFeatureModule as Ι΅x } from './src/modules/ngxs-feature.module';
export { NgxsRootModule as Ι΅l } from './src/modules/ngxs-root.module';

with the exports from the referenced files.

Read more comments on GitHub >

github_iconTop Results From Across the Web

error: failed to initialize angular compilation - ngcc failed.
The NGCC incorrectly compiles the @ngxs/router-plugin as UMD. Minimal Reproduction. https://github.com/arturovt/ivy-ngxs-router-plugin-umd-repro. clone andΒ ...
Read more >
Angular 11 is not running ngcc - ivy - Stack Overflow
My problem was that an another tsconfig file was overwriting the root's definitions, and turned off ivy and ngcc altogether.
Read more >
After upgrading to Angular 10, ivy ngcc is compiling as a esm5 ...
After upgrading to Angular 10, ivy ngcc is compiling as a esm5, umd modules. My Environnement: ngular CLI: 10.2.0 Node: 12.15.0 OS: win32Β ......
Read more >
The Angular linker (goodbye ngcc!) - Ninja Squad
Angular 11.1 introduced a new compilation mode. It allows to partially compile a library before shipping it to NPM. What does that mean?...
Read more >
Angular Ivy
CLI commands run ngcc as needed when performing an Angular build. ... See the Creating Libraries guide for more on how to compile...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found