I'm trying to use AOT compilation to produce production build. Everything seems to be working nicely, except I still have compiler in vendor bundle. AFAIK one of goals of AOT compilation is to remove it from resulting bundle and to reduce app size.
How can I produce proper AOT build without compiler in resulting bundle?
My 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)
}
})
]
});
tsconfig:
{
"compilerOptions": {
"target": "es5",
"module": "es2015",
"baseUrl": "",
"moduleResolution": "node",
"sourceMap": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": true,
"noImplicitAny": false,
"inlineSources": false,
"rootDir": "./",
"outDir": "../../../target/tscoutput"
},
"compileOnSave": false,
"buildOnSave": false,
"awesomeTypescriptLoaderOptions": {
"forkChecker": true,
"useWebpackText": true
}
}
I have these version of tools:
angular: 4.1.2
@ngtools/webpack: 1.3.1
webpack: 2.2.0