Skip to content
This repository was archived by the owner on Apr 4, 2025. It is now read-only.

Commit 8e7658a

Browse files
filipesilvahansl
authored andcommitted
feat(@angular-devkit/build-webpack): sync changes from Angular CLI
Contains all changes from angular/angular-cli@ca8e834...master.
1 parent 29c2646 commit 8e7658a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+4743
-5349
lines changed

package-lock.json

+3,484-4,358
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+29-30
Original file line numberDiff line numberDiff line change
@@ -51,21 +51,20 @@
5151
"homepage": "https://github.com/angular/devkit",
5252
"dependencies": {
5353
"@angular-devkit/build-optimizer": "^0.4.2",
54-
"@angular/common": "^5.2.1",
55-
"@angular/compiler": "^5.2.1",
56-
"@angular/compiler-cli": "^5.2.1",
57-
"@angular/core": "^5.2.1",
54+
"@angular/common": "^5.2.7",
55+
"@angular/compiler": "^5.2.7",
56+
"@angular/compiler-cli": "^5.2.7",
57+
"@angular/core": "^5.2.7",
5858
"@angular/http": "^5.2.6",
5959
"@angular/material": "^5.2.3",
60-
"@angular/platform-browser": "^5.2.1",
61-
"@angular/platform-browser-dynamic": "^5.2.1",
60+
"@angular/platform-browser": "^5.2.7",
61+
"@angular/platform-browser-dynamic": "^5.2.7",
6262
"@angular/router": "^5.2.6",
63-
"@angular/service-worker": "^5.2.1",
63+
"@angular/service-worker": "^5.2.7",
6464
"@ngtools/json-schema": "^1.0.9",
65-
"@ngtools/webpack": "angular/ngtools-webpack-builds#5474750",
65+
"@ngtools/webpack": "6.0.0-beta.4",
6666
"@types/common-tags": "^1.4.0",
6767
"@types/copy-webpack-plugin": "^4.0.1",
68-
"@types/denodeify": "^1.2.31",
6968
"@types/express": "^4.11.1",
7069
"@types/glob": "^5.0.29",
7170
"@types/istanbul": "^0.4.29",
@@ -76,28 +75,26 @@
7675
"@types/request": "^2.47.0",
7776
"@types/semver": "^5.3.30",
7877
"@types/source-map": "0.5.2",
79-
"@types/webpack": "^3.0.2",
78+
"@types/webpack": "^3.8.2",
8079
"@types/webpack-sources": "^0.1.3",
8180
"ajv": "^5.5.1",
8281
"autoprefixer": "^7.2.3",
8382
"bootstrap": "^4.0.0",
83+
"cache-loader": "^1.2.2",
8484
"chalk": "~2.2.2",
8585
"chokidar": "^1.7.0",
86-
"circular-dependency-plugin": "^4.3.0",
86+
"circular-dependency-plugin": "^4.4.0",
8787
"clean-css": "^4.1.9",
8888
"codelyzer": "^4.0.2",
8989
"common-tags": "^1.5.1",
9090
"conventional-changelog": "^1.1.0",
91-
"copy-webpack-plugin": "^4.2.3",
92-
"css-loader": "^0.28.7",
93-
"denodeify": "^1.2.1",
94-
"exports-loader": "^0.6.4",
91+
"copy-webpack-plugin": "~4.4.2",
9592
"express": "^4.16.2",
96-
"extract-text-webpack-plugin": "^3.0.2",
97-
"file-loader": "^1.1.5",
93+
"extract-text-webpack-plugin": "~4.0.0-beta.0",
94+
"file-loader": "^1.1.9",
9895
"font-awesome": "^4.7.0",
9996
"glob": "^7.0.3",
100-
"html-webpack-plugin": "^2.30.1",
97+
"html-webpack-plugin": "github:webpack-contrib/html-webpack-plugin#a8a8c2b6ea496c257fd6f501db3a06a51fa03e1e",
10198
"husky": "^0.14.3",
10299
"istanbul": "^0.4.5",
103100
"istanbul-instrumenter-loader": "^3.0.0",
@@ -112,17 +109,20 @@
112109
"karma-source-map-support": "^1.2.0",
113110
"less": "^2.7.3",
114111
"less-loader": "^4.0.5",
115-
"license-webpack-plugin": "^1.1.1",
112+
"license-webpack-plugin": "^1.1.2",
116113
"loader-utils": "^1.1.0",
117114
"lodash": "^4.17.4",
115+
"material-design-icons": "^3.0.1",
118116
"memory-fs": "^0.4.1",
119117
"minimatch": "^3.0.4",
120118
"minimist": "^1.2.0",
121119
"node-sass": "^4.7.2",
122120
"opn": "^5.1.0",
121+
"parse5": "^4.0.0",
123122
"portfinder": "^1.0.13",
124-
"postcss-import": "^11.0.0",
125-
"postcss-loader": "^2.0.10",
123+
"postcss": "^6.0.19",
124+
"postcss-import": "^11.1.0",
125+
"postcss-loader": "^2.1.1",
126126
"postcss-url": "^7.3.0",
127127
"protractor": "^5.1.2",
128128
"raw-loader": "^0.5.1",
@@ -133,25 +133,24 @@
133133
"semver-intersect": "^1.1.2",
134134
"silent-error": "^1.1.0",
135135
"source-map": "^0.5.6",
136-
"source-map-loader": "^0.2.3",
137136
"source-map-support": "^0.5.0",
138137
"stats-webpack-plugin": "^0.6.2",
139-
"style-loader": "^0.19.1",
138+
"style-loader": "^0.20.2",
140139
"stylus": "^0.54.5",
141-
"stylus-loader": "^3.0.1",
140+
"stylus-loader": "^3.0.2",
142141
"tar": "^3.1.5",
143142
"temp": "^0.8.3",
144143
"tree-kill": "^1.2.0",
145144
"ts-node": "^5.0.0",
146145
"tslint": "^5.9.1",
147146
"typescript": "~2.7.2",
148-
"uglifyjs-webpack-plugin": "^1.1.6",
147+
"uglifyjs-webpack-plugin": "^1.2.2",
149148
"url-loader": "^0.6.2",
150-
"webpack": "^3.10.0",
151-
"webpack-dev-middleware": "^1.12.2",
152-
"webpack-dev-server": "^2.11.0",
153-
"webpack-merge": "^4.1.1",
154-
"webpack-sources": "^1.0.1",
149+
"webpack": "~4.0.0",
150+
"webpack-dev-middleware": "^2.0.6",
151+
"webpack-dev-server": "^3.0.1-beta.0",
152+
"webpack-merge": "^4.1.2",
153+
"webpack-sources": "^1.1.0",
155154
"webpack-subresource-integrity": "^1.0.3",
156155
"zone.js": "^0.8.19"
157156
},

