@angular-devkit/build-angular 12.0.0-rc.2 → 12.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +23 -23
- package/src/dev-server/index.js +2 -1
- package/src/dev-server/schema.d.ts +2 -1
- package/src/dev-server/schema.json +1 -1
- package/src/extract-i18n/index.js +2 -0
- package/src/sass/sass-service.d.ts +53 -0
- package/src/sass/sass-service.js +186 -0
- package/src/sass/worker.d.ts +8 -0
- package/src/sass/worker.js +49 -0
- package/src/utils/action-executor.js +2 -2
- package/src/utils/environment-options.d.ts +1 -0
- package/src/utils/environment-options.js +12 -1
- package/src/utils/index.d.ts +0 -1
- package/src/utils/index.js +0 -1
- package/src/utils/service-worker.js +1 -1
- package/src/webpack/configs/common.js +12 -16
- package/src/webpack/configs/styles.js +47 -7
- package/src/webpack/plugins/index-html-webpack-plugin.js +1 -1
- package/src/webpack/plugins/index.d.ts +0 -1
- package/src/webpack/plugins/index.js +1 -3
- package/src/webpack/plugins/postcss-cli-resources.js +1 -1
- package/src/webpack/utils/async-chunks.js +2 -6
- package/src/webpack/utils/stats.js +2 -7
- package/src/utils/workers.d.ts +0 -22
- package/src/utils/workers.js +0 -26
- package/src/webpack/plugins/optimize-css-webpack-plugin.d.ts +0 -17
- package/src/webpack/plugins/optimize-css-webpack-plugin.js +0 -106
package/package.json
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-devkit/build-angular",
|
|
3
|
-
"version": "12.0.
|
|
3
|
+
"version": "12.0.2",
|
|
4
4
|
"description": "Angular Webpack Build Facade",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"typings": "src/index.d.ts",
|
|
7
7
|
"builders": "builders.json",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@angular-devkit/architect": "0.1200.
|
|
10
|
-
"@angular-devkit/build-optimizer": "0.1200.
|
|
11
|
-
"@angular-devkit/build-webpack": "0.1200.
|
|
12
|
-
"@angular-devkit/core": "12.0.
|
|
13
|
-
"@babel/core": "7.
|
|
14
|
-
"@babel/generator": "7.
|
|
9
|
+
"@angular-devkit/architect": "0.1200.2",
|
|
10
|
+
"@angular-devkit/build-optimizer": "0.1200.2",
|
|
11
|
+
"@angular-devkit/build-webpack": "0.1200.2",
|
|
12
|
+
"@angular-devkit/core": "12.0.2",
|
|
13
|
+
"@babel/core": "7.14.3",
|
|
14
|
+
"@babel/generator": "7.14.3",
|
|
15
15
|
"@babel/plugin-transform-async-to-generator": "7.13.0",
|
|
16
|
-
"@babel/plugin-transform-runtime": "7.
|
|
17
|
-
"@babel/preset-env": "7.
|
|
18
|
-
"@babel/runtime": "7.
|
|
16
|
+
"@babel/plugin-transform-runtime": "7.14.3",
|
|
17
|
+
"@babel/preset-env": "7.14.2",
|
|
18
|
+
"@babel/runtime": "7.14.0",
|
|
19
19
|
"@babel/template": "7.12.13",
|
|
20
20
|
"@discoveryjs/json-ext": "0.5.2",
|
|
21
21
|
"@jsdevtools/coverage-istanbul-loader": "3.0.5",
|
|
22
|
-
"@ngtools/webpack": "12.0.
|
|
22
|
+
"@ngtools/webpack": "12.0.2",
|
|
23
23
|
"ansi-colors": "4.1.1",
|
|
24
24
|
"babel-loader": "8.2.2",
|
|
25
25
|
"browserslist": "^4.9.1",
|
|
@@ -27,12 +27,12 @@
|
|
|
27
27
|
"caniuse-lite": "^1.0.30001032",
|
|
28
28
|
"circular-dependency-plugin": "5.2.2",
|
|
29
29
|
"copy-webpack-plugin": "8.1.1",
|
|
30
|
-
"core-js": "3.
|
|
30
|
+
"core-js": "3.12.0",
|
|
31
31
|
"critters": "0.0.10",
|
|
32
32
|
"css-loader": "5.2.4",
|
|
33
|
-
"
|
|
33
|
+
"css-minimizer-webpack-plugin": "3.0.0",
|
|
34
34
|
"find-cache-dir": "3.3.1",
|
|
35
|
-
"glob": "7.1.
|
|
35
|
+
"glob": "7.1.7",
|
|
36
36
|
"https-proxy-agent": "5.0.0",
|
|
37
37
|
"inquirer": "8.0.0",
|
|
38
38
|
"jest-worker": "26.6.2",
|
|
@@ -43,16 +43,16 @@
|
|
|
43
43
|
"loader-utils": "2.0.0",
|
|
44
44
|
"mini-css-extract-plugin": "1.5.1",
|
|
45
45
|
"minimatch": "3.0.4",
|
|
46
|
-
"open": "8.0.
|
|
46
|
+
"open": "8.0.2",
|
|
47
47
|
"ora": "5.4.0",
|
|
48
48
|
"parse5-html-rewriting-stream": "6.0.1",
|
|
49
|
-
"postcss": "8.
|
|
49
|
+
"postcss": "8.3.0",
|
|
50
50
|
"postcss-import": "14.0.1",
|
|
51
51
|
"postcss-loader": "5.2.0",
|
|
52
52
|
"postcss-preset-env": "6.7.0",
|
|
53
53
|
"raw-loader": "4.0.2",
|
|
54
54
|
"regenerator-runtime": "0.13.7",
|
|
55
|
-
"resolve-url-loader": "
|
|
55
|
+
"resolve-url-loader": "4.0.0",
|
|
56
56
|
"rimraf": "3.0.2",
|
|
57
57
|
"rxjs": "6.6.7",
|
|
58
58
|
"sass": "1.32.12",
|
|
@@ -65,21 +65,21 @@
|
|
|
65
65
|
"stylus": "0.54.8",
|
|
66
66
|
"stylus-loader": "5.0.0",
|
|
67
67
|
"terser": "5.7.0",
|
|
68
|
-
"terser-webpack-plugin": "
|
|
68
|
+
"terser-webpack-plugin": "5.1.2",
|
|
69
69
|
"text-table": "0.2.0",
|
|
70
70
|
"tree-kill": "1.2.2",
|
|
71
|
-
"webpack": "5.36.
|
|
71
|
+
"webpack": "5.36.2",
|
|
72
72
|
"webpack-dev-middleware": "4.1.0",
|
|
73
73
|
"webpack-dev-server": "3.11.2",
|
|
74
74
|
"webpack-merge": "5.7.3",
|
|
75
75
|
"webpack-subresource-integrity": "1.5.2"
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
78
|
-
"@angular/compiler-cli": "^12.0.0
|
|
79
|
-
"@angular/localize": "^12.0.0
|
|
80
|
-
"@angular/service-worker": "^12.0.0
|
|
78
|
+
"@angular/compiler-cli": "^12.0.0",
|
|
79
|
+
"@angular/localize": "^12.0.0",
|
|
80
|
+
"@angular/service-worker": "^12.0.0",
|
|
81
81
|
"karma": "^6.3.0",
|
|
82
|
-
"ng-packagr": "^12.0.0
|
|
82
|
+
"ng-packagr": "^12.0.0",
|
|
83
83
|
"protractor": "^7.0.0",
|
|
84
84
|
"tailwindcss": "^2.0.0",
|
|
85
85
|
"tslint": "^6.1.0",
|
package/src/dev-server/index.js
CHANGED
|
@@ -133,7 +133,8 @@ function serveWebpackBrowser(options, context, transforms = {}) {
|
|
|
133
133
|
logger.warn(core_1.tags.stripIndents `NOTICE: Hot Module Replacement (HMR) is enabled for the dev server.
|
|
134
134
|
See https://webpack.js.org/guides/hot-module-replacement for information on working with HMR for Webpack.`);
|
|
135
135
|
}
|
|
136
|
-
if (options.
|
|
136
|
+
if (!options.disableHostCheck &&
|
|
137
|
+
options.host &&
|
|
137
138
|
!/^127\.\d+\.\d+\.\d+/g.test(options.host) &&
|
|
138
139
|
options.host !== 'localhost') {
|
|
139
140
|
logger.warn(core_1.tags.stripIndent `
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
},
|
|
22
22
|
"proxyConfig": {
|
|
23
23
|
"type": "string",
|
|
24
|
-
"description": "Proxy configuration file."
|
|
24
|
+
"description": "Proxy configuration file. For more information, see https://angular.io/guide/build#proxying-to-a-backend-server."
|
|
25
25
|
},
|
|
26
26
|
"ssl": {
|
|
27
27
|
"type": "boolean",
|
|
@@ -150,6 +150,7 @@ async function execute(options, context, transforms) {
|
|
|
150
150
|
configs_1.getCommonConfig(wco),
|
|
151
151
|
configs_1.getBrowserConfig(wco),
|
|
152
152
|
configs_1.getTypeScriptConfig(wco),
|
|
153
|
+
configs_1.getWorkerConfig(wco),
|
|
153
154
|
configs_1.getStatsConfig(wco),
|
|
154
155
|
];
|
|
155
156
|
// Add Ivy application file extractor support
|
|
@@ -170,6 +171,7 @@ async function execute(options, context, transforms) {
|
|
|
170
171
|
partials.push({
|
|
171
172
|
plugins: [
|
|
172
173
|
new webpack.NormalModuleReplacementPlugin(/\.(css|scss|sass|styl|less)$/, path.join(__dirname, 'empty-export-default.js')),
|
|
174
|
+
new webpack.NormalModuleReplacementPlugin(/^angular-resource:\/\//, path.join(__dirname, 'empty-export-default.js')),
|
|
173
175
|
],
|
|
174
176
|
});
|
|
175
177
|
return partials;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
import { Options, Result, SassException } from 'sass';
|
|
9
|
+
/**
|
|
10
|
+
* The callback type for the `dart-sass` asynchronous render function.
|
|
11
|
+
*/
|
|
12
|
+
declare type RenderCallback = (error?: SassException, result?: Result) => void;
|
|
13
|
+
/**
|
|
14
|
+
* A Sass renderer implementation that provides an interface that can be used by Webpack's
|
|
15
|
+
* `sass-loader`. The implementation uses a Worker thread to perform the Sass rendering
|
|
16
|
+
* with the `dart-sass` package. The `dart-sass` synchronous render function is used within
|
|
17
|
+
* the worker which can be up to two times faster than the asynchronous variant.
|
|
18
|
+
*/
|
|
19
|
+
export declare class SassWorkerImplementation {
|
|
20
|
+
private readonly workers;
|
|
21
|
+
private readonly availableWorkers;
|
|
22
|
+
private readonly requests;
|
|
23
|
+
private idCounter;
|
|
24
|
+
private nextWorkerIndex;
|
|
25
|
+
/**
|
|
26
|
+
* Provides information about the Sass implementation.
|
|
27
|
+
* This mimics enough of the `dart-sass` value to be used with the `sass-loader`.
|
|
28
|
+
*/
|
|
29
|
+
get info(): string;
|
|
30
|
+
/**
|
|
31
|
+
* The synchronous render function is not used by the `sass-loader`.
|
|
32
|
+
*/
|
|
33
|
+
renderSync(): never;
|
|
34
|
+
/**
|
|
35
|
+
* Asynchronously request a Sass stylesheet to be renderered.
|
|
36
|
+
*
|
|
37
|
+
* @param options The `dart-sass` options to use when rendering the stylesheet.
|
|
38
|
+
* @param callback The function to execute when the rendering is complete.
|
|
39
|
+
*/
|
|
40
|
+
render(options: Options, callback: RenderCallback): void;
|
|
41
|
+
/**
|
|
42
|
+
* Shutdown the Sass render worker.
|
|
43
|
+
* Executing this method will stop any pending render requests.
|
|
44
|
+
*
|
|
45
|
+
* The worker is unreferenced upon creation and will not block application exit. This method
|
|
46
|
+
* is only needed if early cleanup is needed.
|
|
47
|
+
*/
|
|
48
|
+
close(): void;
|
|
49
|
+
private createWorker;
|
|
50
|
+
private processImporters;
|
|
51
|
+
private createRequest;
|
|
52
|
+
}
|
|
53
|
+
export {};
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
5
|
+
*
|
|
6
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
+
* found in the LICENSE file at https://angular.io/license
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.SassWorkerImplementation = void 0;
|
|
11
|
+
const worker_threads_1 = require("worker_threads");
|
|
12
|
+
const environment_options_1 = require("../utils/environment-options");
|
|
13
|
+
/**
|
|
14
|
+
* The maximum number of Workers that will be created to execute render requests.
|
|
15
|
+
*/
|
|
16
|
+
const MAX_RENDER_WORKERS = environment_options_1.maxWorkers;
|
|
17
|
+
/**
|
|
18
|
+
* Workaround required for lack of new Worker transfer list support in Node.js prior to 12.17
|
|
19
|
+
*/
|
|
20
|
+
let transferListWorkaround = false;
|
|
21
|
+
const version = process.versions.node.split('.').map((part) => Number(part));
|
|
22
|
+
if (version[0] === 12 && version[1] < 17) {
|
|
23
|
+
transferListWorkaround = true;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* A Sass renderer implementation that provides an interface that can be used by Webpack's
|
|
27
|
+
* `sass-loader`. The implementation uses a Worker thread to perform the Sass rendering
|
|
28
|
+
* with the `dart-sass` package. The `dart-sass` synchronous render function is used within
|
|
29
|
+
* the worker which can be up to two times faster than the asynchronous variant.
|
|
30
|
+
*/
|
|
31
|
+
class SassWorkerImplementation {
|
|
32
|
+
constructor() {
|
|
33
|
+
this.workers = [];
|
|
34
|
+
this.availableWorkers = [];
|
|
35
|
+
this.requests = new Map();
|
|
36
|
+
this.idCounter = 1;
|
|
37
|
+
this.nextWorkerIndex = 0;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Provides information about the Sass implementation.
|
|
41
|
+
* This mimics enough of the `dart-sass` value to be used with the `sass-loader`.
|
|
42
|
+
*/
|
|
43
|
+
get info() {
|
|
44
|
+
return 'dart-sass\tworker';
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The synchronous render function is not used by the `sass-loader`.
|
|
48
|
+
*/
|
|
49
|
+
renderSync() {
|
|
50
|
+
throw new Error('Sass renderSync is not supported.');
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Asynchronously request a Sass stylesheet to be renderered.
|
|
54
|
+
*
|
|
55
|
+
* @param options The `dart-sass` options to use when rendering the stylesheet.
|
|
56
|
+
* @param callback The function to execute when the rendering is complete.
|
|
57
|
+
*/
|
|
58
|
+
render(options, callback) {
|
|
59
|
+
// The `functions` and `importer` options are JavaScript functions that cannot be transferred.
|
|
60
|
+
// If any additional function options are added in the future, they must be excluded as well.
|
|
61
|
+
const { functions, importer, ...serializableOptions } = options;
|
|
62
|
+
// The CLI's configuration does not use or expose the ability to defined custom Sass functions
|
|
63
|
+
if (functions && Object.keys(functions).length > 0) {
|
|
64
|
+
throw new Error('Sass custom functions are not supported.');
|
|
65
|
+
}
|
|
66
|
+
let workerIndex = this.availableWorkers.pop();
|
|
67
|
+
if (workerIndex === undefined) {
|
|
68
|
+
if (this.workers.length < MAX_RENDER_WORKERS) {
|
|
69
|
+
workerIndex = this.workers.length;
|
|
70
|
+
this.workers.push(this.createWorker());
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
workerIndex = this.nextWorkerIndex++;
|
|
74
|
+
if (this.nextWorkerIndex >= this.workers.length) {
|
|
75
|
+
this.nextWorkerIndex = 0;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const request = this.createRequest(workerIndex, callback, importer);
|
|
80
|
+
this.requests.set(request.id, request);
|
|
81
|
+
this.workers[workerIndex].postMessage({
|
|
82
|
+
id: request.id,
|
|
83
|
+
hasImporter: !!importer,
|
|
84
|
+
options: serializableOptions,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Shutdown the Sass render worker.
|
|
89
|
+
* Executing this method will stop any pending render requests.
|
|
90
|
+
*
|
|
91
|
+
* The worker is unreferenced upon creation and will not block application exit. This method
|
|
92
|
+
* is only needed if early cleanup is needed.
|
|
93
|
+
*/
|
|
94
|
+
close() {
|
|
95
|
+
for (const worker of this.workers) {
|
|
96
|
+
void worker.terminate();
|
|
97
|
+
}
|
|
98
|
+
this.requests.clear();
|
|
99
|
+
}
|
|
100
|
+
createWorker() {
|
|
101
|
+
const { port1: mainImporterPort, port2: workerImporterPort } = new worker_threads_1.MessageChannel();
|
|
102
|
+
const importerSignal = new Int32Array(new SharedArrayBuffer(4));
|
|
103
|
+
const workerPath = require.resolve('./worker');
|
|
104
|
+
const worker = new worker_threads_1.Worker(workerPath, {
|
|
105
|
+
workerData: transferListWorkaround ? undefined : { workerImporterPort, importerSignal },
|
|
106
|
+
transferList: transferListWorkaround ? undefined : [workerImporterPort],
|
|
107
|
+
});
|
|
108
|
+
if (transferListWorkaround) {
|
|
109
|
+
worker.postMessage({ init: true, workerImporterPort, importerSignal }, [workerImporterPort]);
|
|
110
|
+
}
|
|
111
|
+
worker.on('message', (response) => {
|
|
112
|
+
const request = this.requests.get(response.id);
|
|
113
|
+
if (!request) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
this.requests.delete(response.id);
|
|
117
|
+
this.availableWorkers.push(request.workerIndex);
|
|
118
|
+
if (response.result) {
|
|
119
|
+
// The results are expected to be Node.js `Buffer` objects but will each be transferred as
|
|
120
|
+
// a Uint8Array that does not have the expected `toString` behavior of a `Buffer`.
|
|
121
|
+
const { css, map, stats } = response.result;
|
|
122
|
+
const result = {
|
|
123
|
+
// This `Buffer.from` override will use the memory directly and avoid making a copy
|
|
124
|
+
css: Buffer.from(css.buffer, css.byteOffset, css.byteLength),
|
|
125
|
+
stats,
|
|
126
|
+
};
|
|
127
|
+
if (map) {
|
|
128
|
+
// This `Buffer.from` override will use the memory directly and avoid making a copy
|
|
129
|
+
result.map = Buffer.from(map.buffer, map.byteOffset, map.byteLength);
|
|
130
|
+
}
|
|
131
|
+
request.callback(undefined, result);
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
request.callback(response.error);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
mainImporterPort.on('message', ({ id, url, prev }) => {
|
|
138
|
+
const request = this.requests.get(id);
|
|
139
|
+
if (!(request === null || request === void 0 ? void 0 : request.importers)) {
|
|
140
|
+
mainImporterPort.postMessage(null);
|
|
141
|
+
Atomics.store(importerSignal, 0, 1);
|
|
142
|
+
Atomics.notify(importerSignal, 0);
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
this.processImporters(request.importers, url, prev)
|
|
146
|
+
.then((result) => {
|
|
147
|
+
mainImporterPort.postMessage(result);
|
|
148
|
+
})
|
|
149
|
+
.catch((error) => {
|
|
150
|
+
mainImporterPort.postMessage(error);
|
|
151
|
+
})
|
|
152
|
+
.finally(() => {
|
|
153
|
+
Atomics.store(importerSignal, 0, 1);
|
|
154
|
+
Atomics.notify(importerSignal, 0);
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
worker.unref();
|
|
158
|
+
mainImporterPort.unref();
|
|
159
|
+
return worker;
|
|
160
|
+
}
|
|
161
|
+
async processImporters(importers, url, prev) {
|
|
162
|
+
let result = null;
|
|
163
|
+
for (const importer of importers) {
|
|
164
|
+
result = await new Promise((resolve) => {
|
|
165
|
+
// Importers can be both sync and async
|
|
166
|
+
const innerResult = importer(url, prev, resolve);
|
|
167
|
+
if (innerResult !== undefined) {
|
|
168
|
+
resolve(innerResult);
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
if (result) {
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return result;
|
|
176
|
+
}
|
|
177
|
+
createRequest(workerIndex, callback, importer) {
|
|
178
|
+
return {
|
|
179
|
+
id: this.idCounter++,
|
|
180
|
+
workerIndex,
|
|
181
|
+
callback,
|
|
182
|
+
importers: !importer || Array.isArray(importer) ? importer : [importer],
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
exports.SassWorkerImplementation = SassWorkerImplementation;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
5
|
+
*
|
|
6
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
+
* found in the LICENSE file at https://angular.io/license
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
const sass_1 = require("sass");
|
|
11
|
+
const worker_threads_1 = require("worker_threads");
|
|
12
|
+
if (!worker_threads_1.parentPort) {
|
|
13
|
+
throw new Error('Sass worker must be executed as a Worker.');
|
|
14
|
+
}
|
|
15
|
+
// The importer variables are used to proxy import requests to the main thread
|
|
16
|
+
let { workerImporterPort, importerSignal } = (worker_threads_1.workerData || {});
|
|
17
|
+
worker_threads_1.parentPort.on('message', (message) => {
|
|
18
|
+
// The init message is only needed to support Node.js < 12.17 and can be removed once support is dropped
|
|
19
|
+
if (message.init) {
|
|
20
|
+
workerImporterPort = message.workerImporterPort;
|
|
21
|
+
importerSignal = message.importerSignal;
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const { id, hasImporter, options } = message;
|
|
25
|
+
try {
|
|
26
|
+
if (hasImporter) {
|
|
27
|
+
// When a custom importer function is present, the importer request must be proxied
|
|
28
|
+
// back to the main thread where it can be executed.
|
|
29
|
+
// This process must be synchronous from the perspective of dart-sass. The `Atomics`
|
|
30
|
+
// functions combined with the shared memory `importSignal` and the Node.js
|
|
31
|
+
// `receiveMessageOnPort` function are used to ensure synchronous behavior.
|
|
32
|
+
options.importer = (url, prev) => {
|
|
33
|
+
var _a;
|
|
34
|
+
Atomics.store(importerSignal, 0, 0);
|
|
35
|
+
workerImporterPort.postMessage({ id, url, prev });
|
|
36
|
+
Atomics.wait(importerSignal, 0, 0);
|
|
37
|
+
return (_a = worker_threads_1.receiveMessageOnPort(workerImporterPort)) === null || _a === void 0 ? void 0 : _a.message;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
// The synchronous Sass render function can be up to two times faster than the async variant
|
|
41
|
+
const result = sass_1.renderSync(options);
|
|
42
|
+
worker_threads_1.parentPort === null || worker_threads_1.parentPort === void 0 ? void 0 : worker_threads_1.parentPort.postMessage({ id, result });
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
// Needed because V8 will only serialize the message and stack properties of an Error instance.
|
|
46
|
+
const { formatted, file, line, column, message, stack } = error;
|
|
47
|
+
worker_threads_1.parentPort === null || worker_threads_1.parentPort === void 0 ? void 0 : worker_threads_1.parentPort.postMessage({ id, error: { formatted, file, line, column, message, stack } });
|
|
48
|
+
}
|
|
49
|
+
});
|
|
@@ -13,7 +13,7 @@ const os = require("os");
|
|
|
13
13
|
const path = require("path");
|
|
14
14
|
const v8_1 = require("v8");
|
|
15
15
|
const action_cache_1 = require("./action-cache");
|
|
16
|
-
const
|
|
16
|
+
const environment_options_1 = require("./environment-options");
|
|
17
17
|
let workerFile = require.resolve('./process-bundle');
|
|
18
18
|
workerFile =
|
|
19
19
|
path.extname(workerFile) === '.ts' ? require.resolve('./process-bundle-bootstrap') : workerFile;
|
|
@@ -36,7 +36,7 @@ class BundleActionExecutor {
|
|
|
36
36
|
return (this.largeWorker = new jest_worker_1.default(workerFile, {
|
|
37
37
|
exposedMethods: ['process', 'inlineLocales'],
|
|
38
38
|
setupArgs: [[...v8_1.serialize(this.workerOptions)]],
|
|
39
|
-
numWorkers:
|
|
39
|
+
numWorkers: environment_options_1.maxWorkers,
|
|
40
40
|
}));
|
|
41
41
|
}
|
|
42
42
|
ensureSmall() {
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* found in the LICENSE file at https://angular.io/license
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.profilingEnabled = exports.cachingBasePath = exports.cachingDisabled = exports.allowMinify = exports.shouldBeautify = exports.allowMangle = void 0;
|
|
10
|
+
exports.maxWorkers = exports.profilingEnabled = exports.cachingBasePath = exports.cachingDisabled = exports.allowMinify = exports.shouldBeautify = exports.allowMangle = void 0;
|
|
11
11
|
const path = require("path");
|
|
12
12
|
function isDisabled(variable) {
|
|
13
13
|
return variable === '0' || variable.toLowerCase() === 'false';
|
|
@@ -72,3 +72,14 @@ exports.cachingBasePath = (() => {
|
|
|
72
72
|
// Build profiling
|
|
73
73
|
const profilingVariable = process.env['NG_BUILD_PROFILING'];
|
|
74
74
|
exports.profilingEnabled = isPresent(profilingVariable) && isEnabled(profilingVariable);
|
|
75
|
+
/**
|
|
76
|
+
* Some environments, like CircleCI which use Docker report a number of CPUs by the host and not the count of available.
|
|
77
|
+
* This cause `Error: Call retries were exceeded` errors when trying to use them.
|
|
78
|
+
*
|
|
79
|
+
* @see https://github.com/nodejs/node/issues/28762
|
|
80
|
+
* @see https://github.com/webpack-contrib/terser-webpack-plugin/issues/143
|
|
81
|
+
* @see https://ithub.com/angular/angular-cli/issues/16860#issuecomment-588828079
|
|
82
|
+
*
|
|
83
|
+
*/
|
|
84
|
+
const maxWorkersVariable = process.env['NG_BUILD_MAX_WORKERS'];
|
|
85
|
+
exports.maxWorkers = isPresent(maxWorkersVariable) ? +maxWorkersVariable : 4;
|
package/src/utils/index.d.ts
CHANGED
package/src/utils/index.js
CHANGED
|
@@ -27,4 +27,3 @@ __exportStar(require("./normalize-source-maps"), exports);
|
|
|
27
27
|
__exportStar(require("./normalize-optimization"), exports);
|
|
28
28
|
__exportStar(require("./normalize-builder-schema"), exports);
|
|
29
29
|
__exportStar(require("./url"), exports);
|
|
30
|
-
__exportStar(require("./workers"), exports);
|
|
@@ -40,7 +40,7 @@ class CliFilesystem {
|
|
|
40
40
|
for await (const entry of await fs_1.promises.opendir(dir)) {
|
|
41
41
|
if (entry.isFile()) {
|
|
42
42
|
// Uses posix paths since the service worker expects URLs
|
|
43
|
-
items.push('/' + path.
|
|
43
|
+
items.push('/' + path.relative(this.base, path.join(dir, entry.name)).replace(/\\/g, '/'));
|
|
44
44
|
}
|
|
45
45
|
else if (entry.isDirectory()) {
|
|
46
46
|
subdirectories.push(path.join(dir, entry.name));
|
|
@@ -23,7 +23,6 @@ const webpack_diagnostics_1 = require("../../utils/webpack-diagnostics");
|
|
|
23
23
|
const plugins_1 = require("../plugins");
|
|
24
24
|
const helpers_1 = require("../utils/helpers");
|
|
25
25
|
const stats_1 = require("../utils/stats");
|
|
26
|
-
const TerserPlugin = require('terser-webpack-plugin');
|
|
27
26
|
// eslint-disable-next-line max-lines-per-function
|
|
28
27
|
function getCommonConfig(wco) {
|
|
29
28
|
var _a;
|
|
@@ -34,6 +33,7 @@ function getCommonConfig(wco) {
|
|
|
34
33
|
const entryPoints = {};
|
|
35
34
|
// determine hashing format
|
|
36
35
|
const hashFormat = helpers_1.getOutputHashFormat(buildOptions.outputHashing || 'none');
|
|
36
|
+
const buildBrowserFeatures = new utils_1.BuildBrowserFeatures(projectRoot);
|
|
37
37
|
const targetInFileName = helpers_1.getEsVersionForFileName(tsConfig.options.target, buildOptions.differentialLoadingNeeded);
|
|
38
38
|
if (buildOptions.main) {
|
|
39
39
|
const mainPath = path.resolve(root, buildOptions.main);
|
|
@@ -42,7 +42,6 @@ function getCommonConfig(wco) {
|
|
|
42
42
|
const differentialLoadingMode = buildOptions.differentialLoadingNeeded && !buildOptions.watch;
|
|
43
43
|
if (platform !== 'server') {
|
|
44
44
|
if (differentialLoadingMode || tsConfig.options.target === typescript_1.ScriptTarget.ES5) {
|
|
45
|
-
const buildBrowserFeatures = new utils_1.BuildBrowserFeatures(projectRoot);
|
|
46
45
|
if (buildBrowserFeatures.isEs5SupportNeeded()) {
|
|
47
46
|
const polyfillsChunkName = 'polyfills-es5';
|
|
48
47
|
entryPoints[polyfillsChunkName] = [path.join(__dirname, '..', 'es5-polyfills.js')];
|
|
@@ -200,7 +199,7 @@ function getCommonConfig(wco) {
|
|
|
200
199
|
compiler.hooks.done.tapPromise('angular-cli-stats', async (stats) => {
|
|
201
200
|
const { stringifyStream } = await Promise.resolve().then(() => require('@discoveryjs/json-ext'));
|
|
202
201
|
const data = stats.toJson('verbose');
|
|
203
|
-
const statsOutputPath = path.
|
|
202
|
+
const statsOutputPath = path.resolve(root, buildOptions.outputPath, 'stats.json');
|
|
204
203
|
try {
|
|
205
204
|
await fs_1.promises.mkdir(path.dirname(statsOutputPath), { recursive: true });
|
|
206
205
|
await new Promise((resolve, reject) => stringifyStream(data)
|
|
@@ -234,14 +233,8 @@ function getCommonConfig(wco) {
|
|
|
234
233
|
];
|
|
235
234
|
}
|
|
236
235
|
const extraMinimizers = [];
|
|
237
|
-
if (stylesOptimization.minify) {
|
|
238
|
-
extraMinimizers.push(new plugins_1.OptimizeCssWebpackPlugin({
|
|
239
|
-
sourceMap: stylesSourceMap,
|
|
240
|
-
// component styles retain their original file name
|
|
241
|
-
test: (file) => /\.(?:css|scss|sass|less|styl)$/.test(file),
|
|
242
|
-
}));
|
|
243
|
-
}
|
|
244
236
|
if (scriptsOptimization) {
|
|
237
|
+
const TerserPlugin = require('terser-webpack-plugin');
|
|
245
238
|
const { GLOBAL_DEFS_FOR_TERSER, GLOBAL_DEFS_FOR_TERSER_WITH_AOT, } = require('@angular/compiler-cli');
|
|
246
239
|
const angularGlobalDefinitions = buildOptions.aot
|
|
247
240
|
? GLOBAL_DEFS_FOR_TERSER_WITH_AOT
|
|
@@ -285,9 +278,7 @@ function getCommonConfig(wco) {
|
|
|
285
278
|
};
|
|
286
279
|
const globalScriptsNames = globalScriptsByBundleName.map((s) => s.bundleName);
|
|
287
280
|
extraMinimizers.push(new TerserPlugin({
|
|
288
|
-
|
|
289
|
-
parallel: utils_1.maxWorkers,
|
|
290
|
-
cache: !environment_options_1.cachingDisabled && cache_path_1.findCachePath('terser-webpack'),
|
|
281
|
+
parallel: environment_options_1.maxWorkers,
|
|
291
282
|
extractComments: false,
|
|
292
283
|
exclude: globalScriptsNames,
|
|
293
284
|
terserOptions,
|
|
@@ -295,9 +286,7 @@ function getCommonConfig(wco) {
|
|
|
295
286
|
// Script bundles are fully optimized here in one step since they are never downleveled.
|
|
296
287
|
// They are shared between ES2015 & ES5 outputs so must support ES5.
|
|
297
288
|
new TerserPlugin({
|
|
298
|
-
|
|
299
|
-
parallel: utils_1.maxWorkers,
|
|
300
|
-
cache: !environment_options_1.cachingDisabled && cache_path_1.findCachePath('terser-webpack'),
|
|
289
|
+
parallel: environment_options_1.maxWorkers,
|
|
301
290
|
extractComments: false,
|
|
302
291
|
include: globalScriptsNames,
|
|
303
292
|
terserOptions: {
|
|
@@ -337,6 +326,7 @@ function getCommonConfig(wco) {
|
|
|
337
326
|
context: root,
|
|
338
327
|
entry: entryPoints,
|
|
339
328
|
output: {
|
|
329
|
+
clean: buildOptions.deleteOutputPath,
|
|
340
330
|
path: path.resolve(root, buildOptions.outputPath),
|
|
341
331
|
publicPath: (_a = buildOptions.deployUrl) !== null && _a !== void 0 ? _a : '',
|
|
342
332
|
filename: ({ chunk }) => {
|
|
@@ -374,6 +364,8 @@ function getCommonConfig(wco) {
|
|
|
374
364
|
},
|
|
375
365
|
{
|
|
376
366
|
test: /\.[cm]?js$|\.tsx?$/,
|
|
367
|
+
// The below is needed due to a bug in `@babel/runtime`. See: https://github.com/babel/babel/issues/12824
|
|
368
|
+
resolve: { fullySpecified: false },
|
|
377
369
|
exclude: [/[\/\\](?:core-js|\@babel|tslib|web-animations-js)[\/\\]/],
|
|
378
370
|
use: [
|
|
379
371
|
{
|
|
@@ -390,6 +382,10 @@ function getCommonConfig(wco) {
|
|
|
390
382
|
...extraRules,
|
|
391
383
|
],
|
|
392
384
|
},
|
|
385
|
+
experiments: {
|
|
386
|
+
syncWebAssembly: true,
|
|
387
|
+
asyncWebAssembly: true,
|
|
388
|
+
},
|
|
393
389
|
cache: !!buildOptions.watch &&
|
|
394
390
|
!environment_options_1.cachingDisabled && {
|
|
395
391
|
type: 'memory',
|
|
@@ -10,7 +10,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
10
10
|
exports.getStylesConfig = void 0;
|
|
11
11
|
const fs = require("fs");
|
|
12
12
|
const path = require("path");
|
|
13
|
+
const sass_service_1 = require("../../sass/sass-service");
|
|
13
14
|
const build_browser_features_1 = require("../../utils/build-browser-features");
|
|
15
|
+
const environment_options_1 = require("../../utils/environment-options");
|
|
14
16
|
const plugins_1 = require("../plugins");
|
|
15
17
|
const helpers_1 = require("../utils/helpers");
|
|
16
18
|
function resolveGlobalStyles(styleEntrypoints, root, preserveSymlinks) {
|
|
@@ -62,7 +64,7 @@ function getStylesConfig(wco) {
|
|
|
62
64
|
// use includePaths from appConfig
|
|
63
65
|
const includePaths = (_c = (_b = (_a = buildOptions.stylePreprocessorOptions) === null || _a === void 0 ? void 0 : _a.includePaths) === null || _b === void 0 ? void 0 : _b.map((p) => path.resolve(root, p))) !== null && _c !== void 0 ? _c : [];
|
|
64
66
|
// Process global styles.
|
|
65
|
-
const { entryPoints, noInjectNames, paths: globalStylePaths } = resolveGlobalStyles(buildOptions.styles, root, !!buildOptions.preserveSymlinks);
|
|
67
|
+
const { entryPoints, noInjectNames, paths: globalStylePaths, } = resolveGlobalStyles(buildOptions.styles, root, !!buildOptions.preserveSymlinks);
|
|
66
68
|
if (noInjectNames.length > 0) {
|
|
67
69
|
// Add plugin to remove hashes from lazy styles.
|
|
68
70
|
extraPlugins.push(new plugins_1.RemoveHashPlugin({ chunkNames: noInjectNames, hashFormat }));
|
|
@@ -78,7 +80,7 @@ function getStylesConfig(wco) {
|
|
|
78
80
|
`To opt-out of the deprecated behaviour and start using 'sass' uninstall 'node-sass'.`);
|
|
79
81
|
}
|
|
80
82
|
catch {
|
|
81
|
-
sassImplementation =
|
|
83
|
+
sassImplementation = new sass_service_1.SassWorkerImplementation();
|
|
82
84
|
}
|
|
83
85
|
const assetNameTemplate = helpers_1.assetNameTemplateFactory(hashFormat);
|
|
84
86
|
const extraPostcssPlugins = [];
|
|
@@ -115,6 +117,11 @@ function getStylesConfig(wco) {
|
|
|
115
117
|
}
|
|
116
118
|
}
|
|
117
119
|
const { supportedBrowsers } = new build_browser_features_1.BuildBrowserFeatures(wco.projectRoot);
|
|
120
|
+
const postcssPresetEnvPlugin = postcssPresetEnv({
|
|
121
|
+
browsers: supportedBrowsers,
|
|
122
|
+
autoprefixer: true,
|
|
123
|
+
stage: 3,
|
|
124
|
+
});
|
|
118
125
|
const postcssOptionsCreator = (inlineSourcemaps, extracted) => {
|
|
119
126
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
120
127
|
const optionGenerator = (loader) => ({
|
|
@@ -150,11 +157,7 @@ function getStylesConfig(wco) {
|
|
|
150
157
|
extracted,
|
|
151
158
|
}),
|
|
152
159
|
...extraPostcssPlugins,
|
|
153
|
-
|
|
154
|
-
browsers: supportedBrowsers,
|
|
155
|
-
autoprefixer: true,
|
|
156
|
-
stage: 3,
|
|
157
|
-
}),
|
|
160
|
+
postcssPresetEnvPlugin,
|
|
158
161
|
],
|
|
159
162
|
});
|
|
160
163
|
// postcss-loader fails when trying to determine configuration files for data URIs
|
|
@@ -232,6 +235,8 @@ function getStylesConfig(wco) {
|
|
|
232
235
|
implementation: sassImplementation,
|
|
233
236
|
sourceMap: true,
|
|
234
237
|
sassOptions: {
|
|
238
|
+
// Prevent use of `fibers` package as it no longer works in newer Node.js versions
|
|
239
|
+
fiber: false,
|
|
235
240
|
// bootstrap-sass requires a minimum precision of 8
|
|
236
241
|
precision: 8,
|
|
237
242
|
includePaths,
|
|
@@ -340,11 +345,46 @@ function getStylesConfig(wco) {
|
|
|
340
345
|
],
|
|
341
346
|
});
|
|
342
347
|
}
|
|
348
|
+
const extraMinimizers = [];
|
|
349
|
+
if (buildOptions.optimization.styles.minify) {
|
|
350
|
+
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
|
|
351
|
+
const minimizerOptions = {
|
|
352
|
+
preset: [
|
|
353
|
+
'default',
|
|
354
|
+
{
|
|
355
|
+
// Disable SVG optimizations, as this can cause optimizations which are not compatible in all browsers.
|
|
356
|
+
svgo: false,
|
|
357
|
+
// Disable `calc` optimizations, due to several issues. #16910, #16875, #17890
|
|
358
|
+
calc: false,
|
|
359
|
+
// Disable CSS rules sorted due to several issues #20693, https://github.com/ionic-team/ionic-framework/issues/23266 and https://github.com/cssnano/cssnano/issues/1054
|
|
360
|
+
cssDeclarationSorter: false,
|
|
361
|
+
},
|
|
362
|
+
],
|
|
363
|
+
};
|
|
364
|
+
const globalBundlesRegExp = new RegExp(`^(${Object.keys(entryPoints).join('|')})(\.[0-9a-f]{20})?.css$`);
|
|
365
|
+
extraMinimizers.push(new CssMinimizerPlugin({
|
|
366
|
+
// Component styles retain their original file name
|
|
367
|
+
test: /\.(?:css|scss|sass|less|styl)$/,
|
|
368
|
+
parallel: false,
|
|
369
|
+
exclude: globalBundlesRegExp,
|
|
370
|
+
minify: [CssMinimizerPlugin.cssnanoMinify],
|
|
371
|
+
minimizerOptions,
|
|
372
|
+
}), new CssMinimizerPlugin({
|
|
373
|
+
test: /\.css$/,
|
|
374
|
+
include: globalBundlesRegExp,
|
|
375
|
+
parallel: environment_options_1.maxWorkers,
|
|
376
|
+
minify: [CssMinimizerPlugin.cssnanoMinify],
|
|
377
|
+
minimizerOptions,
|
|
378
|
+
}));
|
|
379
|
+
}
|
|
343
380
|
return {
|
|
344
381
|
entry: entryPoints,
|
|
345
382
|
module: {
|
|
346
383
|
rules: [...fileLanguageRules, ...inlineLanguageRules],
|
|
347
384
|
},
|
|
385
|
+
optimization: {
|
|
386
|
+
minimizer: extraMinimizers,
|
|
387
|
+
},
|
|
348
388
|
plugins: extraPlugins,
|
|
349
389
|
};
|
|
350
390
|
}
|
|
@@ -40,7 +40,7 @@ class IndexHtmlWebpackPlugin extends index_html_generator_1.IndexHtmlGenerator {
|
|
|
40
40
|
const moduleFiles = [];
|
|
41
41
|
try {
|
|
42
42
|
for (const [entryName, entrypoint] of this.compilation.entrypoints) {
|
|
43
|
-
const entryFiles = (_a = entrypoint === null || entrypoint === void 0 ? void 0 : entrypoint.getFiles()) === null || _a === void 0 ? void 0 : _a.map((f) => ({
|
|
43
|
+
const entryFiles = (_a = entrypoint === null || entrypoint === void 0 ? void 0 : entrypoint.getFiles()) === null || _a === void 0 ? void 0 : _a.filter((f) => !f.endsWith('.hot-update.js')).map((f) => ({
|
|
44
44
|
name: entryName,
|
|
45
45
|
file: f,
|
|
46
46
|
extension: path_1.extname(f),
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
8
|
export { AnyComponentStyleBudgetChecker } from './any-component-style-budget-checker';
|
|
9
|
-
export { OptimizeCssWebpackPlugin, OptimizeCssWebpackPluginOptions, } from './optimize-css-webpack-plugin';
|
|
10
9
|
export { ScriptsWebpackPlugin, ScriptsWebpackPluginOptions } from './scripts-webpack-plugin';
|
|
11
10
|
export { SuppressExtractedTextChunksWebpackPlugin } from './suppress-entry-chunks-webpack-plugin';
|
|
12
11
|
export { RemoveHashPlugin, RemoveHashPluginOptions } from './remove-hash-plugin';
|
|
@@ -7,12 +7,10 @@
|
|
|
7
7
|
* found in the LICENSE file at https://angular.io/license
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.PostcssCliResources = exports.CommonJsUsageWarnPlugin = exports.DedupeModuleResolvePlugin = exports.RemoveHashPlugin = exports.SuppressExtractedTextChunksWebpackPlugin = exports.ScriptsWebpackPlugin = exports.
|
|
10
|
+
exports.PostcssCliResources = exports.CommonJsUsageWarnPlugin = exports.DedupeModuleResolvePlugin = exports.RemoveHashPlugin = exports.SuppressExtractedTextChunksWebpackPlugin = exports.ScriptsWebpackPlugin = exports.AnyComponentStyleBudgetChecker = void 0;
|
|
11
11
|
// Exports the webpack plugins we use internally.
|
|
12
12
|
var any_component_style_budget_checker_1 = require("./any-component-style-budget-checker");
|
|
13
13
|
Object.defineProperty(exports, "AnyComponentStyleBudgetChecker", { enumerable: true, get: function () { return any_component_style_budget_checker_1.AnyComponentStyleBudgetChecker; } });
|
|
14
|
-
var optimize_css_webpack_plugin_1 = require("./optimize-css-webpack-plugin");
|
|
15
|
-
Object.defineProperty(exports, "OptimizeCssWebpackPlugin", { enumerable: true, get: function () { return optimize_css_webpack_plugin_1.OptimizeCssWebpackPlugin; } });
|
|
16
14
|
var scripts_webpack_plugin_1 = require("./scripts-webpack-plugin");
|
|
17
15
|
Object.defineProperty(exports, "ScriptsWebpackPlugin", { enumerable: true, get: function () { return scripts_webpack_plugin_1.ScriptsWebpackPlugin; } });
|
|
18
16
|
var suppress_entry_chunks_webpack_plugin_1 = require("./suppress-entry-chunks-webpack-plugin");
|
|
@@ -83,7 +83,7 @@ function default_1(options) {
|
|
|
83
83
|
}
|
|
84
84
|
loader.addDependency(result);
|
|
85
85
|
if (emitFile) {
|
|
86
|
-
loader.emitFile(outputPath, content, undefined);
|
|
86
|
+
loader.emitFile(outputPath, content, undefined, { sourceFilename: result });
|
|
87
87
|
}
|
|
88
88
|
let outputUrl = outputPath.replace(/\\/g, '/');
|
|
89
89
|
if (hash || search) {
|
|
@@ -24,17 +24,13 @@ function markAsyncChunksNonInitial(webpackStats, extraEntryPoints) {
|
|
|
24
24
|
.filter((entryPoint) => !entryPoint.inject)
|
|
25
25
|
.flatMap((entryPoint) => entryPoints[entryPoint.bundleName].chunks);
|
|
26
26
|
// Find chunks for each ID.
|
|
27
|
-
const asyncChunks = asyncChunkIds
|
|
28
|
-
.map((chunkId) => {
|
|
27
|
+
const asyncChunks = asyncChunkIds.map((chunkId) => {
|
|
29
28
|
const chunk = chunks.find((chunk) => chunk.id === chunkId);
|
|
30
29
|
if (!chunk) {
|
|
31
30
|
throw new Error(`Failed to find chunk (${chunkId}) in set:\n${JSON.stringify(chunks)}`);
|
|
32
31
|
}
|
|
33
32
|
return chunk;
|
|
34
|
-
})
|
|
35
|
-
// All Webpack chunks are dependent on `runtime`, which is never an async
|
|
36
|
-
// entry point, simply ignore this one.
|
|
37
|
-
.filter((chunk) => { var _a; return !!((_a = chunk.names) === null || _a === void 0 ? void 0 : _a.includes('runtime')); });
|
|
33
|
+
});
|
|
38
34
|
// A chunk is considered `initial` only if Webpack already belives it to be initial
|
|
39
35
|
// and the application developer did not mark it async via an extra entry point.
|
|
40
36
|
return chunks.map((chunk) => ({
|
|
@@ -12,6 +12,7 @@ const core_1 = require("@angular-devkit/core");
|
|
|
12
12
|
const path = require("path");
|
|
13
13
|
const textTable = require("text-table");
|
|
14
14
|
const color_1 = require("../../utils/color");
|
|
15
|
+
const stats_1 = require("../configs/stats");
|
|
15
16
|
function formatSize(size) {
|
|
16
17
|
if (size <= 0) {
|
|
17
18
|
return '0 bytes';
|
|
@@ -259,13 +260,7 @@ function createWebpackLoggingCallback(verbose, logger) {
|
|
|
259
260
|
if (verbose) {
|
|
260
261
|
logger.info(stats.toString(config.stats));
|
|
261
262
|
}
|
|
262
|
-
webpackStatsLogger(logger, stats.toJson(
|
|
263
|
-
errors: true,
|
|
264
|
-
warnings: true,
|
|
265
|
-
builtAt: true,
|
|
266
|
-
assets: true,
|
|
267
|
-
chunks: true,
|
|
268
|
-
}), config);
|
|
263
|
+
webpackStatsLogger(logger, stats.toJson(stats_1.getWebpackStatsConfig(false)), config);
|
|
269
264
|
};
|
|
270
265
|
}
|
|
271
266
|
exports.createWebpackLoggingCallback = createWebpackLoggingCallback;
|
package/src/utils/workers.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright Google LLC All Rights Reserved.
|
|
4
|
-
*
|
|
5
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
-
* found in the LICENSE file at https://angular.io/license
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Use CPU count -1 with limit to 7 for workers not to clog the system.
|
|
10
|
-
* Some environments, like CircleCI which use Docker report a number of CPUs by the host and not the count of available.
|
|
11
|
-
* This cause `Error: Call retries were exceeded` errors when trying to use them.
|
|
12
|
-
*
|
|
13
|
-
* See:
|
|
14
|
-
*
|
|
15
|
-
* https://github.com/nodejs/node/issues/28762
|
|
16
|
-
*
|
|
17
|
-
* https://github.com/webpack-contrib/terser-webpack-plugin/issues/143
|
|
18
|
-
*
|
|
19
|
-
* https://github.com/angular/angular-cli/issues/16860#issuecomment-588828079
|
|
20
|
-
*
|
|
21
|
-
*/
|
|
22
|
-
export declare const maxWorkers: number;
|
package/src/utils/workers.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @license
|
|
4
|
-
* Copyright Google LLC All Rights Reserved.
|
|
5
|
-
*
|
|
6
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
-
* found in the LICENSE file at https://angular.io/license
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.maxWorkers = void 0;
|
|
11
|
-
const os_1 = require("os");
|
|
12
|
-
/**
|
|
13
|
-
* Use CPU count -1 with limit to 7 for workers not to clog the system.
|
|
14
|
-
* Some environments, like CircleCI which use Docker report a number of CPUs by the host and not the count of available.
|
|
15
|
-
* This cause `Error: Call retries were exceeded` errors when trying to use them.
|
|
16
|
-
*
|
|
17
|
-
* See:
|
|
18
|
-
*
|
|
19
|
-
* https://github.com/nodejs/node/issues/28762
|
|
20
|
-
*
|
|
21
|
-
* https://github.com/webpack-contrib/terser-webpack-plugin/issues/143
|
|
22
|
-
*
|
|
23
|
-
* https://github.com/angular/angular-cli/issues/16860#issuecomment-588828079
|
|
24
|
-
*
|
|
25
|
-
*/
|
|
26
|
-
exports.maxWorkers = Math.max(Math.min(os_1.cpus().length, 8) - 1, 1);
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright Google LLC All Rights Reserved.
|
|
4
|
-
*
|
|
5
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
-
* found in the LICENSE file at https://angular.io/license
|
|
7
|
-
*/
|
|
8
|
-
import { Compiler } from 'webpack';
|
|
9
|
-
export interface OptimizeCssWebpackPluginOptions {
|
|
10
|
-
sourceMap: boolean;
|
|
11
|
-
test: (file: string) => boolean;
|
|
12
|
-
}
|
|
13
|
-
export declare class OptimizeCssWebpackPlugin {
|
|
14
|
-
private readonly _options;
|
|
15
|
-
constructor(options: Partial<OptimizeCssWebpackPluginOptions>);
|
|
16
|
-
apply(compiler: Compiler): void;
|
|
17
|
-
}
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @license
|
|
4
|
-
* Copyright Google LLC All Rights Reserved.
|
|
5
|
-
*
|
|
6
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
-
* found in the LICENSE file at https://angular.io/license
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.OptimizeCssWebpackPlugin = void 0;
|
|
11
|
-
const cssNano = require("cssnano");
|
|
12
|
-
const webpack_1 = require("webpack");
|
|
13
|
-
const webpack_diagnostics_1 = require("../../utils/webpack-diagnostics");
|
|
14
|
-
const PLUGIN_NAME = 'optimize-css-webpack-plugin';
|
|
15
|
-
function hook(compiler, action) {
|
|
16
|
-
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
17
|
-
compilation.hooks.processAssets.tapPromise({
|
|
18
|
-
name: PLUGIN_NAME,
|
|
19
|
-
stage: webpack_1.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE,
|
|
20
|
-
}, (assets) => action(compilation, Object.keys(assets)));
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
class OptimizeCssWebpackPlugin {
|
|
24
|
-
constructor(options) {
|
|
25
|
-
this._options = {
|
|
26
|
-
sourceMap: false,
|
|
27
|
-
test: (file) => file.endsWith('.css'),
|
|
28
|
-
...options,
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
apply(compiler) {
|
|
32
|
-
hook(compiler, (compilation, assetsURI) => {
|
|
33
|
-
const files = [...compilation.additionalChunkAssets, ...assetsURI];
|
|
34
|
-
const actions = files
|
|
35
|
-
.filter((file) => this._options.test(file))
|
|
36
|
-
.map(async (file) => {
|
|
37
|
-
const asset = compilation.assets[file];
|
|
38
|
-
if (!asset) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
let content;
|
|
42
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
43
|
-
let map;
|
|
44
|
-
if (this._options.sourceMap && asset.sourceAndMap) {
|
|
45
|
-
const sourceAndMap = asset.sourceAndMap({});
|
|
46
|
-
content = sourceAndMap.source;
|
|
47
|
-
map = sourceAndMap.map;
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
content = asset.source();
|
|
51
|
-
}
|
|
52
|
-
if (typeof content !== 'string') {
|
|
53
|
-
content = content.toString();
|
|
54
|
-
}
|
|
55
|
-
if (content.length === 0) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
const cssNanoOptions = {
|
|
59
|
-
preset: [
|
|
60
|
-
'default',
|
|
61
|
-
{
|
|
62
|
-
// Disable SVG optimizations, as this can cause optimizations which are not compatible in all browsers.
|
|
63
|
-
svgo: false,
|
|
64
|
-
// Disable `calc` optimizations, due to several issues. #16910, #16875, #17890
|
|
65
|
-
calc: false,
|
|
66
|
-
// Disable CSS rules sorted due to several issues #20693, https://github.com/ionic-team/ionic-framework/issues/23266 and https://github.com/cssnano/cssnano/issues/1054
|
|
67
|
-
cssDeclarationSorter: false,
|
|
68
|
-
},
|
|
69
|
-
],
|
|
70
|
-
};
|
|
71
|
-
const postCssOptions = {
|
|
72
|
-
from: file,
|
|
73
|
-
map: map && { annotation: false, prev: map },
|
|
74
|
-
};
|
|
75
|
-
try {
|
|
76
|
-
const output = await new Promise((resolve, reject) => {
|
|
77
|
-
// @types/cssnano are not up to date with version 5.
|
|
78
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
79
|
-
cssNano(cssNanoOptions)
|
|
80
|
-
.process(content, postCssOptions)
|
|
81
|
-
.then(resolve)
|
|
82
|
-
.catch((err) => reject(err));
|
|
83
|
-
});
|
|
84
|
-
for (const { text } of output.warnings()) {
|
|
85
|
-
webpack_diagnostics_1.addWarning(compilation, text);
|
|
86
|
-
}
|
|
87
|
-
let newSource;
|
|
88
|
-
if (output.map) {
|
|
89
|
-
newSource = new webpack_1.sources.SourceMapSource(output.css, file, output.map.toString(), content, map);
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
newSource = new webpack_1.sources.RawSource(output.css);
|
|
93
|
-
}
|
|
94
|
-
compilation.assets[file] = newSource;
|
|
95
|
-
}
|
|
96
|
-
catch (error) {
|
|
97
|
-
webpack_diagnostics_1.addError(compilation, error.message);
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
102
|
-
return Promise.all(actions).then(() => { });
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
exports.OptimizeCssWebpackPlugin = OptimizeCssWebpackPlugin;
|