Angular-cli: @ngtools/webpack-Loader without AotPlugin

Created on 12 Mar 2017  路  8Comments  路  Source: angular/angular-cli

It seems, that the @ngtools/webpack-Loader does not work without using the AotPlugin.
Is this right or perhaps by Design?
If yes, why?

OS?

Windows 10

Versions.

CLI rc.1, node 6.1

Repro steps.

  1. Create a project with the CLI
  2. Eject the CLI
  3. Remove the AOT-Plugin from the webpack.config.js
  4. run npm run build
  5. Face an error: Module build failed: TypeError: Cannot read property 'newLine' of undefined

Most helpful comment

It seems that it works now in @1.2.1 without AOT plugin:

            {
                "test": /\.ts$/,
                "loader": "@ngtools/webpack",
                "options": {
                    "tsConfigPath": "src\\tsconfig.app.json",
                }
            }

webpack compiles correctly.

All 8 comments

You should look at it more this way; the Plugin requires your configuration to include the loader, and not the other way around :) If we could have done it without a loader we would have.

AotPlugin is a misnomer at this point; it really is a "code-splitter-maybe-code-gen" plugin. It does code splitting based on your lazy routes, it sanitize your code and replace resources for require calls (which is necessary in JIT). If you pass in skipCodeGeneration: true, it will not do AOT compilation. So if you're looking to skip code generation, you should pass that option in (if you just ran ng eject that was already the case).

If you only want a typescript compiler, there are great options out there; awesome-typescript-loader or ts-loader are two that we used to use in the CLI. For Angular though this might not be enough; you'll have to manually manage resources or use another Angular loader for transforming your resource URLs.

angular2-template-loader worked for me. I had the same issue and I'm not sure why it requires AOT to be included to run properly.

Edit: I split off my question into its own thread.

Is AOTPlugin the culprit for slowness in rebuilds after ejecting? I suspected that and tried to disable it but it's not that simple as noted above.

to the webpack.common.js file.

var myloaders = environment === 'development' ? [
    'awesome-typescript-loader',
    'angular2-template-loader',
    'angular2-router-loader',

] : [
        '@ngtools/webpack',
    ]; // AoT

to the rules array

     rules: [{
            test: /\.ts$/,
            use: myloaders 
        },

It seems that it works now in @1.2.1 without AOT plugin:

            {
                "test": /\.ts$/,
                "loader": "@ngtools/webpack",
                "options": {
                    "tsConfigPath": "src\\tsconfig.app.json",
                }
            }

webpack compiles correctly.

It's not a solution, it's forcing me to eject just put the tsConfigPath there

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