We recently noticed an issue where ng build --prod generates bad output (code will not run) the first time. However, running a second time immediately afterward the build output is slightly larger and runs fine. Here's some of the build output:
~]> pnpm install
Lockfile is up-to-date, resolution step is skipped
Packages: +1700
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Packages are hard linked from the content-addressable store to the virtual store.
Content-addressable store is at: C:\Users\chezb\.pnpm-store\v3
Virtual store is at: node_modules\.pnpm
Progress: resolved 1700, reused 1693, downloaded 7, added 1700, done
node_modules/.pnpm/browser-tabs-lock@1.2.11/node_modules/browser-tabs-lock: Running postinstall script, done in 70ms
node_modules/.pnpm/core-js@3.6.4/node_modules/core-js: Running postinstall script, done in 79ms
node_modules/.pnpm/core-js@2.6.11/node_modules/core-js: Running postinstall script, done in 80ms
node_modules/.pnpm/@angular/cli@10.1.3/node_modules/@angular/cli: Running postinstall script, done in 736ms
node_modules/.pnpm/core-js@3.6.5/node_modules/core-js: Running postinstall script, done in 58ms
node_modules/.pnpm/cypress@5.2.0/node_modules/cypress: Running postinstall script, done in 755ms
node_modules/.pnpm/husky@4.3.0/node_modules/husky: Running install script, done in 206ms
node_modules/.pnpm/husky@4.3.0/node_modules/husky: Running postinstall script, done in 68ms
dependencies:
+ @angular/animations 10.1.3
+ @angular/cdk 10.2.2
+ @angular/common 10.1.3
+ @angular/compiler 10.1.3
+ @angular/core 10.1.3
+ @angular/forms 10.1.3
+ @angular/localize 10.1.3
+ @angular/material 10.2.2
+ @angular/platform-browser 10.1.3
+ @angular/platform-browser-dynamic 10.1.3
+ @angular/router 10.1.3
+ @angular/service-worker 10.1.3
+ @auth0/auth0-spa-js 1.12.0
+ @babel/preset-env 7.11.5
+ @microsoft/applicationinsights-analytics-js 2.5.8
+ @microsoft/applicationinsights-channel-js 2.5.8
+ @microsoft/applicationinsights-common 2.5.8
+ @microsoft/applicationinsights-core-js 2.5.8
+ @microsoft/applicationinsights-dependencies-js 2.5.8
+ @microsoft/applicationinsights-properties-js 2.5.8
+ @microsoft/applicationinsights-shims 1.0.2
+ @microsoft/applicationinsights-web 2.5.8
+ @microsoft/dynamicproto-js 0.5.3
+ @ngrx/effects 10.0.0
+ @ngrx/store 10.0.0
+ @ngrx/store-devtools 10.0.0
+ @nrwl/workspace 10.0.13
+ @swimlane/ngx-datatable 17.1.0
+ @types/auth0 2.20.8
+ @types/knockout 3.4.69
+ @types/moment-timezone 0.5.30
+ angular-in-memory-web-api 0.11.0
+ angular2-hotkeys 2.2.0
+ bootstrap 4.5.2
+ chart.js 2.9.3
+ classlist.js 1.1.20150312
+ concurrently 5.3.0
+ core-js 3.6.5
+ deep-diff 1.0.2
+ elmah.io.javascript 3.3.1
+ file-saver 2.0.2
+ flexmonster 2.8.15
+ handlebars 4.7.6
+ jquery 3.5.1
+ knockout 3.5.1
+ libphonenumber-js 1.7.58
+ lodash-es 4.17.15
+ moment 2.28.0
+ moment-timezone 0.5.31
+ mousetrap 1.6.5
+ ng-block-ui 2.1.8
+ ng-flexmonster 2.8.15
+ ng2-charts 2.4.1
+ ngx-autosize 1.8.0
+ ngx-bootstrap 5.6.2
+ ngx-mask 10.0.1
+ ngx-toastr 13.0.0
+ opencollective-postinstall 2.0.3
+ popper.js 1.16.1
+ querystring 0.2.0
+ reflect-metadata 0.1.13
+ rxjs 6.6.3
+ stacktrace-js 2.0.2
+ survey-angular 1.8.3
+ surveyjs-widgets 1.8.3
+ toastr 2.1.4
+ ts-md5 1.2.7
+ tslib 2.0.1
+ util 0.12.3
+ uuid 3.4.0
+ vanilla-text-mask 5.1.1
+ zone.js 0.10.3
devDependencies:
+ @angular-devkit/build-angular 0.1001.3
+ @angular-devkit/schematics 10.1.3
+ @angular/cli 10.1.3
+ @angular/compiler-cli 10.1.3
+ @angular/language-service 10.1.3
+ @nrwl/angular 10.0.13
+ @nrwl/cli 9.6.0
+ @nrwl/cypress 10.0.13
+ @nrwl/jest 10.0.13
+ @types/file-saver 2.0.1
+ @types/jest 25.2.3
+ @types/node 12.12.62
+ babel-jest 26.3.0
+ babel-plugin-transform-es2015-modules-commonjs 6.26.2
+ babel-polyfill 6.26.0
+ codelyzer 6.0.0
+ cypress 5.2.0
+ cypress-file-upload 4.1.1
+ cypress-wait-until 1.7.1
+ husky 4.3.0
+ jest 26.4.2
+ jest-preset-angular 8.3.1
+ mailslurp-client 8.7.8
+ npm-run-all 4.1.5
+ prettier 2.1.2
+ pretty-quick 2.0.2
+ ts-jest 26.3.0
+ ts-node 8.10.2
+ tslint 6.1.3
+ typescript 3.9.7
> webapp@0.0.0 postinstall
> ngcc --properties es2015
~]> ng build --prod
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 angular2-hotkeys : es2015 as esm2015
Compiling ng-block-ui : es2015 as esm2015
Compiling @angular/common/http : es2015 as esm2015
Compiling @angular/animations : es2015 as esm2015
Compiling @angular/animations/browser : es2015 as esm2015
Compiling @angular/platform-browser/animations : es2015 as esm2015
Compiling @ngrx/store : es2015 as esm2015
Compiling @ngrx/effects : es2015 as esm2015
Compiling ngx-bootstrap/utils : es2015 as esm2015
Compiling ngx-bootstrap/positioning : es2015 as esm2015
Compiling ngx-bootstrap/component-loader : es2015 as esm2015
Compiling ngx-bootstrap/modal : es2015 as esm2015
Compiling @ngrx/store-devtools : es2015 as esm2015
Compiling @angular/forms : es2015 as esm2015
Compiling ngx-mask : es2015 as esm2015
Compiling @angular/service-worker : es2015 as esm2015
Compiling ngx-bootstrap/dropdown : es2015 as esm2015
Compiling ngx-bootstrap/chronos : es2015 as esm2015
Compiling ngx-bootstrap/mini-ngrx : es2015 as esm2015
Compiling ngx-bootstrap/datepicker : es2015 as esm2015
Compiling @angular/router : es2015 as esm2015
Compiling ngx-toastr : es2015 as esm2015
Compiling @angular/cdk/platform : es2015 as esm2015
Compiling @angular/cdk/text-field : es2015 as esm2015
Compiling @angular/core/testing : es2015 as esm2015
Compiling @swimlane/ngx-datatable : es2015 as esm2015
Compiling ngx-bootstrap/tooltip : es2015 as esm2015
Compiling @angular/cdk/bidi : es2015 as esm2015
Compiling @angular/cdk/collections : es2015 as esm2015
Compiling @angular/cdk/scrolling : es2015 as esm2015
Compiling @angular/cdk/drag-drop : es2015 as esm2015
Compiling ng2-charts : es2015 as esm2015
Compiling ng-flexmonster : es2015 as esm2015
chunk {} runtime.569f1d0041eff5195de4.js (runtime) 2.35 kB [entry] [rendered]
chunk {1} 1.fa4fcd5d2c7d15faf70f.js () 17.6 kB [rendered]
chunk {2} 2.bda4a478890a0ad6fc5a.js () 29.3 kB [rendered]
chunk {3} main.3ad7e1d57be3d1e02a85.js (main) 1.45 MB [initial] [rendered]
chunk {4} polyfills.910addeb33ecd4e44bb1.js (polyfills) 36.7 kB [initial] [rendered]
chunk {5} styles.5ea0e2968dbbdc171655.css (styles) 404 kB [initial] [rendered]
chunk {6} 6.e46eab05db6e2d7bcc39.js () 2.59 MB [rendered]
chunk {7} 7.4fe3863b21c2130d85cb.js () 119 kB [rendered]
chunk {8} 8.b373430e68dff33d6ed2.js () 21 kB [rendered]
chunk {9} 9.9cee0294be954c4bbb7d.js () 8.57 kB [rendered]
chunk {scripts} scripts.b31bfd7c5283ba273864.js (scripts) 240 kB [entry] [rendered]
Date: 2020-09-25T21:29:48.640Z - Hash: 8420734c586a454a06de - Time: 96804ms
WARNING in budgets: initial exceeded maximum budget. Budget 2 MB was not met by 122 kB with a total of 2.12 MB.
~]> ng build --prod
chunk {} runtime.b22744c722394ab83a1d.js (runtime) 2.35 kB [entry] [rendered]
chunk {1} 1.44ca2caf5d1221a0bf27.js () 94.6 kB [rendered]
chunk {2} 2.c20d2dffb2420057613a.js () 29.3 kB [rendered]
chunk {3} main.3ed012144b5f14c0c457.js (main) 1.62 MB [initial] [rendered]
chunk {4} polyfills.910addeb33ecd4e44bb1.js (polyfills) 36.7 kB [initial] [rendered]
chunk {5} styles.5ea0e2968dbbdc171655.css (styles) 404 kB [initial] [rendered]
chunk {6} 6.f3432bf01fd2a37bd55c.js () 2.63 MB [rendered]
chunk {7} 7.84727ef35fe737b4cdab.js () 119 kB [rendered]
chunk {8} 8.504f8986a66c84232185.js () 21 kB [rendered]
chunk {9} 9.c685321f51c184b2b259.js () 8.57 kB [rendered]
chunk {scripts} scripts.b31bfd7c5283ba273864.js (scripts) 240 kB [entry] [rendered]
Date: 2020-09-25T21:31:19.851Z - Hash: 3968e68578df1b07b541 - Time: 75969ms
WARNING in budgets: initial exceeded maximum budget. Budget 2 MB was not met by 296 kB with a total of 2.29 MB.
Note that the Hashes vary, the file sizes vary. Every subsequent build (until we purge node_modules) results in the same output as the second run. We suspect this is related to the precompiler steps (ngcc) as they only appear for the first build. We've read in several places that we should be able to run this step manually in advance using something like npx ngcc --properties module but this never generates any output for us. Am I missing something? Maybe there's a bad interaction between pnpm and ngcc, or if maybe there's some buggy behavior in ngcc. Any help is GREATLY appreciated!
Version information:
pnpm: 5.7.0
Angular CLI: 10.1.3
Node: 12.18.3
OS: win32 x64
Angular: 10.1.3
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, localize, platform-browser
... platform-browser-dynamic, router, service-worker
Ivy Workspace: Yes
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1001.3
@angular-devkit/build-angular 0.1001.3
@angular-devkit/core 10.1.3
@angular-devkit/schematics 10.1.3
@angular/cdk 10.2.2
@angular/material 10.2.2
@schematics/angular 10.1.3
@schematics/update 0.1001.3
rxjs 6.6.3
typescript 3.9.7