Angular-cli: ng build --build-optimizer --aot fails when upgrading to @angular-devkit/build-angular 0.6.8

Created on 10 Jun 2018  Â·  12Comments  Â·  Source: angular/angular-cli

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Area

- [x] devkit
- [ ] schematics

Versions

Running Mac OS X High Sierra 10.13.5.

$ node --version
v9.10.1

$ npm --version
6.1.0

$ ng version

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / â–³ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 6.0.8
Node: 9.10.1
OS: darwin x64
Angular: 6.0.4
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router, service-worker

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.6.8
@angular-devkit/build-angular     0.6.8
@angular-devkit/build-optimizer   0.6.8
@angular-devkit/core              0.6.8
@angular-devkit/schematics        0.6.8
@angular/cdk                      6.2.1
@angular/cli                      6.0.8
@angular/flex-layout              6.0.0-beta.16
@angular/material                 6.2.1
@angular/pwa                      0.7.0-beta.1
@ngtools/webpack                  6.0.8
@schematics/angular               0.6.8
@schematics/update                0.6.8
rxjs                              6.2.0
typescript                        2.7.2
webpack                           4.8.3

Repro steps

First, clone the project and checkout the branch I've created for the purposes of this bug report:

git clone https://github.com/alexjlockwood/ShapeShifter
cd ShapeShifter
git checkout angular-cli-build-error

Then build the project using the following commands:

npm install
ng build --build-optimizer --aot

The log given by the failure

$ ng build --build-optimizer --aot

Date: 2018-06-10T19:25:03.454Z
Hash: 353caaa8f1b364972ab1
Time: 64928ms
chunk {main} main.js, main.js.map (main) 1.8 MB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 305 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 5.22 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 163 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 8.16 MB [initial] [rendered]

ERROR in ./node_modules/svgo/plugins/_path.js
Module build failed: Error: Debug Failure. False expression.
    at getJSDocTags (/Users/alockwood/ShapeShifter/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:13173:22)
    at getFirstJSDocTag (/Users/alockwood/ShapeShifter/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:13181:24)
    at Object.getJSDocType (/Users/alockwood/ShapeShifter/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:13149:19)
    at getContextualSignature (/Users/alockwood/ShapeShifter/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:40930:32)
    at checkFunctionExpressionOrObjectLiteralMethod (/Users/alockwood/ShapeShifter/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:44548:43)
    at checkExpressionWorker (/Users/alockwood/ShapeShifter/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:45605:28)
    at checkExpression (/Users/alockwood/ShapeShifter/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:45533:42)
    at checkExpressionCached (/Users/alockwood/ShapeShifter/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:45384:38)
    at getWidenedTypeFromJSSpecialPropertyDeclarations (/Users/alockwood/ShapeShifter/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:30686:46)
    at getTypeOfVariableOrParameterOrProperty (/Users/alockwood/ShapeShifter/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:30961:28)
    at getTypeOfSymbol (/Users/alockwood/ShapeShifter/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:31171:24)
    at checkPropertyAccessExpressionOrQualifiedName (/Users/alockwood/ShapeShifter/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:42266:53)
    at checkPropertyAccessExpression (/Users/alockwood/ShapeShifter/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:42221:20)
    at checkExpressionWorker (/Users/alockwood/ShapeShifter/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:45587:28)
    at checkExpression (/Users/alockwood/ShapeShifter/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:45533:42)
    at checkBinaryLikeExpression (/Users/alockwood/ShapeShifter/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:45081:28)
ERROR in ./node_modules/svgo/lib/svgo/tools.js
Module build failed: Error: Debug Failure. False expression.
    at getJSDocTags (/Users/alockwood/ShapeShifter/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:13173:22)
    at getFirstJSDocTag (/Users/alockwood/ShapeShifter/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:13181:24)
    at Object.getJSDocType (/Users/alockwood/ShapeShifter/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:13149:19)
    at getContextualSignature (/Users/alockwood/ShapeShifter/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:40930:32)
    at checkFunctionExpressionOrObjectLiteralMethod (/Users/alockwood/ShapeShifter/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:44548:43)
    at checkExpressionWorker (/Users/alockwood/ShapeShifter/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:45605:28)
    at checkExpression (/Users/alockwood/ShapeShifter/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:45533:42)
    at checkExpressionCached (/Users/alockwood/ShapeShifter/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:45384:38)
    at getWidenedTypeFromJSSpecialPropertyDeclarations (/Users/alockwood/ShapeShifter/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:30686:46)
    at getTypeOfVariableOrParameterOrProperty (/Users/alockwood/ShapeShifter/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:30961:28)
    at getTypeOfSymbol (/Users/alockwood/ShapeShifter/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:31171:24)
    at checkPropertyAccessExpressionOrQualifiedName (/Users/alockwood/ShapeShifter/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:42266:53)
    at checkPropertyAccessExpression (/Users/alockwood/ShapeShifter/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:42221:20)
    at checkExpressionWorker (/Users/alockwood/ShapeShifter/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:45587:28)
    at checkExpression (/Users/alockwood/ShapeShifter/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:45533:42)
    at checkBinaryLikeExpression (/Users/alockwood/ShapeShifter/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:45081:28)

