diff --git a/package.json b/package.json index f0b96e758815..aaa4f6519ed6 100644 --- a/package.json +++ b/package.json @@ -122,7 +122,6 @@ "walk-sync": "^0.2.6", "webpack": "2.1.0-beta.25", "webpack-dev-server": "2.1.0-beta.9", - "webpack-md5-hash": "0.0.5", "webpack-merge": "^0.14.0", "webpack-sources": "^0.1.3", "yam": "0.0.18" diff --git a/packages/@ngtools/webpack/src/plugin.ts b/packages/@ngtools/webpack/src/plugin.ts index b3d198e71436..2844570ef936 100644 --- a/packages/@ngtools/webpack/src/plugin.ts +++ b/packages/@ngtools/webpack/src/plugin.ts @@ -309,6 +309,7 @@ export class AotPlugin implements Tapable { Object.keys(allLazyRoutes) .forEach(k => { const lazyRoute = allLazyRoutes[k]; + k = k.split('#')[0]; if (this.skipCodeGeneration) { this._lazyRoutes[k] = lazyRoute; } else { diff --git a/packages/angular-cli/blueprints/ng2/files/package.json b/packages/angular-cli/blueprints/ng2/files/package.json index 1bbbb1f52530..a39e327733d7 100644 --- a/packages/angular-cli/blueprints/ng2/files/package.json +++ b/packages/angular-cli/blueprints/ng2/files/package.json @@ -20,7 +20,7 @@ "@angular/http": "~2.3.1", "@angular/platform-browser": "~2.3.1", "@angular/platform-browser-dynamic": "~2.3.1", - "@angular/router": "3.2.3", + "@angular/router": "~3.3.1", "core-js": "^2.4.1", "rxjs": "5.0.0-rc.4", "ts-helpers": "^1.1.1", diff --git a/packages/angular-cli/models/webpack-build-production.ts b/packages/angular-cli/models/webpack-build-production.ts index 12bc762e4130..1ec187c372b8 100644 --- a/packages/angular-cli/models/webpack-build-production.ts +++ b/packages/angular-cli/models/webpack-build-production.ts @@ -1,6 +1,5 @@ import * as path from 'path'; import * as webpack from 'webpack'; -const WebpackMd5Hash = require('webpack-md5-hash'); const ExtractTextPlugin = require('extract-text-webpack-plugin'); import {CompressionPlugin} from '../lib/webpack/compression-plugin'; const autoprefixer = require('autoprefixer'); @@ -30,7 +29,6 @@ export const getWebpackProdConfigPartial = function(projectRoot: string, }, plugins: [ new ExtractTextPlugin('[name].[chunkhash].bundle.css'), - new WebpackMd5Hash(), new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify('production') }), diff --git a/packages/angular-cli/package.json b/packages/angular-cli/package.json index a52650ec0724..b2cd2a1e9e45 100644 --- a/packages/angular-cli/package.json +++ b/packages/angular-cli/package.json @@ -101,7 +101,6 @@ "walk-sync": "^0.2.6", "webpack": "2.1.0-beta.25", "webpack-dev-server": "2.1.0-beta.9", - "webpack-md5-hash": "0.0.5", "webpack-merge": "^0.14.0", "webpack-sources": "^0.1.3", "yam": "0.0.18" diff --git a/tests/e2e/assets/webpack/test-app-weird/package.json b/tests/e2e/assets/webpack/test-app-weird/package.json index 8e70c25f017b..94e310fd05b0 100644 --- a/tests/e2e/assets/webpack/test-app-weird/package.json +++ b/tests/e2e/assets/webpack/test-app-weird/package.json @@ -10,7 +10,7 @@ "@angular/platform-browser": "~2.3.1", "@angular/platform-browser-dynamic": "~2.3.1", "@angular/platform-server": "~2.3.1", - "@angular/router": "~3.2.3", + "@angular/router": "~3.3.1", "@ngtools/webpack": "0.0.0", "core-js": "^2.4.1", "rxjs": "5.0.0-rc.4", diff --git a/tests/e2e/assets/webpack/test-app/package.json b/tests/e2e/assets/webpack/test-app/package.json index 97e03f5e8f6a..b0bda39cf79a 100644 --- a/tests/e2e/assets/webpack/test-app/package.json +++ b/tests/e2e/assets/webpack/test-app/package.json @@ -10,7 +10,7 @@ "@angular/platform-browser": "~2.3.1", "@angular/platform-browser-dynamic": "~2.3.1", "@angular/platform-server": "~2.3.1", - "@angular/router": "~3.2.3", + "@angular/router": "~3.3.1", "@ngtools/webpack": "0.0.0", "core-js": "^2.4.1", "rxjs": "5.0.0-rc.4", diff --git a/tests/e2e/tests/build/chunk-hash.ts b/tests/e2e/tests/build/chunk-hash.ts new file mode 100644 index 000000000000..5004a1b3f0b6 --- /dev/null +++ b/tests/e2e/tests/build/chunk-hash.ts @@ -0,0 +1,56 @@ +import {oneLine} from 'common-tags'; +import * as fs from 'fs'; + +import {ng} from '../../utils/process'; +import {writeFile} from '../../utils/fs'; +import {addImportToModule} from '../../utils/ast'; + + +export default function() { + const oldHashes: {[module: string]: string} = {}; + const newHashes: {[module: string]: string} = {}; + // First, collect the hashes. + return Promise.resolve() + .then(() => ng('generate', 'module', 'lazy', '--routing')) + .then(() => addImportToModule('src/app/app.module.ts', oneLine` + RouterModule.forRoot([{ path: "lazy", loadChildren: "./lazy/lazy.module#LazyModule" }]) + `, '@angular/router')) + .then(() => ng('build', '--prod')) + .then(() => { + fs.readdirSync('./dist') + .forEach(name => { + if (!name.match(/(main|inline|style|\d+)\.[a-z0-9]+\.bundle\.(js|css)/)) { + return; + } + + const [module, hash] = name.split('.'); + oldHashes[module] = hash; + }); + }) + .then(() => writeFile('src/app/app.component.css', 'h1 { margin: 5px; }')) + .then(() => writeFile('src/styles.css', 'body { background: red; }')) + .then(() => ng('build', '--prod')) + .then(() => { + fs.readdirSync('./dist') + .forEach(name => { + if (!name.match(/(main|inline|style|\d+)\.[a-z0-9]+\.bundle\.(js|css)/)) { + return; + } + + const [module, hash] = name.split('.'); + newHashes[module] = hash; + }); + }) + .then(() => { + console.log(' Validating hashes...'); + console.log(` Old hashes: ${JSON.stringify(oldHashes)}`); + console.log(` New hashes: ${JSON.stringify(newHashes)}`); + + Object.keys(oldHashes) + .forEach(module => { + if (oldHashes[module] == newHashes[module]) { + throw new Error(`Module "${module}" did not change hash (${oldHashes[module]})...`); + } + }); + }); +}