Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
anbaran opened this issue Sep 12, 2018 · 4 comments
Closed

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

anbaran opened this issue Sep 12, 2018 · 4 comments
Labels
area: ngtools/webpack freq1: low Only reported by a handful of users who observe it rarely severity3: broken
Milestone

Comments

@anbaran
Copy link

anbaran commented Sep 12, 2018

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.

@alan-agius4 alan-agius4 added freq1: low Only reported by a handful of users who observe it rarely severity3: broken area: ngtools/webpack labels Sep 13, 2018
@ngbot ngbot bot added this to the needsTriage milestone Sep 13, 2018
@anbaran
Copy link
Author

anbaran commented Sep 14, 2018

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 (webpack-contrib/grunt-webpack#168)

@p3x-robot
Copy link

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.

@alan-agius4
Copy link
Collaborator

Closing in favor of the upstream tracked issue.

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: ngtools/webpack freq1: low Only reported by a handful of users who observe it rarely severity3: broken
Projects
None yet
Development

No branches or pull requests

3 participants