angular: Angular 9.0.3 ngcc fails to process ng2-dragula

🐞 bug report

Affected Package

@angular/compiler-cli

Is this a regression?

Yes it works properly with angular 9.0.2

Description

ngcc build failed with ng2-dragula.

🔬 Minimal Reproduction

  1. Clone https://github.com/log2-hwan/ngcc-ng2-dragula-bug-demo
  2. npm install
  3. npm run build ngcc-ng2-dragula-bug-demo
  4. Build failed with error

🔥 Exception or Error


0% compiling
Compiling @angular/core : es2015 as esm2015

Compiling @angular/common : es2015 as esm2015

Compiling @angular/platform-browser : es2015 as esm2015

Compiling @angular/platform-browser-dynamic : es2015 as esm2015

Compiling ng2-dragula : es2015 as esm2015

ERROR in Cannot read property 'push' of undefined

🌍 Your Environment

Angular Version:




     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 9.0.3
Node: 13.8.0
OS: darwin x64

Angular: 9.0.3
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Ivy Workspace: Yes

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.900.3
@angular-devkit/build-angular     0.900.3
@angular-devkit/build-optimizer   0.900.3
@angular-devkit/build-webpack     0.900.3
@angular-devkit/core              9.0.3
@angular-devkit/schematics        9.0.3
@ngtools/webpack                  9.0.3
@schematics/angular               9.0.3
@schematics/update                0.900.3
rxjs                              6.5.4
typescript                        3.7.5
webpack                           4.41.2

Anything else relevant? I guess the error is caused by commit df816c9 which is related to sourcemap processing, so ng2-dragula’s sourcemap may have some problems.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 5
  • Comments: 40 (17 by maintainers)

Commits related to this issue

Most upvoted comments

I had same error and tried many different solution. Finally I’ve solved it with adding following lines to tsconfig.app.json.

"angularCompilerOptions": {
    "enableIvy": false
  }

Basically, it will be solved when you disable the “Ivy” on angularCompilerOptions.

Angular 9.0.4 has been released which should fix these problems.

The proper solution was given above. Liking your own advice doesn’t increase its weight. Disabling Ivy is not the way to go. Just downgrade the Angular Version to yesterday’s.

Added a new commit to my PR that should also fix the Cannot read property 'push' of undefined error.

I believe that the third error that was reported RangeError: Maximum call stack size exceeded was transient and fixed by cleaning the node_modules folder and re-installing.

@petebacondarwin Just so you know, your commits does fix my issue.

I have an error ERROR in Cannot read property 'flattenedMappings' of null, seems to me this is related

@tomgruszowski - we hear you.

The PR is just about green and should be merged in the next hour. The plan is to then roll out a new patch release. So you should be unblocked before the end of the day.

Sorry that this release caused some issues and frustration.

Also fails on ngx-toastr apparently: image

Worked with previous version

I am also getting this error since upgrading to Angular 9.0.3 Cannot read property 'flattenedMappings' of null. It seems to be when ngcc runs on third party libraries. In my case I am not using either of the two libraries mentioned in the preceding comments (failing point for me is during compilation of angular-safeguard to esm5)

@naveedahmed1 There has not been a hot-patch for the 9.1.0-next release line, it was only 9.0.4 that was released the same week as 9.0.3. There will be a 9.1.0-next release around Wednesday/Thursday this week that should address the crash.

The normal cycle is to release a new patch version every week. Given that 9.0.3 came out yesterday, I expect 9.0.4 to be released next Wednesday 4th March.

This seems like a pretty bad regression to wait this long, unless ‘revert to old version’ is acceptable.

*edit - thanks for the quick turnaround ng team 😃

At a minimum you need to change @angular/compiler-cli from “~9.0.3” to “9.0.2”. But to be on the safe side you could change all the ~9.0.3 to 9.0.2 and also the ~0.900.3 to 0.900.2.

I had trouble with ngcc when compiling @angular/animations.

Compiling @angular/animations : es2015 as esm2015
Error: Error on worker #2: RangeError: Maximum call stack size exceeded
    at JSON.parse (<anonymous>)
    at SourceFileLoader.loadRawSourceMap (C:\Users\Vincent\web-acc\node_modules\@angular\compiler-cli\ngcc\src\sourcemaps\source_file_loader.js:113:25)
    at SourceFileLoader.loadSourceMap (C:\Users\Vincent\web-acc\node_modules\@angular\compiler-cli\ngcc\src\sourcemaps\source_file_loader.js:91:36)
    at SourceFileLoader.loadSourceFile (C:\Users\Vincent\web-acc\node_modules\@angular\compiler-cli\ngcc\src\sourcemaps\source_file_loader.js:53:35)
    at C:\Users\Vincent\web-acc\node_modules\@angular\compiler-cli\ngcc\src\sourcemaps\source_file_loader.js:105:30
    at Array.map (<anonymous>)
    at SourceFileLoader.processSources (C:\Users\Vincent\web-acc\node_modules\@angular\compiler-cli\ngcc\src\sourcemaps\source_file_loader.js:102:32)
    at SourceFileLoader.loadSourceFile (C:\Users\Vincent\web-acc\node_modules\@angular\compiler-cli\ngcc\src\sourcemaps\source_file_loader.js:60:32)
    at C:\Users\Vincent\web-acc\node_modules\@angular\compiler-cli\ngcc\src\sourcemaps\source_file_loader.js:105:30
    at Array.map (<anonymous>)
    at ClusterMaster.onWorkerMessage (C:\Users\Vincent\web-acc\node_modules\@angular\compiler-cli\ngcc\src\execution\cluster\master.js:158:27)
    at C:\Users\Vincent\web-acc\node_modules\@angular\compiler-cli\ngcc\src\execution\cluster\master.js:46:95
    at ClusterMaster.<anonymous> (C:\Users\Vincent\web-acc\node_modules\@angular\compiler-cli\ngcc\src\execution\cluster\master.js:238:57)
    at step (C:\Users\Vincent\web-acc\node_modules\tslib\tslib.js:139:27)
    at Object.next (C:\Users\Vincent\web-acc\node_modules\tslib\tslib.js:120:57)
    at C:\Users\Vincent\web-acc\node_modules\tslib\tslib.js:113:75
    at new Promise (<anonymous>)
    at Object.__awaiter (C:\Users\Vincent\web-acc\node_modules\tslib\tslib.js:109:16)
    at EventEmitter.<anonymous> (C:\Users\Vincent\web-acc\node_modules\@angular\compiler-cli\ngcc\src\execution\cluster\master.js:232:32)
    at EventEmitter.emit (events.js:200:13)
Compiling @angular/compiler/testing : es2015 as esm2015
Compiling @angular/core : es2015 as esm2015
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! web-acc@2.1.9 postinstall: `ngcc --properties es2015 browser module main --first-only --create-ivy-entry-points`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the web-acc@2.1.9 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Vincent\AppData\Roaming\npm-cache\_logs\2020-02-27T08_44_05_048Z-debug.log

I don’t know if you guys will have success with this, but the issue went away when deleting node_modules and package-lock.json and reinstalling everything from scratch.

Angular 9.0.4 has been released which should fix these problems.

Nope it didn’t… worse happened for me after updating to 9.0.4 from 9.0.2…

had to rollback my package* files and had to delete node_modules and run npm install to reinstall Just rolling back package* files and running npm install didn’t work that is why I had to delete node_modules

The normal cycle is to release a new patch version every week. Given that 9.0.3 came out yesterday, I expect 9.0.4 to be released next Wednesday 4th March.

There seemed to be a problem again so I did it all over again and it looks better. Thanks @petebacondarwin and @Ploppy3

@GitHubish - did you change the package.json dependencies to 9.0.2 before removing node_modules and running npm i?

Here it works after deleting node_modules and running npm i again.

I’m using angular 9.0.3

@GitHubish Remove the node_modules folder & your package manager’s lock file and finally run the install command again