packages/angular_devkit/build_webpack/package.json

+20-21
Original file line numberDiff line numberDiff line change
@@ -12,52 +12,51 @@
1212
"@angular-devkit/build-optimizer": "0.0.0",
1313
"@angular-devkit/architect": "0.0.0",
1414
"@angular-devkit/core": "0.0.0",
15-
"@ngtools/webpack": "^1.10.0-rc.0",
15+
"@ngtools/webpack": "6.0.0-beta.4",
1616
"autoprefixer": "^7.2.3",
17+
"cache-loader": "^1.2.0",
1718
"chalk": "~2.2.2",
18-
"circular-dependency-plugin": "^4.3.0",
19+
"circular-dependency-plugin": "^4.4.0",
1920
"clean-css": "^4.1.9",
2021
"common-tags": "^1.5.1",
21-
"copy-webpack-plugin": "^4.2.3",
22-
"css-loader": "^0.28.7",
23-
"denodeify": "^1.2.1",
24-
"exports-loader": "^0.6.4",
25-
"extract-text-webpack-plugin": "^3.0.2",
22+
"copy-webpack-plugin": "^4.4.2",
23+
"extract-text-webpack-plugin": "~4.0.0-beta.0",
2624
"file-loader": "^1.1.5",
2725
"glob": "^7.0.3",
28-
"html-webpack-plugin": "^2.30.1",
26+
"html-webpack-plugin": "github:webpack-contrib/html-webpack-plugin#a8a8c2b6ea496c257fd6f501db3a06a51fa03e1e",
2927
"karma-source-map-support": "^1.2.0",
3028
"less": "^2.7.3",
3129
"less-loader": "^4.0.5",
32-
"license-webpack-plugin": "^1.1.1",
30+
"license-webpack-plugin": "^1.1.2",
3331
"lodash": "^4.17.4",
3432
"memory-fs": "^0.4.1",
3533
"minimatch": "^3.0.4",
3634
"node-sass": "^4.7.2",
35+
"parse5": "^4.0.0",
3736
"opn": "^5.1.0",
3837
"portfinder": "^1.0.13",
39-
"postcss-import": "^11.0.0",
40-
"postcss-loader": "^2.0.10",
41-
"postcss-url": "^7.3.0",
38+
"postcss": "^6.0.19",
39+
"postcss-import": "^11.1.0",
40+
"postcss-loader": "^2.1.1",
41+
"postcss-url": "^7.3.1",
4242
"raw-loader": "^0.5.1",
4343
"request": "^2.83.0",
4444
"rxjs": "^5.5.6",
4545
"sass-loader": "^6.0.6",
4646
"silent-error": "^1.1.0",
47-
"source-map-loader": "^0.2.3",
4847
"source-map-support": "^0.5.0",
4948
"stats-webpack-plugin": "^0.6.2",
50-
"style-loader": "^0.19.1",
49+
"style-loader": "^0.20.2",
5150
"stylus": "^0.54.5",
52-
"stylus-loader": "^3.0.1",
51+
"stylus-loader": "^3.0.2",
5352
"tree-kill": "^1.2.0",
54-
"uglifyjs-webpack-plugin": "^1.1.6",
53+
"uglifyjs-webpack-plugin": "^1.2.2",
5554
"url-loader": "^0.6.2",
56-
"webpack": "^3.10.0",
57-
"webpack-dev-middleware": "^1.12.2",
58-
"webpack-dev-server": "^2.11.0",
59-
"webpack-merge": "^4.1.1",
60-
"webpack-sources": "^1.0.1",
55+
"webpack": "~4.0.0",
56+
"webpack-dev-middleware": "^2.0.6",
57+
"webpack-dev-server": "^3.0.1-beta.0",
58+
"webpack-merge": "^4.1.2",
59+
"webpack-sources": "^1.1.0",
6160
"webpack-subresource-integrity": "^1.0.3"
6261
}
6362
}

