@angular-devkit/build-angular 13.0.4 → 13.1.0-next.3
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 +37 -37
- package/src/babel/presets/application.d.ts +1 -0
- package/src/babel/webpack-loader.js +9 -0
- package/src/builders/browser/index.js +7 -9
- package/src/builders/dev-server/index.js +31 -6
- package/src/builders/extract-i18n/index.js +1 -4
- package/src/builders/karma/index.d.ts +2 -2
- package/src/builders/karma/index.js +1 -7
- package/src/builders/server/index.js +1 -7
- package/src/utils/build-options.d.ts +1 -2
- package/src/utils/bundle-calculator.d.ts +6 -7
- package/src/utils/bundle-calculator.js +3 -1
- package/src/utils/i18n-inlining.js +18 -2
- package/src/utils/i18n-options.d.ts +16 -10
- package/src/utils/i18n-options.js +45 -34
- package/src/utils/index-file/augment-index-html.d.ts +5 -1
- package/src/utils/index-file/augment-index-html.js +25 -5
- package/src/utils/index.d.ts +0 -1
- package/src/utils/index.js +0 -1
- package/src/utils/normalize-builder-schema.js +2 -0
- package/src/{webpack/configs/worker.d.ts → utils/supported-browsers.d.ts} +1 -3
- package/src/utils/supported-browsers.js +26 -0
- package/src/webpack/configs/common.d.ts +2 -2
- package/src/webpack/configs/common.js +135 -158
- package/src/webpack/configs/dev-server.d.ts +2 -2
- package/src/webpack/configs/dev-server.js +74 -19
- package/src/webpack/configs/index.d.ts +0 -6
- package/src/webpack/configs/index.js +0 -6
- package/src/webpack/configs/styles.d.ts +2 -2
- package/src/webpack/configs/styles.js +2 -4
- package/src/webpack/plugins/index.d.ts +2 -0
- package/src/webpack/plugins/index.js +5 -1
- package/src/webpack/plugins/json-stats-plugin.d.ts +13 -0
- package/src/webpack/plugins/json-stats-plugin.js +54 -0
- package/src/webpack/plugins/named-chunks-plugin.d.ts +17 -0
- package/src/webpack/plugins/named-chunks-plugin.js +49 -0
- package/src/webpack/plugins/progress-plugin.d.ts +11 -0
- package/src/webpack/plugins/progress-plugin.js +38 -0
- package/src/webpack/plugins/transfer-size-plugin.d.ts +12 -0
- package/src/webpack/plugins/transfer-size-plugin.js +47 -0
- package/src/webpack/{configs/browser.d.ts → plugins/typescript.d.ts} +2 -2
- package/src/webpack/{configs → plugins}/typescript.js +5 -24
- package/src/webpack/utils/helpers.d.ts +15 -5
- package/src/webpack/utils/helpers.js +159 -34
- package/src/webpack/utils/stats.d.ts +10 -3
- package/src/webpack/utils/stats.js +112 -35
- package/src/utils/build-browser-features.d.ts +0 -16
- package/src/utils/build-browser-features.js +0 -54
- package/src/webpack/configs/browser.js +0 -81
- package/src/webpack/configs/server.d.ts +0 -14
- package/src/webpack/configs/server.js +0 -73
- package/src/webpack/configs/stats.d.ts +0 -38
- package/src/webpack/configs/stats.js +0 -53
- package/src/webpack/configs/test.d.ts +0 -10
- package/src/webpack/configs/test.js +0 -77
- package/src/webpack/configs/typescript.d.ts +0 -12
- package/src/webpack/configs/worker.js +0 -22
|
@@ -89,7 +89,7 @@ async function getDevServerConfig(wco) {
|
|
|
89
89
|
},
|
|
90
90
|
compress: false,
|
|
91
91
|
static: false,
|
|
92
|
-
|
|
92
|
+
server: getServerConfig(root, wco.buildOptions),
|
|
93
93
|
allowedHosts: getAllowedHostsConfig(wco.buildOptions),
|
|
94
94
|
devMiddleware: {
|
|
95
95
|
publicPath: servePath,
|
|
@@ -139,15 +139,20 @@ exports.buildServePath = buildServePath;
|
|
|
139
139
|
* Private method to enhance a webpack config with SSL configuration.
|
|
140
140
|
* @private
|
|
141
141
|
*/
|
|
142
|
-
function
|
|
142
|
+
function getServerConfig(root, options) {
|
|
143
143
|
const { ssl, sslCert, sslKey } = options;
|
|
144
|
-
if (ssl
|
|
145
|
-
return
|
|
146
|
-
key: (0, path_1.resolve)(root, sslKey),
|
|
147
|
-
cert: (0, path_1.resolve)(root, sslCert),
|
|
148
|
-
};
|
|
144
|
+
if (!ssl) {
|
|
145
|
+
return 'http';
|
|
149
146
|
}
|
|
150
|
-
return
|
|
147
|
+
return {
|
|
148
|
+
type: 'https',
|
|
149
|
+
options: sslCert && sslKey
|
|
150
|
+
? {
|
|
151
|
+
key: (0, path_1.resolve)(root, sslKey),
|
|
152
|
+
cert: (0, path_1.resolve)(root, sslCert),
|
|
153
|
+
}
|
|
154
|
+
: undefined,
|
|
155
|
+
};
|
|
151
156
|
}
|
|
152
157
|
/**
|
|
153
158
|
* Private method to enhance a webpack config with Proxy configuration.
|
|
@@ -158,21 +163,71 @@ async function addProxyConfig(root, proxyConfig) {
|
|
|
158
163
|
return undefined;
|
|
159
164
|
}
|
|
160
165
|
const proxyPath = (0, path_1.resolve)(root, proxyConfig);
|
|
161
|
-
if ((0, fs_1.existsSync)(proxyPath)) {
|
|
162
|
-
|
|
163
|
-
|
|
166
|
+
if (!(0, fs_1.existsSync)(proxyPath)) {
|
|
167
|
+
throw new Error(`Proxy configuration file ${proxyPath} does not exist.`);
|
|
168
|
+
}
|
|
169
|
+
switch ((0, path_1.extname)(proxyPath)) {
|
|
170
|
+
case '.json': {
|
|
171
|
+
const content = await fs_1.promises.readFile(proxyPath, 'utf-8');
|
|
172
|
+
const { parse, printParseErrorCode } = await Promise.resolve().then(() => __importStar(require('jsonc-parser')));
|
|
173
|
+
const parseErrors = [];
|
|
174
|
+
const proxyConfiguration = parse(content, parseErrors, { allowTrailingComma: true });
|
|
175
|
+
if (parseErrors.length > 0) {
|
|
176
|
+
let errorMessage = `Proxy configuration file ${proxyPath} contains parse errors:`;
|
|
177
|
+
for (const parseError of parseErrors) {
|
|
178
|
+
const { line, column } = getJsonErrorLineColumn(parseError.offset, content);
|
|
179
|
+
errorMessage += `\n[${line}, ${column}] ${printParseErrorCode(parseError.error)}`;
|
|
180
|
+
}
|
|
181
|
+
throw new Error(errorMessage);
|
|
182
|
+
}
|
|
183
|
+
return proxyConfiguration;
|
|
164
184
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
185
|
+
case '.mjs':
|
|
186
|
+
// Load the ESM configuration file using the TypeScript dynamic import workaround.
|
|
187
|
+
// Once TypeScript provides support for keeping the dynamic import this workaround can be
|
|
188
|
+
// changed to a direct dynamic import.
|
|
189
|
+
return (await (0, load_esm_1.loadEsmModule)(url.pathToFileURL(proxyPath))).default;
|
|
190
|
+
case '.cjs':
|
|
191
|
+
return require(proxyPath);
|
|
192
|
+
default:
|
|
193
|
+
// The file could be either CommonJS or ESM.
|
|
194
|
+
// CommonJS is tried first then ESM if loading fails.
|
|
195
|
+
try {
|
|
196
|
+
return require(proxyPath);
|
|
171
197
|
}
|
|
172
|
-
|
|
198
|
+
catch (e) {
|
|
199
|
+
if (e.code === 'ERR_REQUIRE_ESM') {
|
|
200
|
+
// Load the ESM configuration file using the TypeScript dynamic import workaround.
|
|
201
|
+
// Once TypeScript provides support for keeping the dynamic import this workaround can be
|
|
202
|
+
// changed to a direct dynamic import.
|
|
203
|
+
return (await (0, load_esm_1.loadEsmModule)(url.pathToFileURL(proxyPath))).default;
|
|
204
|
+
}
|
|
205
|
+
throw e;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Calculates the line and column for an error offset in the content of a JSON file.
|
|
211
|
+
* @param location The offset error location from the beginning of the content.
|
|
212
|
+
* @param content The full content of the file containing the error.
|
|
213
|
+
* @returns An object containing the line and column
|
|
214
|
+
*/
|
|
215
|
+
function getJsonErrorLineColumn(offset, content) {
|
|
216
|
+
if (offset === 0) {
|
|
217
|
+
return { line: 1, column: 1 };
|
|
218
|
+
}
|
|
219
|
+
let line = 0;
|
|
220
|
+
let position = 0;
|
|
221
|
+
// eslint-disable-next-line no-constant-condition
|
|
222
|
+
while (true) {
|
|
223
|
+
++line;
|
|
224
|
+
const nextNewline = content.indexOf('\n', position);
|
|
225
|
+
if (nextNewline === -1 || nextNewline > offset) {
|
|
226
|
+
break;
|
|
173
227
|
}
|
|
228
|
+
position = nextNewline + 1;
|
|
174
229
|
}
|
|
175
|
-
|
|
230
|
+
return { line, column: offset - position + 1 };
|
|
176
231
|
}
|
|
177
232
|
/**
|
|
178
233
|
* Find the default server path. We don't want to expose baseHref and deployUrl as arguments, only
|
|
@@ -6,12 +6,6 @@
|
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
8
|
export * from './analytics';
|
|
9
|
-
export * from './browser';
|
|
10
9
|
export * from './common';
|
|
11
10
|
export * from './dev-server';
|
|
12
|
-
export * from './server';
|
|
13
11
|
export * from './styles';
|
|
14
|
-
export * from './test';
|
|
15
|
-
export * from './typescript';
|
|
16
|
-
export * from './stats';
|
|
17
|
-
export * from './worker';
|
|
@@ -18,12 +18,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
20
|
__exportStar(require("./analytics"), exports);
|
|
21
|
-
__exportStar(require("./browser"), exports);
|
|
22
21
|
__exportStar(require("./common"), exports);
|
|
23
22
|
__exportStar(require("./dev-server"), exports);
|
|
24
|
-
__exportStar(require("./server"), exports);
|
|
25
23
|
__exportStar(require("./styles"), exports);
|
|
26
|
-
__exportStar(require("./test"), exports);
|
|
27
|
-
__exportStar(require("./typescript"), exports);
|
|
28
|
-
__exportStar(require("./stats"), exports);
|
|
29
|
-
__exportStar(require("./worker"), exports);
|
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
|
-
import
|
|
8
|
+
import { Configuration } from 'webpack';
|
|
9
9
|
import { WebpackConfigOptions } from '../../utils/build-options';
|
|
10
|
-
export declare function getStylesConfig(wco: WebpackConfigOptions):
|
|
10
|
+
export declare function getStylesConfig(wco: WebpackConfigOptions): Configuration;
|
|
@@ -30,7 +30,6 @@ exports.getStylesConfig = void 0;
|
|
|
30
30
|
const fs = __importStar(require("fs"));
|
|
31
31
|
const path = __importStar(require("path"));
|
|
32
32
|
const sass_service_1 = require("../../sass/sass-service");
|
|
33
|
-
const build_browser_features_1 = require("../../utils/build-browser-features");
|
|
34
33
|
const plugins_1 = require("../plugins");
|
|
35
34
|
const css_optimizer_plugin_1 = require("../plugins/css-optimizer-plugin");
|
|
36
35
|
const helpers_1 = require("../utils/helpers");
|
|
@@ -134,9 +133,8 @@ function getStylesConfig(wco) {
|
|
|
134
133
|
extraPostcssPlugins.push(require(tailwindPackagePath)({ config: tailwindConfigPath }));
|
|
135
134
|
}
|
|
136
135
|
}
|
|
137
|
-
const { supportedBrowsers } = new build_browser_features_1.BuildBrowserFeatures(wco.projectRoot);
|
|
138
136
|
const postcssPresetEnvPlugin = postcssPresetEnv({
|
|
139
|
-
browsers: supportedBrowsers,
|
|
137
|
+
browsers: buildOptions.supportedBrowsers,
|
|
140
138
|
autoprefixer: true,
|
|
141
139
|
stage: 3,
|
|
142
140
|
});
|
|
@@ -361,7 +359,7 @@ function getStylesConfig(wco) {
|
|
|
361
359
|
minimizer: buildOptions.optimization.styles.minify
|
|
362
360
|
? [
|
|
363
361
|
new css_optimizer_plugin_1.CssOptimizerPlugin({
|
|
364
|
-
supportedBrowsers,
|
|
362
|
+
supportedBrowsers: buildOptions.supportedBrowsers,
|
|
365
363
|
}),
|
|
366
364
|
]
|
|
367
365
|
: undefined,
|
|
@@ -11,4 +11,6 @@ export { SuppressExtractedTextChunksWebpackPlugin } from './suppress-entry-chunk
|
|
|
11
11
|
export { RemoveHashPlugin, RemoveHashPluginOptions } from './remove-hash-plugin';
|
|
12
12
|
export { DedupeModuleResolvePlugin } from './dedupe-module-resolve-plugin';
|
|
13
13
|
export { CommonJsUsageWarnPlugin } from './common-js-usage-warn-plugin';
|
|
14
|
+
export { JsonStatsPlugin } from './json-stats-plugin';
|
|
15
|
+
export { JavaScriptOptimizerPlugin } from './javascript-optimizer-plugin';
|
|
14
16
|
export { default as PostcssCliResources, PostcssCliResourcesOptions, } from './postcss-cli-resources';
|
|
@@ -10,7 +10,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
10
10
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.PostcssCliResources = exports.CommonJsUsageWarnPlugin = exports.DedupeModuleResolvePlugin = exports.RemoveHashPlugin = exports.SuppressExtractedTextChunksWebpackPlugin = exports.ScriptsWebpackPlugin = exports.AnyComponentStyleBudgetChecker = void 0;
|
|
13
|
+
exports.PostcssCliResources = exports.JavaScriptOptimizerPlugin = exports.JsonStatsPlugin = exports.CommonJsUsageWarnPlugin = exports.DedupeModuleResolvePlugin = exports.RemoveHashPlugin = exports.SuppressExtractedTextChunksWebpackPlugin = exports.ScriptsWebpackPlugin = exports.AnyComponentStyleBudgetChecker = void 0;
|
|
14
14
|
// Exports the webpack plugins we use internally.
|
|
15
15
|
var any_component_style_budget_checker_1 = require("./any-component-style-budget-checker");
|
|
16
16
|
Object.defineProperty(exports, "AnyComponentStyleBudgetChecker", { enumerable: true, get: function () { return any_component_style_budget_checker_1.AnyComponentStyleBudgetChecker; } });
|
|
@@ -24,5 +24,9 @@ var dedupe_module_resolve_plugin_1 = require("./dedupe-module-resolve-plugin");
|
|
|
24
24
|
Object.defineProperty(exports, "DedupeModuleResolvePlugin", { enumerable: true, get: function () { return dedupe_module_resolve_plugin_1.DedupeModuleResolvePlugin; } });
|
|
25
25
|
var common_js_usage_warn_plugin_1 = require("./common-js-usage-warn-plugin");
|
|
26
26
|
Object.defineProperty(exports, "CommonJsUsageWarnPlugin", { enumerable: true, get: function () { return common_js_usage_warn_plugin_1.CommonJsUsageWarnPlugin; } });
|
|
27
|
+
var json_stats_plugin_1 = require("./json-stats-plugin");
|
|
28
|
+
Object.defineProperty(exports, "JsonStatsPlugin", { enumerable: true, get: function () { return json_stats_plugin_1.JsonStatsPlugin; } });
|
|
29
|
+
var javascript_optimizer_plugin_1 = require("./javascript-optimizer-plugin");
|
|
30
|
+
Object.defineProperty(exports, "JavaScriptOptimizerPlugin", { enumerable: true, get: function () { return javascript_optimizer_plugin_1.JavaScriptOptimizerPlugin; } });
|
|
27
31
|
var postcss_cli_resources_1 = require("./postcss-cli-resources");
|
|
28
32
|
Object.defineProperty(exports, "PostcssCliResources", { enumerable: true, get: function () { return __importDefault(postcss_cli_resources_1).default; } });
|
|
@@ -0,0 +1,13 @@
|
|
|
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 declare class JsonStatsPlugin {
|
|
10
|
+
private readonly statsOutputPath;
|
|
11
|
+
constructor(statsOutputPath: string);
|
|
12
|
+
apply(compiler: Compiler): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
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
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.JsonStatsPlugin = void 0;
|
|
30
|
+
const fs_1 = require("fs");
|
|
31
|
+
const path_1 = require("path");
|
|
32
|
+
const webpack_diagnostics_1 = require("../../utils/webpack-diagnostics");
|
|
33
|
+
class JsonStatsPlugin {
|
|
34
|
+
constructor(statsOutputPath) {
|
|
35
|
+
this.statsOutputPath = statsOutputPath;
|
|
36
|
+
}
|
|
37
|
+
apply(compiler) {
|
|
38
|
+
compiler.hooks.done.tapPromise('angular-json-stats', async (stats) => {
|
|
39
|
+
const { stringifyStream } = await Promise.resolve().then(() => __importStar(require('@discoveryjs/json-ext')));
|
|
40
|
+
const data = stats.toJson('verbose');
|
|
41
|
+
try {
|
|
42
|
+
await fs_1.promises.mkdir((0, path_1.dirname)(this.statsOutputPath), { recursive: true });
|
|
43
|
+
await new Promise((resolve, reject) => stringifyStream(data)
|
|
44
|
+
.pipe((0, fs_1.createWriteStream)(this.statsOutputPath))
|
|
45
|
+
.on('close', resolve)
|
|
46
|
+
.on('error', reject));
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
(0, webpack_diagnostics_1.addError)(stats.compilation, `Unable to write stats file: ${error.message || 'unknown error'}`);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.JsonStatsPlugin = JsonStatsPlugin;
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
/**
|
|
10
|
+
* Webpack will not populate the chunk `name` property unless `webpackChunkName` magic comment is used.
|
|
11
|
+
* This however will also effect the filename which is not desired when using `deterministic` chunkIds.
|
|
12
|
+
* This plugin will populate the chunk `name` which is mainly used so that users can set bundle budgets on lazy chunks.
|
|
13
|
+
*/
|
|
14
|
+
export declare class NamedChunksPlugin {
|
|
15
|
+
apply(compiler: Compiler): void;
|
|
16
|
+
private generateName;
|
|
17
|
+
}
|
|
@@ -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
|
+
exports.NamedChunksPlugin = void 0;
|
|
11
|
+
const webpack_1 = require("webpack");
|
|
12
|
+
// `ImportDependency` is not part of Webpack's depenencies typings.
|
|
13
|
+
const ImportDependency = require('webpack/lib/dependencies/ImportDependency');
|
|
14
|
+
const PLUGIN_NAME = 'named-chunks-plugin';
|
|
15
|
+
/**
|
|
16
|
+
* Webpack will not populate the chunk `name` property unless `webpackChunkName` magic comment is used.
|
|
17
|
+
* This however will also effect the filename which is not desired when using `deterministic` chunkIds.
|
|
18
|
+
* This plugin will populate the chunk `name` which is mainly used so that users can set bundle budgets on lazy chunks.
|
|
19
|
+
*/
|
|
20
|
+
class NamedChunksPlugin {
|
|
21
|
+
apply(compiler) {
|
|
22
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
23
|
+
compilation.hooks.chunkAsset.tap(PLUGIN_NAME, (chunk) => {
|
|
24
|
+
if (chunk.name) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const name = this.generateName(chunk);
|
|
28
|
+
if (name) {
|
|
29
|
+
chunk.name = name;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
generateName(chunk) {
|
|
35
|
+
for (const group of chunk.groupsIterable) {
|
|
36
|
+
const [block] = group.getBlocks();
|
|
37
|
+
if (!(block instanceof webpack_1.AsyncDependenciesBlock)) {
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
for (const dependency of block.dependencies) {
|
|
41
|
+
if (dependency instanceof ImportDependency) {
|
|
42
|
+
return webpack_1.Template.toPath(dependency.request);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.NamedChunksPlugin = NamedChunksPlugin;
|
|
@@ -0,0 +1,11 @@
|
|
|
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 { ProgressPlugin as WebpackProgressPlugin } from 'webpack';
|
|
9
|
+
export declare class ProgressPlugin extends WebpackProgressPlugin {
|
|
10
|
+
constructor(platform: 'server' | 'browser');
|
|
11
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
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.ProgressPlugin = void 0;
|
|
11
|
+
const webpack_1 = require("webpack");
|
|
12
|
+
const spinner_1 = require("../../utils/spinner");
|
|
13
|
+
class ProgressPlugin extends webpack_1.ProgressPlugin {
|
|
14
|
+
constructor(platform) {
|
|
15
|
+
const platformCapitalFirst = platform.replace(/^\w/, (s) => s.toUpperCase());
|
|
16
|
+
const spinner = new spinner_1.Spinner();
|
|
17
|
+
spinner.start(`Generating ${platform} application bundles (phase: setup)...`);
|
|
18
|
+
super({
|
|
19
|
+
handler: (percentage, message) => {
|
|
20
|
+
const phase = message ? ` (phase: ${message})` : '';
|
|
21
|
+
spinner.text = `Generating ${platform} application bundles${phase}...`;
|
|
22
|
+
switch (percentage) {
|
|
23
|
+
case 1:
|
|
24
|
+
if (spinner.isSpinning) {
|
|
25
|
+
spinner.succeed(`${platformCapitalFirst} application bundle generation complete.`);
|
|
26
|
+
}
|
|
27
|
+
break;
|
|
28
|
+
case 0:
|
|
29
|
+
if (!spinner.isSpinning) {
|
|
30
|
+
spinner.start();
|
|
31
|
+
}
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.ProgressPlugin = ProgressPlugin;
|
|
@@ -0,0 +1,12 @@
|
|
|
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 declare class TransferSizePlugin {
|
|
10
|
+
constructor();
|
|
11
|
+
apply(compiler: Compiler): void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
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.TransferSizePlugin = void 0;
|
|
11
|
+
const util_1 = require("util");
|
|
12
|
+
const zlib_1 = require("zlib");
|
|
13
|
+
const brotliCompressAsync = (0, util_1.promisify)(zlib_1.brotliCompress);
|
|
14
|
+
const PLUGIN_NAME = 'angular-transfer-size-estimator';
|
|
15
|
+
class TransferSizePlugin {
|
|
16
|
+
constructor() { }
|
|
17
|
+
apply(compiler) {
|
|
18
|
+
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
|
|
19
|
+
compilation.hooks.processAssets.tapPromise({
|
|
20
|
+
name: PLUGIN_NAME,
|
|
21
|
+
stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_ANALYSE,
|
|
22
|
+
}, async (compilationAssets) => {
|
|
23
|
+
const actions = [];
|
|
24
|
+
for (const assetName of Object.keys(compilationAssets)) {
|
|
25
|
+
if (!assetName.endsWith('.js') && !assetName.endsWith('.css')) {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
const scriptAsset = compilation.getAsset(assetName);
|
|
29
|
+
if (!scriptAsset || scriptAsset.source.size() <= 0) {
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
actions.push(brotliCompressAsync(scriptAsset.source.source())
|
|
33
|
+
.then((result) => {
|
|
34
|
+
compilation.updateAsset(assetName, (s) => s, {
|
|
35
|
+
estimatedTransferSize: result.length,
|
|
36
|
+
});
|
|
37
|
+
})
|
|
38
|
+
.catch((error) => {
|
|
39
|
+
compilation.warnings.push(new compilation.compiler.webpack.WebpackError(`Unable to calculate estimated transfer size for '${assetName}'. Reason: ${error.message}`));
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
await Promise.all(actions);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.TransferSizePlugin = TransferSizePlugin;
|
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
|
-
import
|
|
8
|
+
import { AngularWebpackPlugin } from '@ngtools/webpack';
|
|
9
9
|
import { WebpackConfigOptions } from '../../utils/build-options';
|
|
10
|
-
export declare function
|
|
10
|
+
export declare function createIvyPlugin(wco: WebpackConfigOptions, aot: boolean, tsconfig: string): AngularWebpackPlugin;
|
|
@@ -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.
|
|
10
|
+
exports.createIvyPlugin = void 0;
|
|
11
11
|
const core_1 = require("@angular-devkit/core");
|
|
12
12
|
const webpack_1 = require("@ngtools/webpack");
|
|
13
13
|
const typescript_1 = require("typescript");
|
|
@@ -22,6 +22,9 @@ function ensureIvy(wco) {
|
|
|
22
22
|
wco.tsConfig.options.enableIvy = true;
|
|
23
23
|
}
|
|
24
24
|
function createIvyPlugin(wco, aot, tsconfig) {
|
|
25
|
+
if (aot) {
|
|
26
|
+
ensureIvy(wco);
|
|
27
|
+
}
|
|
25
28
|
const { buildOptions } = wco;
|
|
26
29
|
const optimize = buildOptions.optimization.scripts;
|
|
27
30
|
const compilerOptions = {
|
|
@@ -69,26 +72,4 @@ function createIvyPlugin(wco, aot, tsconfig) {
|
|
|
69
72
|
inlineStyleFileExtension,
|
|
70
73
|
});
|
|
71
74
|
}
|
|
72
|
-
|
|
73
|
-
const { buildOptions: { aot = false, main, polyfills }, tsConfigPath, } = wco;
|
|
74
|
-
if (main || polyfills) {
|
|
75
|
-
ensureIvy(wco);
|
|
76
|
-
return {
|
|
77
|
-
module: {
|
|
78
|
-
rules: [
|
|
79
|
-
{
|
|
80
|
-
test: /\.[jt]sx?$/,
|
|
81
|
-
loader: webpack_1.AngularWebpackLoaderPath,
|
|
82
|
-
},
|
|
83
|
-
],
|
|
84
|
-
},
|
|
85
|
-
plugins: [createIvyPlugin(wco, aot, tsConfigPath)],
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
return {};
|
|
89
|
-
}
|
|
90
|
-
exports.getTypeScriptConfig = getTypeScriptConfig;
|
|
91
|
-
function getTypescriptWorkerPlugin(wco, workerTsConfigPath) {
|
|
92
|
-
return createIvyPlugin(wco, false, workerTsConfigPath);
|
|
93
|
-
}
|
|
94
|
-
exports.getTypescriptWorkerPlugin = getTypescriptWorkerPlugin;
|
|
75
|
+
exports.createIvyPlugin = createIvyPlugin;
|
|
@@ -5,8 +5,10 @@
|
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import type { ObjectPattern } from 'copy-webpack-plugin';
|
|
9
|
+
import type { Configuration, WebpackOptionsNormalized } from 'webpack';
|
|
10
|
+
import { AssetPatternClass, ExtraEntryPoint, ExtraEntryPointClass } from '../../builders/browser/schema';
|
|
11
|
+
import { WebpackConfigOptions } from '../../utils/build-options';
|
|
10
12
|
export interface HashFormat {
|
|
11
13
|
chunk: string;
|
|
12
14
|
extract: string;
|
|
@@ -16,8 +18,16 @@ export interface HashFormat {
|
|
|
16
18
|
export declare function getOutputHashFormat(option: string, length?: number): HashFormat;
|
|
17
19
|
export declare type NormalizedEntryPoint = Required<ExtraEntryPointClass>;
|
|
18
20
|
export declare function normalizeExtraEntryPoints(extraEntryPoints: ExtraEntryPoint[], defaultBundleName: string): NormalizedEntryPoint[];
|
|
19
|
-
export declare function getSourceMapDevTool(scriptsSourceMap: boolean | undefined, stylesSourceMap: boolean | undefined, hiddenSourceMap?: boolean, inlineSourceMap?: boolean): SourceMapDevToolPlugin;
|
|
20
|
-
export declare function isPolyfillsEntry(name: string): boolean;
|
|
21
|
-
export declare function getWatchOptions(poll: number | undefined): NonNullable<Configuration['watchOptions']>;
|
|
22
21
|
export declare function assetNameTemplateFactory(hashFormat: HashFormat): (resourcePath: string) => string;
|
|
23
22
|
export declare function getInstrumentationExcludedPaths(sourceRoot: string, excludedPaths: string[]): Set<string>;
|
|
23
|
+
export declare function getCacheSettings(wco: WebpackConfigOptions, angularVersion: string): WebpackOptionsNormalized['cache'];
|
|
24
|
+
export declare function globalScriptsByBundleName(root: string, scripts: ExtraEntryPoint[]): {
|
|
25
|
+
bundleName: string;
|
|
26
|
+
inject: boolean;
|
|
27
|
+
paths: string[];
|
|
28
|
+
}[];
|
|
29
|
+
export declare function assetPatterns(root: string, assets: AssetPatternClass[]): ObjectPattern[];
|
|
30
|
+
export declare function externalizePackages(context: string, request: string | undefined, callback: (error?: Error, result?: string) => void): void;
|
|
31
|
+
declare type WebpackStatsOptions = Exclude<Configuration['stats'], string | boolean>;
|
|
32
|
+
export declare function getStatsOptions(verbose?: boolean): WebpackStatsOptions;
|
|
33
|
+
export {};
|