Skip to content

Commit 1ae084a

Browse files
author
Alexander Zhukov
committed
feat(dependencies): update ng-router-loader to 2.1.0
1 parent 33f0fbb commit 1ae084a

File tree

5 files changed

+160
-74
lines changed

5 files changed

+160
-74
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ sudo: false
33
language: node_js
44

55
node_js:
6-
- "5"
76
- "6"
87

98
addons:
@@ -15,6 +14,7 @@ addons:
1514

1615
install:
1716
- npm config set spin false
17+
- npm install -g npm@latest
1818

1919
- npm install
2020

config/webpack.common.js

+27-7
Original file line numberDiff line numberDiff line change
@@ -90,26 +90,46 @@ module.exports = function (options) {
9090
module: {
9191

9292
rules: [
93+
9394
/*
94-
* Typescript loader support for .ts and Angular 2 async routes via .async.ts
95-
* Replace templateUrl and stylesUrl with require()
95+
* Typescript loader support for .ts
96+
*
97+
* Component Template/Style integration using `angular2-template-loader`
98+
* Angular 2 lazy loading (async routes) via `ng-router-loader`
99+
*
100+
* `ng-router-loader` expects vanilla JavaScript code, not TypeScript code. This is why the
101+
* order of the loader matter.
96102
*
97103
* See: https://github.com/s-panferov/awesome-typescript-loader
98104
* See: https://github.com/TheLarkInn/angular2-template-loader
105+
* See: https://github.com/shlomiassaf/ng-router-loader
99106
*/
100107
{
101108
test: /\.ts$/,
102109
use: [
103-
'@angularclass/hmr-loader?pretty=' + !isProd + '&prod=' + isProd,
104-
'awesome-typescript-loader?{configFileName: "tsconfig.webpack.json"}',
105-
'angular2-template-loader',
106110
{
111+
loader: '@angularclass/hmr-loader',
112+
options: {
113+
pretty: !isProd,
114+
prod: isProd
115+
}
116+
},
117+
{ // MAKE SURE TO CHAIN VANILLA JS CODE, I.E. TS COMPILATION OUTPUT.
107118
loader: 'ng-router-loader',
108119
options: {
109-
loader: 'async-system',
120+
loader: 'async-import',
110121
genDir: 'compiled',
111122
aot: AOT
112123
}
124+
},
125+
{
126+
loader: 'awesome-typescript-loader',
127+
options: {
128+
configFileName: 'tsconfig.webpack.json'
129+
}
130+
},
131+
{
132+
loader: 'angular2-template-loader'
113133
}
114134
],
115135
exclude: [/\.(spec|e2e)\.ts$/]
@@ -220,7 +240,7 @@ module.exports = function (options) {
220240
new CommonsChunkPlugin({
221241
name: 'vendor',
222242
chunks: ['main'],
223-
minChunks: module => /node_modules\//.test(module.resource)
243+
minChunks: module => /node_modules/.test(module.resource)
224244
}),
225245
// Specify the correct order the scripts will be injected in
226246
new CommonsChunkPlugin({

config/webpack.prod.js

+8-7
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin');
1313
const NormalModuleReplacementPlugin = require('webpack/lib/NormalModuleReplacementPlugin');
1414
const ProvidePlugin = require('webpack/lib/ProvidePlugin');
1515
const UglifyJsPlugin = require('webpack/lib/optimize/UglifyJsPlugin');
16-
const WebpackMd5Hash = require('webpack-md5-hash');
17-
const V8LazyParseWebpackPlugin = require('v8-lazy-parse-webpack-plugin');
18-
16+
const OptimizeJsPlugin = require('optimize-js-plugin');
1917
/**
2018
* Webpack Constants
2119
*/
@@ -88,12 +86,15 @@ module.exports = function (env) {
8886
plugins: [
8987

9088
/**
91-
* Plugin: WebpackMd5Hash
92-
* Description: Plugin to replace a standard webpack chunkhash with md5.
89+
* Webpack plugin to optimize a JavaScript file for faster initial load
90+
* by wrapping eagerly-invoked functions.
9391
*
94-
* See: https://www.npmjs.com/package/webpack-md5-hash
92+
* See: https://github.com/vigneshshanmugam/optimize-js-plugin
9593
*/
96-
new WebpackMd5Hash(),
94+
95+
new OptimizeJsPlugin({
96+
sourceMap: false
97+
}),
9798

9899
/**
99100
* Plugin: DedupePlugin

0 commit comments

Comments
 (0)