packages/angular_devkit/build_webpack/src/angular-cli-files/lib/base-href-webpack/base-href-webpack-plugin.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export class BaseHrefWebpackPlugin {
2929
} else {
3030
// Replace only href attribute if exists
3131
const modifiedBaseTag = baseTagMatches[0].replace(
32-
/href="\S+"/i, `href="${this.options.baseHref}"`
32+
/href="\S*?"/i, `href="${this.options.baseHref}"`
3333
);
3434
htmlPluginData.html = htmlPluginData.html.replace(baseTagRegex, modifiedBaseTag);
3535
}

packages/angular_devkit/build_webpack/src/angular-cli-files/models/build-options.ts

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ export interface BuildOptions {
3333
buildOptimizer?: boolean;
3434
namedChunks?: boolean;
3535
subresourceIntegrity?: boolean;
36-
forceTsCommonjs?: boolean;
3736
serviceWorker?: boolean;
3837
skipAppShell?: boolean;
3938
statsJson: boolean;

packages/angular_devkit/build_webpack/src/angular-cli-files/models/webpack-configs/browser.ts

+66-48
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,19 @@ import * as webpack from 'webpack';
55
import * as path from 'path';
66
const HtmlWebpackPlugin = require('html-webpack-plugin');
77
const SubresourceIntegrityPlugin = require('webpack-subresource-integrity');
8-
9-
import { packageChunkSort } from '../../utilities/package-chunk-sort';
8+
import { LicenseWebpackPlugin } from 'license-webpack-plugin';
9+
import { generateEntryPoints, packageChunkSort } from '../../utilities/package-chunk-sort';
1010
import { BaseHrefWebpackPlugin } from '../../lib/base-href-webpack';
11+
import { IndexHtmlWebpackPlugin } from '../../plugins/index-html-webpack-plugin';
1112
import { extraEntryParser, lazyChunksFilter } from './utils';
1213
import { WebpackConfigOptions } from '../build-options';
1314

15+
/**
16+
+ * license-webpack-plugin has a peer dependency on webpack-sources, list it in a comment to
17+
+ * let the dependency validator know it is used.
18+
+ *
19+
+ * require('webpack-sources')
20+
+ */
1421

1522
export function getBrowserConfig(wco: WebpackConfigOptions) {
1623
const { projectRoot, buildOptions, appConfig } = wco;
@@ -25,12 +32,23 @@ export function getBrowserConfig(wco: WebpackConfigOptions) {
2532
...extraEntryParser(appConfig.styles, appRoot, 'styles')
2633
]);
2734

28-
if (buildOptions.vendorChunk) {
29-
extraPlugins.push(new webpack.optimize.CommonsChunkPlugin({
30-
name: 'vendor',
31-
chunks: ['main'],
32-
minChunks: (module: any) =>
33-
module.resource && /[\\\/]node_modules[\\\/]/.test(module.resource)
35+
// TODO: Enable this once HtmlWebpackPlugin supports Webpack 4
36+
const generateIndexHtml = false;
37+
if (generateIndexHtml) {
38+
extraPlugins.push(new HtmlWebpackPlugin({
39+
template: path.resolve(appRoot, appConfig.index),
40+
filename: path.resolve(buildOptions.outputPath, appConfig.index),
41+
chunksSortMode: packageChunkSort(appConfig),
42+
excludeChunks: lazyChunks,
43+
xhtml: true,
44+
minify: buildOptions.optimizationLevel === 1 ? {
45+
caseSensitive: true,
46+
collapseWhitespace: true,
47+
keepClosingSlash: true
48+
} : false
49+
}));
50+
extraPlugins.push(new BaseHrefWebpackPlugin({
51+
baseHref: buildOptions.baseHref as string
3452
}));
3553
}
3654

@@ -54,21 +72,24 @@ export function getBrowserConfig(wco: WebpackConfigOptions) {
5472
}
5573
}
5674

57-
if (buildOptions.commonChunk) {
58-
extraPlugins.push(new webpack.optimize.CommonsChunkPlugin({
59-
name: 'main',
60-
async: 'common',
61-
children: true,
62-
minChunks: 2
63-
}));
64-
}
65-
6675
if (buildOptions.subresourceIntegrity) {
6776
extraPlugins.push(new SubresourceIntegrityPlugin({
6877
hashFuncNames: ['sha384']
6978
}));
7079
}
7180

81+
if (buildOptions.extractLicenses) {
82+
extraPlugins.push(new LicenseWebpackPlugin({
83+
pattern: /.*/,
84+
suppressErrors: true,
85+
perChunkOutput: false,
86+
outputFilename: `3rdpartylicenses.txt`
87+
}));
88+
}
89+
90+
const globalStylesEntries = extraEntryParser(appConfig.styles, appRoot, 'styles')
91+
.map(style => style.entry);
92+
7293
return {
7394
resolve: {
7495
mainFields: [
@@ -79,37 +100,34 @@ export function getBrowserConfig(wco: WebpackConfigOptions) {
79100
output: {
80101
crossOriginLoading: buildOptions.subresourceIntegrity ? 'anonymous' : false
81102
},
82-
plugins: [
83-
new HtmlWebpackPlugin({
84-
template: path.resolve(appRoot, appConfig.index),
85-
filename: path.resolve(projectRoot, buildOptions.outputPath as any, appConfig.index),
86-
chunksSortMode: packageChunkSort(appConfig),
87-
excludeChunks: lazyChunks,
88-
xhtml: true,
89-
minify: buildOptions.optimizationLevel === 1? {
90-
caseSensitive: true,
91-
collapseWhitespace: true,
92-
keepClosingSlash: true
93-
} : false
94-
}),
95-
new BaseHrefWebpackPlugin({
96-
baseHref: buildOptions.baseHref as any
103+
optimization: {
104+
runtimeChunk: 'single',
105+
splitChunks: {
106+
chunks: buildOptions.commonChunk ? 'all' : 'initial',
107+
cacheGroups: {
108+
vendors: false,
109+
vendor: buildOptions.vendorChunk && {
110+
name: 'vendor',
111+
chunks: 'initial',
112+
test: (module: any, chunks: Array<{ name: string }>) => {
113+
const moduleName = module.nameForCondition ? module.nameForCondition() : '';
114+
return /[\\/]node_modules[\\/]/.test(moduleName)
115+
&& !chunks.some(({ name }) => name === 'polyfills'
116+
|| globalStylesEntries.includes(name));
117+
},
118+
},
119+
}
120+
}
121+
},
122+
plugins: extraPlugins.concat([
123+
new IndexHtmlWebpackPlugin({
124+
input: path.resolve(appRoot, appConfig.index),
125+
output: appConfig.index,
126+
baseHref: buildOptions.baseHref,
127+
entrypoints: generateEntryPoints(appConfig),
128+
deployUrl: buildOptions.deployUrl,
97129
}),
98-
new webpack.optimize.CommonsChunkPlugin({
99-
minChunks: Infinity,
100-
name: 'inline'
101-
})
102-
].concat(extraPlugins),
103-
node: {
104-
fs: 'empty',
105-
global: true,
106-
crypto: 'empty',
107-
tls: 'empty',
108-
net: 'empty',
109-
process: true,
110-
module: false,
111-
clearImmediate: false,
112-
setImmediate: false
113-
}
130+
]),
131+
node: false,
114132
};
115133
}

0 commit comments

Comments
 (0)