Mention any other details that might be useful

This error does not show up when setting @angular-devkit/build-angular": "0.6.7" in my package.json (I only see the error when upgrading to 0.6.8).

devkibuild-optimizer high broken bufix

Most helpful comment

For context, I believe this is the same as reported in https://github.com/angular/angular-cli/issues/11055 and https://github.com/angular/angular-cli/issues/11918.

This happens because Build Optimizer functions slightly differently with and without sourcemaps. Without sourcemaps we take shortcuts that make it much faster.

As far as I can tell, when the shortcuts are not taken we run into a TypeScript 2.9 bug: https://github.com/Microsoft/TypeScript/issues/26253, https://github.com/Microsoft/TypeScript/issues/2506. https://github.com/Microsoft/TypeScript/issues/24963 (these are all the same AFAIK).

I think this bug is sorted in TS 3.x, and we updated out build optimizer dependencies accordingly. So if you update to @angular-devkit/[email protected] it should go away. This should work even on Angular 6 projects.

Let me know if you still see this, and if so, please give me a repro that I can look into.

All 12 comments

We seem to suffer from this same issue. The CI server fails on every build with this same stack trace, but local builds are fine. I can reproduce the following scenarion (multiple times):

  • delete note_modules and do a clean npm install
  • ng build --build-optimizer --aot fails with the above error (even when run multiple times)
  • ng build --build-optimizer --aot --prod succeeds without any error
  • any subsequent runs of ng build --build-optimizer --aot also complete without any error
  • as soon as node_modules is cleared and reinstalled the non-prod builds start failing again.

Perhaps this can help tracking down the issue

UPDATE: after some more investigation this seems related to node_modules/@angular-devkit/build-optimizer/src/.cache. If this cache is created with the --prod built any subsequent build will succeed (with or without --prod). But when you clear this build-optimizer cache any subsequent build without --prod will fail.

Just arrived to the same error, confirming that with 0.6.7 it works. Also note that this error occurred after I implemented lazy modules into my app, so it will be probably connected.

i just noticed this after including yarn to mirror our npm packages offline and doing a prod build (ng build --prod) with version 0.6.8. Version 0.6.7 works fine.

I can confirm reverting to 0.6.7 works, for me the error also occurs in a lazy loaded module.

Also can confirm this issue here. With 0.6.8 the error occurs with 0.6.7 not.
I also read about threads where you should use a particular typescript version of 2.8.4. But this doesn't solve my problem.
Im sticking now with 2.7.2 of typscript and 0.6.7 with build-angular and the compiling process finishes as expected. huch

Hello
version 0.7.0 has still the same issue. any updates on this ?

0.7.1 still has the issue as well.

0.7.5 has the same issue.

Any updates on this? I've been unable to update these dependencies for a few months now. Can anyone suggest a workaround?

I pinned the version "0.6.7" in my package.json

Yeah, that's what I've been doing. Would really like to update soon though.

For context, I believe this is the same as reported in https://github.com/angular/angular-cli/issues/11055 and https://github.com/angular/angular-cli/issues/11918.

This happens because Build Optimizer functions slightly differently with and without sourcemaps. Without sourcemaps we take shortcuts that make it much faster.

As far as I can tell, when the shortcuts are not taken we run into a TypeScript 2.9 bug: https://github.com/Microsoft/TypeScript/issues/26253, https://github.com/Microsoft/TypeScript/issues/2506. https://github.com/Microsoft/TypeScript/issues/24963 (these are all the same AFAIK).

I think this bug is sorted in TS 3.x, and we updated out build optimizer dependencies accordingly. So if you update to @angular-devkit/[email protected] it should go away. This should work even on Angular 6 projects.

Let me know if you still see this, and if so, please give me a repro that I can look into.

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JanStureNielsen picture JanStureNielsen  Â·  3Comments

5amfung picture 5amfung  Â·  3Comments

rwillmer picture rwillmer  Â·  3Comments

donaldallen picture donaldallen  Â·  3Comments

IngvarKofoed picture IngvarKofoed  Â·  3Comments