@angular-devkit/build-angular 12.2.11 → 12.2.15
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
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-devkit/build-angular",
|
|
3
|
-
"version": "12.2.
|
|
3
|
+
"version": "12.2.15",
|
|
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
9
|
"@ampproject/remapping": "1.0.1",
|
|
10
|
-
"@angular-devkit/architect": "0.1202.
|
|
11
|
-
"@angular-devkit/build-optimizer": "0.1202.
|
|
12
|
-
"@angular-devkit/build-webpack": "0.1202.
|
|
13
|
-
"@angular-devkit/core": "12.2.
|
|
10
|
+
"@angular-devkit/architect": "0.1202.15",
|
|
11
|
+
"@angular-devkit/build-optimizer": "0.1202.15",
|
|
12
|
+
"@angular-devkit/build-webpack": "0.1202.15",
|
|
13
|
+
"@angular-devkit/core": "12.2.15",
|
|
14
14
|
"@babel/core": "7.14.8",
|
|
15
15
|
"@babel/generator": "7.14.8",
|
|
16
16
|
"@babel/helper-annotate-as-pure": "7.14.5",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"@babel/template": "7.14.5",
|
|
23
23
|
"@discoveryjs/json-ext": "0.5.3",
|
|
24
24
|
"@jsdevtools/coverage-istanbul-loader": "3.0.5",
|
|
25
|
-
"@ngtools/webpack": "12.2.
|
|
25
|
+
"@ngtools/webpack": "12.2.15",
|
|
26
26
|
"ansi-colors": "4.1.1",
|
|
27
27
|
"babel-loader": "8.2.2",
|
|
28
28
|
"browserslist": "^4.9.1",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"circular-dependency-plugin": "5.2.2",
|
|
32
32
|
"copy-webpack-plugin": "9.0.1",
|
|
33
33
|
"core-js": "3.16.0",
|
|
34
|
-
"critters": "0.0.
|
|
34
|
+
"critters": "0.0.12",
|
|
35
35
|
"css-loader": "6.2.0",
|
|
36
36
|
"css-minimizer-webpack-plugin": "3.0.2",
|
|
37
37
|
"esbuild-wasm": "0.13.8",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"tslib": "2.3.0",
|
|
73
73
|
"webpack": "5.50.0",
|
|
74
74
|
"webpack-dev-middleware": "5.0.0",
|
|
75
|
-
"webpack-dev-server": "3.11.
|
|
75
|
+
"webpack-dev-server": "3.11.3",
|
|
76
76
|
"webpack-merge": "5.8.0",
|
|
77
77
|
"webpack-subresource-integrity": "1.5.2"
|
|
78
78
|
},
|
package/src/browser/index.js
CHANGED
|
@@ -131,7 +131,7 @@ function buildWebpackBrowser(options, context, transforms = {}) {
|
|
|
131
131
|
}).pipe(
|
|
132
132
|
// eslint-disable-next-line max-lines-per-function
|
|
133
133
|
operators_1.concatMap(async (buildEvent) => {
|
|
134
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
134
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
135
135
|
const spinner = new spinner_1.Spinner();
|
|
136
136
|
spinner.enabled = options.progress !== false;
|
|
137
137
|
const { success, emittedFiles = [], outputPath: webpackOutputPath } = buildEvent;
|
|
@@ -241,7 +241,7 @@ function buildWebpackBrowser(options, context, transforms = {}) {
|
|
|
241
241
|
if (actionOptions.sourceMaps) {
|
|
242
242
|
try {
|
|
243
243
|
map = fs.readFileSync(filename + '.map', 'utf8');
|
|
244
|
-
if (es5Polyfills) {
|
|
244
|
+
if (es5Polyfills || i18n.shouldInline) {
|
|
245
245
|
fs.unlinkSync(filename + '.map');
|
|
246
246
|
}
|
|
247
247
|
}
|
|
@@ -251,6 +251,11 @@ function buildWebpackBrowser(options, context, transforms = {}) {
|
|
|
251
251
|
fs.unlinkSync(filename);
|
|
252
252
|
filename = filename.replace(/\-es20\d{2}/, '');
|
|
253
253
|
}
|
|
254
|
+
else if (i18n.shouldInline) {
|
|
255
|
+
// Original files must be deleted with i18n to avoid the original files from
|
|
256
|
+
// being copied over the translated files when copying the project assets.
|
|
257
|
+
fs.unlinkSync(filename);
|
|
258
|
+
}
|
|
254
259
|
const es2015Polyfills = file.file.startsWith('polyfills-es20');
|
|
255
260
|
// Record the bundle processing action
|
|
256
261
|
// The runtime chunk gets special processing for lazy loaded files
|
|
@@ -265,6 +270,8 @@ function buildWebpackBrowser(options, context, transforms = {}) {
|
|
|
265
270
|
runtime: file.file.startsWith('runtime'),
|
|
266
271
|
ignoreOriginal: es5Polyfills,
|
|
267
272
|
optimizeOnly: es2015Polyfills,
|
|
273
|
+
// When using i18n, file results are kept in memory for further processing
|
|
274
|
+
memoryMode: i18n.shouldInline,
|
|
268
275
|
});
|
|
269
276
|
// ES2015 polyfills are only optimized; optimization check was performed above
|
|
270
277
|
if (es2015Polyfills) {
|
|
@@ -279,6 +286,9 @@ function buildWebpackBrowser(options, context, transforms = {}) {
|
|
|
279
286
|
const processActions = [];
|
|
280
287
|
let processRuntimeAction;
|
|
281
288
|
for (const action of actions) {
|
|
289
|
+
if (options.verbose) {
|
|
290
|
+
context.logger.info(`[${new Date().toISOString()}] Differential loading file queued: ${action.filename}`);
|
|
291
|
+
}
|
|
282
292
|
// If SRI is enabled always process the runtime bundle
|
|
283
293
|
// Lazy route integrity values are stored in the runtime bundle
|
|
284
294
|
if (action.integrityAlgorithm && action.runtime) {
|
|
@@ -293,6 +303,14 @@ function buildWebpackBrowser(options, context, transforms = {}) {
|
|
|
293
303
|
try {
|
|
294
304
|
spinner.start('Generating ES5 bundles for differential loading...');
|
|
295
305
|
for await (const result of differentialLoadingExecutor.processAll(processActions)) {
|
|
306
|
+
if (options.verbose) {
|
|
307
|
+
if (result.original) {
|
|
308
|
+
context.logger.info(`[${new Date().toISOString()}] Differential loading file processed: ${result.original.filename}`);
|
|
309
|
+
}
|
|
310
|
+
if (result.downlevel) {
|
|
311
|
+
context.logger.info(`[${new Date().toISOString()}] Differential loading file processed: ${result.downlevel.filename}`);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
296
314
|
processResults.push(result);
|
|
297
315
|
}
|
|
298
316
|
}
|
|
@@ -308,51 +326,55 @@ function buildWebpackBrowser(options, context, transforms = {}) {
|
|
|
308
326
|
};
|
|
309
327
|
processResults.push(await Promise.resolve().then(() => __importStar(require('../utils/process-bundle'))).then((m) => m.process(runtimeOptions)));
|
|
310
328
|
}
|
|
329
|
+
if (options.verbose) {
|
|
330
|
+
context.logger.info(`[${new Date().toISOString()}] Differential loading processing complete.`);
|
|
331
|
+
}
|
|
311
332
|
spinner.succeed('ES5 bundle generation complete.');
|
|
312
333
|
if (i18n.shouldInline) {
|
|
313
334
|
spinner.start('Generating localized bundles...');
|
|
314
335
|
const inlineActions = [];
|
|
315
|
-
const processedFiles = new Set();
|
|
316
336
|
for (const result of processResults) {
|
|
317
337
|
if (result.original) {
|
|
338
|
+
if (options.verbose) {
|
|
339
|
+
context.logger.info(`[${new Date().toISOString()}] i18n localize file queued: ${result.original.filename}`);
|
|
340
|
+
}
|
|
318
341
|
inlineActions.push({
|
|
319
342
|
filename: path.basename(result.original.filename),
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
343
|
+
// Memory mode is always enabled for i18n
|
|
344
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
345
|
+
code: result.original.content,
|
|
346
|
+
map: (_a = result.original.map) === null || _a === void 0 ? void 0 : _a.content,
|
|
323
347
|
outputPath: baseOutputPath,
|
|
324
348
|
es5: false,
|
|
325
349
|
missingTranslation: options.i18nMissingTranslation,
|
|
326
350
|
setLocale: result.name === mainChunkId,
|
|
327
351
|
});
|
|
328
|
-
processedFiles.add(result.original.filename);
|
|
329
|
-
if (result.original.map) {
|
|
330
|
-
processedFiles.add(result.original.map.filename);
|
|
331
|
-
}
|
|
332
352
|
}
|
|
333
353
|
if (result.downlevel) {
|
|
354
|
+
if (options.verbose) {
|
|
355
|
+
context.logger.info(`[${new Date().toISOString()}] i18n localize file queued: ${result.downlevel.filename}`);
|
|
356
|
+
}
|
|
334
357
|
inlineActions.push({
|
|
335
358
|
filename: path.basename(result.downlevel.filename),
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
359
|
+
// Memory mode is always enabled for i18n
|
|
360
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
361
|
+
code: result.downlevel.content,
|
|
362
|
+
map: (_b = result.downlevel.map) === null || _b === void 0 ? void 0 : _b.content,
|
|
339
363
|
outputPath: baseOutputPath,
|
|
340
364
|
es5: true,
|
|
341
365
|
missingTranslation: options.i18nMissingTranslation,
|
|
342
366
|
setLocale: result.name === mainChunkId,
|
|
343
367
|
});
|
|
344
|
-
processedFiles.add(result.downlevel.filename);
|
|
345
|
-
if (result.downlevel.map) {
|
|
346
|
-
processedFiles.add(result.downlevel.map.filename);
|
|
347
|
-
}
|
|
348
368
|
}
|
|
349
369
|
}
|
|
350
370
|
let hasErrors = false;
|
|
351
371
|
const i18nExecutor = new action_executor_1.BundleActionExecutor({ i18n }, options.subresourceIntegrity ? 'sha384' : undefined);
|
|
352
372
|
try {
|
|
373
|
+
let localizedCount = 0;
|
|
353
374
|
for await (const result of i18nExecutor.inlineAll(inlineActions)) {
|
|
375
|
+
localizedCount++;
|
|
354
376
|
if (options.verbose) {
|
|
355
|
-
context.logger.info(`Localized "${result.file}" [${result.count} translation(s)].`);
|
|
377
|
+
context.logger.info(`[${new Date().toISOString()}] (${localizedCount}/${inlineActions.length}) Localized "${result.file}" [${result.count} translation(s)].`);
|
|
356
378
|
}
|
|
357
379
|
for (const diagnostic of result.diagnostics) {
|
|
358
380
|
spinner.stop();
|
|
@@ -372,7 +394,6 @@ function buildWebpackBrowser(options, context, transforms = {}) {
|
|
|
372
394
|
glob: '**/*',
|
|
373
395
|
input: webpackOutputPath,
|
|
374
396
|
output: '',
|
|
375
|
-
ignore: [...processedFiles].map((f) => path.relative(webpackOutputPath, f)),
|
|
376
397
|
},
|
|
377
398
|
], Array.from(outputPaths.values()), '');
|
|
378
399
|
}
|
|
@@ -394,7 +415,7 @@ function buildWebpackBrowser(options, context, transforms = {}) {
|
|
|
394
415
|
}
|
|
395
416
|
}
|
|
396
417
|
for (const result of processResults) {
|
|
397
|
-
const chunk = (
|
|
418
|
+
const chunk = (_c = webpackStats.chunks) === null || _c === void 0 ? void 0 : _c.find((chunk) => { var _a; return ((_a = chunk.id) === null || _a === void 0 ? void 0 : _a.toString()) === result.name; });
|
|
398
419
|
if (result.original) {
|
|
399
420
|
bundleInfoStats.push(generateBundleInfoStats(result.original, chunk, 'modern'));
|
|
400
421
|
}
|
|
@@ -402,9 +423,9 @@ function buildWebpackBrowser(options, context, transforms = {}) {
|
|
|
402
423
|
bundleInfoStats.push(generateBundleInfoStats(result.downlevel, chunk, 'legacy'));
|
|
403
424
|
}
|
|
404
425
|
}
|
|
405
|
-
const unprocessedChunks = ((
|
|
426
|
+
const unprocessedChunks = ((_d = webpackStats.chunks) === null || _d === void 0 ? void 0 : _d.filter((chunk) => !processResults.find((result) => { var _a; return ((_a = chunk.id) === null || _a === void 0 ? void 0 : _a.toString()) === result.name; }))) || [];
|
|
406
427
|
for (const chunk of unprocessedChunks) {
|
|
407
|
-
const asset = (
|
|
428
|
+
const asset = (_e = webpackStats.assets) === null || _e === void 0 ? void 0 : _e.find((a) => { var _a; return a.name === ((_a = chunk.files) === null || _a === void 0 ? void 0 : _a[0]); });
|
|
408
429
|
bundleInfoStats.push(stats_1.generateBundleStats({ ...chunk, size: asset === null || asset === void 0 ? void 0 : asset.size }));
|
|
409
430
|
}
|
|
410
431
|
}
|
|
@@ -425,10 +446,10 @@ function buildWebpackBrowser(options, context, transforms = {}) {
|
|
|
425
446
|
for (const { severity, message } of budgetFailures) {
|
|
426
447
|
switch (severity) {
|
|
427
448
|
case bundle_calculator_1.ThresholdSeverity.Warning:
|
|
428
|
-
(
|
|
449
|
+
(_f = webpackStats.warnings) === null || _f === void 0 ? void 0 : _f.push({ message });
|
|
429
450
|
break;
|
|
430
451
|
case bundle_calculator_1.ThresholdSeverity.Error:
|
|
431
|
-
(
|
|
452
|
+
(_g = webpackStats.errors) === null || _g === void 0 ? void 0 : _g.push({ message });
|
|
432
453
|
break;
|
|
433
454
|
default:
|
|
434
455
|
assertNever(severity);
|
|
@@ -438,7 +459,7 @@ function buildWebpackBrowser(options, context, transforms = {}) {
|
|
|
438
459
|
const buildSuccess = success && !stats_1.statsHasErrors(webpackStats);
|
|
439
460
|
if (buildSuccess) {
|
|
440
461
|
// Copy assets
|
|
441
|
-
if (!options.watch && ((
|
|
462
|
+
if (!options.watch && ((_h = options.assets) === null || _h === void 0 ? void 0 : _h.length)) {
|
|
442
463
|
spinner.start('Copying assets...');
|
|
443
464
|
try {
|
|
444
465
|
await copy_assets_1.copyAssets(utils_1.normalizeAssetPatterns(options.assets, root, core_1.normalize(projectRoot), projectSourceRoot === undefined ? undefined : core_1.normalize(projectSourceRoot)), Array.from(outputPaths.values()), context.workspaceRoot);
|
|
@@ -453,8 +474,8 @@ function buildWebpackBrowser(options, context, transforms = {}) {
|
|
|
453
474
|
spinner.start('Generating index html...');
|
|
454
475
|
const WOFFSupportNeeded = !buildBrowserFeatures.isFeatureSupported('woff2');
|
|
455
476
|
const entrypoints = package_chunk_sort_1.generateEntryPoints({
|
|
456
|
-
scripts: (
|
|
457
|
-
styles: (
|
|
477
|
+
scripts: (_j = options.scripts) !== null && _j !== void 0 ? _j : [],
|
|
478
|
+
styles: (_k = options.styles) !== null && _k !== void 0 ? _k : [],
|
|
458
479
|
});
|
|
459
480
|
const indexHtmlGenerator = new index_html_generator_1.IndexHtmlGenerator({
|
|
460
481
|
indexPath: path.join(context.workspaceRoot, webpack_browser_config_1.getIndexInputFile(options.index)),
|
|
@@ -62,13 +62,12 @@ class BundleActionExecutor {
|
|
|
62
62
|
const executions = new Map();
|
|
63
63
|
for (const action of actions) {
|
|
64
64
|
const execution = executor(action);
|
|
65
|
-
executions.set(execution, execution.then((result) =>
|
|
66
|
-
executions.delete(execution);
|
|
67
|
-
return result;
|
|
68
|
-
}));
|
|
65
|
+
executions.set(execution, execution.then((result) => [execution, result]));
|
|
69
66
|
}
|
|
70
67
|
while (executions.size > 0) {
|
|
71
|
-
|
|
68
|
+
const [execution, result] = await Promise.race(executions.values());
|
|
69
|
+
executions.delete(execution);
|
|
70
|
+
yield result;
|
|
72
71
|
}
|
|
73
72
|
}
|
|
74
73
|
stop() {
|
|
@@ -24,6 +24,7 @@ export interface ProcessBundleOptions {
|
|
|
24
24
|
runtimeData?: ProcessBundleResult[];
|
|
25
25
|
replacements?: [string, string][];
|
|
26
26
|
supportedBrowsers?: string[] | Record<string, string>;
|
|
27
|
+
memoryMode?: boolean;
|
|
27
28
|
}
|
|
28
29
|
export interface ProcessBundleResult {
|
|
29
30
|
name: string;
|
|
@@ -35,9 +36,11 @@ export interface ProcessBundleFile {
|
|
|
35
36
|
filename: string;
|
|
36
37
|
size: number;
|
|
37
38
|
integrity?: string;
|
|
39
|
+
content?: string;
|
|
38
40
|
map?: {
|
|
39
41
|
filename: string;
|
|
40
42
|
size: number;
|
|
43
|
+
content?: string;
|
|
41
44
|
};
|
|
42
45
|
}
|
|
43
46
|
export declare const enum CacheKey {
|
|
@@ -134,7 +134,7 @@ async function process(options) {
|
|
|
134
134
|
}
|
|
135
135
|
exports.process = process;
|
|
136
136
|
async function processBundle(options) {
|
|
137
|
-
const { optimize, isOriginal, code, map, downlevelMap, filename: filepath, hiddenSourceMaps, cacheKeys = [], integrityAlgorithm, } = options;
|
|
137
|
+
const { optimize, isOriginal, code, map, downlevelMap, filename: filepath, hiddenSourceMaps, cacheKeys = [], integrityAlgorithm, memoryMode, } = options;
|
|
138
138
|
const filename = path.basename(filepath);
|
|
139
139
|
let resultCode = code;
|
|
140
140
|
let optimizeResult;
|
|
@@ -168,11 +168,15 @@ async function processBundle(options) {
|
|
|
168
168
|
mapContent = map;
|
|
169
169
|
}
|
|
170
170
|
await cachePut(mapContent, cacheKeys[isOriginal ? 1 /* OriginalMap */ : 3 /* DownlevelMap */]);
|
|
171
|
-
|
|
171
|
+
if (!memoryMode) {
|
|
172
|
+
fs.writeFileSync(filepath + '.map', mapContent);
|
|
173
|
+
}
|
|
172
174
|
}
|
|
173
|
-
const fileResult = createFileEntry(filepath, resultCode, mapContent, integrityAlgorithm);
|
|
175
|
+
const fileResult = createFileEntry(filepath, resultCode, mapContent, memoryMode, integrityAlgorithm);
|
|
174
176
|
await cachePut(resultCode, cacheKeys[isOriginal ? 0 /* OriginalCode */ : 2 /* DownlevelCode */], fileResult.integrity);
|
|
175
|
-
|
|
177
|
+
if (!memoryMode) {
|
|
178
|
+
fs.writeFileSync(filepath, resultCode);
|
|
179
|
+
}
|
|
176
180
|
return fileResult;
|
|
177
181
|
}
|
|
178
182
|
async function terserMangle(code, options = {}) {
|
|
@@ -200,16 +204,18 @@ async function terserMangle(code, options = {}) {
|
|
|
200
204
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
201
205
|
return { code: minifyOutput.code, map: minifyOutput.map };
|
|
202
206
|
}
|
|
203
|
-
function createFileEntry(filename, code, map, integrityAlgorithm) {
|
|
207
|
+
function createFileEntry(filename, code, map, memoryMode, integrityAlgorithm) {
|
|
204
208
|
return {
|
|
205
209
|
filename: filename,
|
|
206
210
|
size: Buffer.byteLength(code),
|
|
207
211
|
integrity: integrityAlgorithm && generateIntegrityValue(integrityAlgorithm, code),
|
|
212
|
+
content: memoryMode ? code : undefined,
|
|
208
213
|
map: !map
|
|
209
214
|
? undefined
|
|
210
215
|
: {
|
|
211
216
|
filename: filename + '.map',
|
|
212
217
|
size: Buffer.byteLength(map),
|
|
218
|
+
content: memoryMode ? map : undefined,
|
|
213
219
|
},
|
|
214
220
|
};
|
|
215
221
|
}
|