Skip to content

Angular 6 AOT compilation not working - Error in AngularCompilerPlugin #12248

Closed

Description

@anbaran

Bug Report or Feature Request (mark with an x)

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

Command (mark with an x)

- [ ] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Versions

Linux Ubuntu VERSION="16.04.4 LTS (Xenial Xerus)
node v10.10.0
npm 6.4.1
ng (none, this project is not managed by Angular CLI)
Angular 6
ngtools/webpack 1.10.2

"dependencies": {
"@angular/common": "^6.0.0",
"@angular/compiler": "^6.0.0",
"@angular/core": "^6.0.0",
"@angular/forms": "^6.0.0",
"@angular/http": "^6.0.0",
"@angular/platform-browser": "^6.0.0",
"@angular/router": "^6.0.0",
"@angular/upgrade": "^6.0.0",
"angular-in-memory-web-api": "^0.6.0",
"core-js": "^2.5.4",
"rxjs": "^6.0.0",
"zone.js": "^0.8.24"
},
"devDependencies": {
"@angular/compiler-cli": "^6.0.0",
"@ngtools/webpack": "1.10.2",
"@types/node": "^6.0.45",
"lodash": "^4.16.2",
"typescript": "2.7.2",
"grunt": "~0.4.5",
"grunt-cli": "1.2.0",
"grunt-webpack": "3.1.3",
"webpack": "3.12.0",
"raw-loader": "0.5.1"
},

Repro steps

I created minimal sample app to reproduce this error. The key point is that this app is AOT compiled using the webpack plugin @ngtools/webpack.

How to reproduce

  1. git clone https://github.com/anbaran/ngtools-webpack-error.git
  2. cd ngtools-webpack-error/
  3. install grunt cli with: npm install -g grunt-cli (if you don't already have it)
  4. Run: npm install
  5. Run: grunt (this step will start AOT compilation of that project)

The log given by the failure

ERROR in : TypeError: Cannot read property 'getTsProgram' of undefined
    at AngularCompilerPlugin._getTsProgram (<project-location>/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:189:62)
    at getTypeChecker (<project-location>/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:533:43)
    at ast_helpers_1.collectDeepNodes.filter (<project-location>/node_modules/@ngtools/webpack/src/transformers/remove_decorators.js:14:60)
    at Array.filter (<anonymous>)
    at standardTransform (<project-location>/node_modules/@ngtools/webpack/src/transformers/remove_decorators.js:14:14)
    at transformer (<project-location>/node_modules/@ngtools/webpack/src/transformers/make_transform.js:14:25)
    at <project-location>/node_modules/typescript/lib/typescript.js:2892:86
    at reduceLeft (<project-location>/node_modules/typescript/lib/typescript.js:2585:30)
    at <project-location>/node_modules/typescript/lib/typescript.js:2892:42
    at transformRoot (<project-location>/node_modules/typescript/lib/typescript.js:67846:82)

Desired functionality

It should be possible to compile Angular 6 projects with Ahead-of-Time compiler using @ngtools/webpack plugin (without using the Angular CLI)

Mention any other details that might be useful

Using @ngtools/webpack for AOT compiling works in my setup until version 1.8 which is ok for Angular 5. However, Angular 6 requires to have at least @ngtools/webpack 1.10.0 which causes the above error.

Activity

  1. added
    freq1: low
    on Sep 13, 2018
  2. added this to the needsTriage milestone on Sep 13, 2018
  3. anbaran commented on Sep 14, 2018

    @anbaran
    Author

    I made further investigation and it turns out that even though the error occurs in AngularCompilerPlugin, it occurs only when running @ngtools/webpack via grunt-webpack integration (I use grunt for building the application). If compiling is done directly via webpack it works without problems. I modified the sample minimal app to have both options possible i.e. compile via grunt-webpack integration and compile directly via webpack (see the app repository for instructions https://github.com/anbaran/ngtools-webpack-error)

    I also submitted a bug error to grunt-webpack project (danez/grunt-webpack#168)

  4. p3x-robot commented on Sep 14, 2018

    @p3x-robot

    I have been trying to fix this for about over 6 months, finally someone found the bug, reference:
    #12179

    I guess it will work from now on.

  5. alan-agius4 commented on Oct 4, 2018

    @alan-agius4
    Collaborator

    Closing in favor of the upstream tracked issue.

  6. angular-automatic-lock-bot commented on Sep 8, 2019

    @angular-automatic-lock-bot

    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.

  7. locked and limited conversation to collaborators on Sep 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: @ngtools/webpackfreq1: lowseverity3: broken

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions