Skip to content

Error when starting @ngtools/webpack plugin via "grunt-webpack" #168

@anbaran

Description

@anbaran

When I start the webpack plugin @ngtools/webpack via grunt-webpack it results in error. When I start this same plugin directly via webpack it works without errors. I created minimal sample app to demonstrate this behavior.

How to reproduce

  1. checkout the repository: git clone https://github.com/anbaran/ngtools-webpack-error.git
  2. cd ngtools-webpack-error
  3. install grunt cli: npm install -g grunt-cli
  4. run: npm install

Now we have 2 options, run the webpack task directly in webpack or via grunt-webpack integration

Case 1 - Using webpack directly - compilation completes without error

 run: `npx webpack --config webpack.config.js`

Result: no error, compilation successful

Case 2 - Using grunt integration for webpack , the "grunt-webpack" - compilation results in error (see below)

 run: `grunt`

Result:

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)

Expected Behavior

Running a task via grunt-webpack or directly webpack should produce the same result

Context

One of the subtasks of my grunt build process is to compile Angular application using webpack plugin "@ngtools/webpack"

Your Environment

grunt: 1.0.3,
grunt-webpack: 3.1.3,
webpack: 3.12.0
node v10.10.0
npm 6.4.1
Linux Ubuntu VERSION="16.04.4 LTS (Xenial Xerus)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions