question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@ngtools/webpack keeps @angular/compile module in AOT build

See original GitHub issue

Bug Report

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

Versions.

@ngtools/webpack: 1.3.1 
NodeJS: v6.10.3
npm: 5.0.0

Repro steps.

Webpack config

var webpack = require('webpack');
var webpackMerge = require('webpack-merge');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var commonConfig = require('./webpack.common.js');
var helpers = require('./helpers');
var ngtools = require('@ngtools/webpack');
var AotPlugin = ngtools.AotPlugin;

const ENV = process.env.NODE_ENV = process.env.ENV = 'production';

module.exports = webpackMerge(commonConfig, {
    devtool: 'source-map',

    output: {
        path: helpers.root('../../../target/rhamt-web'),
        filename: 'js/[name].js',
        chunkFilename: 'js/[id].chunk.js'
    },

    module: {
        loaders: [
            {
                test: /\.ts$/,
                exclude: /jquery*\.js/,
                loaders: '@ngtools/webpack'
            }
        ]
    },

    plugins: [
        new webpack.NoEmitOnErrorsPlugin(),
        new ExtractTextPlugin('css/[name].css'),
        new AotPlugin({
            tsConfigPath: './tsconfig-production.json',
            basePath: '.',
            mainPath: 'src/main.ts',
            skipCodeGeneration: true
        }),
        new webpack.optimize.UglifyJsPlugin({ // https://github.com/angular/angular/issues/10618
            mangle: {
                keep_fnames: true
            }
        }),
        new webpack.DefinePlugin({
            'process.env': {
                'ENV': JSON.stringify(ENV)
            }
        })
    ]
});

main.ts

import {platformBrowserDynamic} from "@angular/platform-browser-dynamic";
import {NgZone, enableProdMode} from "@angular/core";
import {AppModule} from "./app/app.module";

require('./keycloak.json.ftl');
require('../css/windup-web.css');

if (process.env.ENV === 'production') {
    enableProdMode();
}

platformBrowserDynamic().bootstrapModule(AppModule).then(app => {
    // this is just here to make some data easier to retrieve from tests
    window["app"] = app;
    window["MainNgZone"] = app.injector.get(NgZone);
    if (window["windupAppInitialized"] != null)
        window["windupAppInitialized"](app, window["MainNgZone"]);
})
.catch(err => {
    console.log(err);
    if (window["windupAppInitialized"] != null)
        window["windupAppInitialized"]();
});

Desired functionality.

@angular/compiler module should not be present in AOT builded app.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:13 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
filipesilvacommented, Jun 1, 2017

You have the skipCodeGeneration: true turned on, which disables AOT builds and instead gives you a JIT build that does require the compiler at runtime. Set skipCodeGeneration: false and that should give you an AOT build that doesn’t require the compiler.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ngtools\webpack AOT doesn't work OR freezes at 95% emitting
Can anyone help me at all? It appears to work, however, compiler.js is still included in the bundle. Also it is still looking...
Read more >
Ahead-of-time (AOT) compilation - Angular
The Angular ahead-of-time (AOT) compiler converts your Angular HTML and TypeScript ... When you run the ng build (build only) or ng serve...
Read more >
Angular AOT compilation with Webpack | Jiayi's Chronicles
The first step towards successful AOT compilation is adding AOTPlugin to your Webpack configuration file, usually named webpack.config.js . You ...
Read more >
JavaScript Demos Using Webpack 4 With Angular 6.1.7 And ...
This one loader will handle the transpilation, HTML and CSS inlining, and Ahead of Time (AoT) compilation. In order to get the "@ngtools/webpack...
Read more >
@ngtools/webpack | Yarn - Package Manager
Webpack plugin that AoT compiles your Angular components and modules. ... is a command-line interface tool that you use to initialize, develop, scaffold,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found