@angular-devkit/build-angular 12.0.0-rc.0 → 12.0.0
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/README.md +14 -13
- package/package.json +24 -24
- package/plugins/karma.d.ts +1 -1
- package/plugins/karma.js +1 -1
- package/src/app-shell/index.d.ts +7 -0
- package/src/app-shell/index.js +9 -7
- package/src/app-shell/schema.json +1 -4
- package/src/babel/babel-loader.d.ts +2 -1
- package/src/babel/presets/application.d.ts +7 -0
- package/src/babel/presets/application.js +3 -3
- package/src/babel/webpack-loader.d.ts +7 -0
- package/src/babel/webpack-loader.js +6 -5
- package/src/babel-bazel.d.ts +2 -1
- package/src/browser/index.d.ts +1 -1
- package/src/browser/index.js +34 -33
- package/src/browser/schema.d.ts +1 -5
- package/src/browser/schema.json +11 -57
- package/src/browser/tests/setup.d.ts +1 -1
- package/src/browser/tests/setup.js +7 -0
- package/src/dev-server/index.d.ts +1 -1
- package/src/dev-server/index.js +22 -15
- package/src/dev-server/schema.json +1 -3
- package/src/dev-server/tests/execute-fetch.d.ts +1 -1
- package/src/dev-server/tests/execute-fetch.js +4 -4
- package/src/dev-server/tests/setup.d.ts +7 -0
- package/src/dev-server/tests/setup.js +7 -0
- package/src/extract-i18n/index.d.ts +1 -1
- package/src/extract-i18n/index.js +10 -12
- package/src/extract-i18n/ivy-extract-loader.d.ts +7 -0
- package/src/extract-i18n/ivy-extract-loader.js +7 -6
- package/src/extract-i18n/schema.json +2 -14
- package/src/index.d.ts +6 -6
- package/src/index.js +1 -1
- package/src/karma/find-tests.d.ts +7 -0
- package/src/karma/find-tests.js +4 -4
- package/src/karma/index.d.ts +1 -1
- package/src/karma/index.js +21 -13
- package/src/karma/schema.json +7 -28
- package/src/ng-packagr/index.d.ts +1 -1
- package/src/ng-packagr/index.js +4 -4
- package/src/ng-packagr/schema.json +1 -3
- package/src/protractor/index.d.ts +1 -1
- package/src/protractor/index.js +8 -8
- package/src/protractor/schema.json +1 -3
- package/src/server/index.d.ts +1 -1
- package/src/server/index.js +6 -6
- package/src/server/schema.d.ts +1 -5
- package/src/server/schema.json +7 -35
- package/src/test-utils.d.ts +1 -1
- package/src/test-utils.js +4 -4
- package/src/testing/builder-harness.d.ts +2 -2
- package/src/testing/builder-harness.js +10 -8
- package/src/testing/file-watching.d.ts +1 -1
- package/src/testing/file-watching.js +7 -0
- package/src/testing/index.d.ts +1 -1
- package/src/testing/index.js +7 -0
- package/src/testing/jasmine-helpers.d.ts +2 -2
- package/src/testing/jasmine-helpers.js +7 -0
- package/src/transforms.d.ts +1 -1
- package/src/transforms.js +7 -0
- package/src/tslint/index.d.ts +7 -0
- package/src/tslint/index.js +10 -12
- package/src/tslint/schema.json +1 -1
- package/src/typings.d.ts +2 -1
- package/src/utils/action-cache.d.ts +7 -0
- package/src/utils/action-cache.js +6 -8
- package/src/utils/action-executor.d.ts +7 -0
- package/src/utils/action-executor.js +13 -28
- package/src/utils/build-browser-features.d.ts +1 -1
- package/src/utils/build-browser-features.js +3 -7
- package/src/utils/build-options.d.ts +1 -2
- package/src/utils/build-options.js +1 -1
- package/src/utils/bundle-calculator.d.ts +7 -0
- package/src/utils/bundle-calculator.js +32 -31
- package/src/utils/cache-path.d.ts +7 -0
- package/src/utils/cache-path.js +3 -3
- package/src/utils/check-port.d.ts +7 -0
- package/src/utils/check-port.js +4 -4
- package/src/utils/color.d.ts +1 -1
- package/src/utils/color.js +3 -3
- package/src/utils/copy-assets.d.ts +7 -0
- package/src/utils/copy-assets.js +3 -3
- package/src/utils/copy-file.d.ts +2 -2
- package/src/utils/copy-file.js +4 -4
- package/src/utils/default-progress.d.ts +1 -1
- package/src/utils/default-progress.js +1 -1
- package/src/utils/delete-output-dir.d.ts +7 -0
- package/src/utils/delete-output-dir.js +3 -3
- package/src/utils/empty.js +0 -1
- package/src/utils/environment-options.d.ts +7 -0
- package/src/utils/environment-options.js +3 -3
- package/src/utils/find-up.d.ts +7 -0
- package/src/utils/find-up.js +3 -3
- package/src/utils/i18n-inlining.d.ts +1 -1
- package/src/utils/i18n-inlining.js +8 -1
- package/src/utils/i18n-options.d.ts +1 -1
- package/src/utils/i18n-options.js +11 -3
- package/src/utils/index-file/augment-index-html.d.ts +1 -1
- package/src/utils/index-file/augment-index-html.js +6 -11
- package/src/utils/index-file/html-rewriting-stream.d.ts +1 -1
- package/src/utils/index-file/html-rewriting-stream.js +2 -2
- package/src/utils/index-file/index-html-generator.d.ts +1 -1
- package/src/utils/index-file/index-html-generator.js +7 -11
- package/src/utils/index-file/inline-critical-css.d.ts +1 -1
- package/src/utils/index-file/inline-critical-css.js +1 -1
- package/src/utils/index-file/inline-fonts.d.ts +1 -1
- package/src/utils/index-file/inline-fonts.js +18 -19
- package/src/utils/index.d.ts +1 -1
- package/src/utils/index.js +1 -1
- package/src/utils/is-directory.d.ts +1 -1
- package/src/utils/is-directory.js +2 -3
- package/src/utils/load-translations.d.ts +7 -0
- package/src/utils/load-translations.js +9 -19
- package/src/utils/normalize-asset-patterns.d.ts +1 -1
- package/src/utils/normalize-asset-patterns.js +6 -7
- package/src/utils/normalize-builder-schema.d.ts +1 -1
- package/src/utils/normalize-builder-schema.js +5 -6
- package/src/utils/normalize-file-replacements.d.ts +1 -1
- package/src/utils/normalize-file-replacements.js +2 -3
- package/src/utils/normalize-optimization.d.ts +1 -1
- package/src/utils/normalize-optimization.js +12 -8
- package/src/utils/normalize-source-maps.d.ts +1 -1
- package/src/utils/normalize-source-maps.js +3 -3
- package/src/utils/output-paths.d.ts +7 -0
- package/src/utils/output-paths.js +7 -4
- package/src/utils/package-chunk-sort.d.ts +1 -1
- package/src/utils/package-chunk-sort.js +10 -3
- package/src/utils/process-bundle-bootstrap.js +3 -2
- package/src/utils/process-bundle.d.ts +2 -2
- package/src/utils/process-bundle.js +31 -40
- package/src/utils/read-tsconfig.d.ts +1 -1
- package/src/utils/read-tsconfig.js +2 -4
- package/src/utils/run-module-as-observable-fork.d.ts +1 -1
- package/src/utils/run-module-as-observable-fork.js +9 -2
- package/src/utils/run-module-worker.js +1 -3
- package/src/utils/service-worker.d.ts +1 -1
- package/src/utils/service-worker.js +3 -3
- package/src/utils/spinner.d.ts +1 -1
- package/src/utils/spinner.js +1 -1
- package/src/utils/strip-bom.d.ts +1 -1
- package/src/utils/strip-bom.js +2 -3
- package/src/utils/tty.d.ts +1 -1
- package/src/utils/tty.js +1 -1
- package/src/utils/url.d.ts +1 -1
- package/src/utils/url.js +1 -1
- package/src/utils/version.d.ts +1 -1
- package/src/utils/version.js +3 -3
- package/src/utils/webpack-browser-config.d.ts +1 -1
- package/src/utils/webpack-browser-config.js +9 -2
- package/src/utils/webpack-diagnostics.d.ts +2 -2
- package/src/utils/webpack-diagnostics.js +4 -4
- package/src/utils/workers.d.ts +1 -1
- package/src/utils/workers.js +1 -1
- package/src/webpack/configs/browser.d.ts +7 -0
- package/src/webpack/configs/browser.js +3 -3
- package/src/webpack/configs/common.d.ts +7 -0
- package/src/webpack/configs/common.js +16 -19
- package/src/webpack/configs/dev-server.d.ts +1 -1
- package/src/webpack/configs/dev-server.js +7 -6
- package/src/webpack/configs/index.d.ts +1 -1
- package/src/webpack/configs/index.js +7 -7
- package/src/webpack/configs/server.d.ts +7 -0
- package/src/webpack/configs/server.js +4 -4
- package/src/webpack/configs/stats.d.ts +1 -1
- package/src/webpack/configs/stats.js +1 -1
- package/src/webpack/configs/styles.d.ts +7 -0
- package/src/webpack/configs/styles.js +6 -10
- package/src/webpack/configs/test.d.ts +1 -1
- package/src/webpack/configs/test.js +2 -5
- package/src/webpack/configs/typescript.d.ts +7 -0
- package/src/webpack/configs/typescript.js +4 -6
- package/src/webpack/configs/worker.d.ts +7 -0
- package/src/webpack/configs/worker.js +3 -3
- package/src/webpack/es5-jit-polyfills.js +2 -1
- package/src/webpack/es5-polyfills.js +2 -3
- package/src/webpack/jit-polyfills.js +2 -1
- package/src/webpack/plugins/analytics.d.ts +2 -2
- package/src/webpack/plugins/analytics.js +9 -9
- package/src/webpack/plugins/any-component-style-budget-checker.d.ts +1 -1
- package/src/webpack/plugins/any-component-style-budget-checker.js +3 -9
- package/src/webpack/plugins/builder-watch-plugin.d.ts +1 -1
- package/src/webpack/plugins/builder-watch-plugin.js +7 -0
- package/src/webpack/plugins/common-js-usage-warn-plugin.d.ts +1 -1
- package/src/webpack/plugins/common-js-usage-warn-plugin.js +10 -10
- package/src/webpack/plugins/dedupe-module-resolve-plugin.d.ts +1 -1
- package/src/webpack/plugins/dedupe-module-resolve-plugin.js +9 -2
- package/src/webpack/plugins/hmr/hmr-accept.d.ts +1 -1
- package/src/webpack/plugins/hmr/hmr-accept.js +6 -9
- package/src/webpack/plugins/hmr/hmr-loader.d.ts +1 -1
- package/src/webpack/plugins/hmr/hmr-loader.js +2 -2
- package/src/webpack/plugins/index-html-webpack-plugin.d.ts +7 -0
- package/src/webpack/plugins/index-html-webpack-plugin.js +6 -6
- package/src/webpack/plugins/index.d.ts +2 -2
- package/src/webpack/plugins/index.js +1 -1
- package/src/webpack/plugins/karma/karma-context.html +31 -30
- package/src/webpack/plugins/karma/karma-debug.html +34 -33
- package/src/webpack/plugins/karma/karma.d.ts +7 -0
- package/src/webpack/plugins/karma/karma.js +13 -11
- package/src/webpack/plugins/optimize-css-webpack-plugin.d.ts +7 -0
- package/src/webpack/plugins/optimize-css-webpack-plugin.js +18 -11
- package/src/webpack/plugins/postcss-cli-resources.d.ts +7 -0
- package/src/webpack/plugins/postcss-cli-resources.js +11 -9
- package/src/webpack/plugins/remove-hash-plugin.d.ts +1 -1
- package/src/webpack/plugins/remove-hash-plugin.js +9 -4
- package/src/webpack/plugins/scripts-webpack-plugin.d.ts +1 -1
- package/src/webpack/plugins/scripts-webpack-plugin.js +11 -10
- package/src/webpack/plugins/single-test-transform.d.ts +1 -1
- package/src/webpack/plugins/single-test-transform.js +5 -5
- package/src/webpack/plugins/suppress-entry-chunks-webpack-plugin.d.ts +1 -1
- package/src/webpack/plugins/suppress-entry-chunks-webpack-plugin.js +1 -1
- package/src/webpack/utils/async-chunks.d.ts +1 -1
- package/src/webpack/utils/async-chunks.js +9 -1
- package/src/webpack/utils/helpers.d.ts +1 -1
- package/src/webpack/utils/helpers.js +2 -2
- package/src/webpack/utils/stats.d.ts +1 -1
- package/src/webpack/utils/stats.js +39 -33
package/src/tslint/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
2
|
/**
|
|
4
3
|
* @license
|
|
5
|
-
* Copyright Google
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
6
5
|
*
|
|
7
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
8
7
|
* found in the LICENSE file at https://angular.io/license
|
|
9
8
|
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
const architect_1 = require("@angular-devkit/architect");
|
|
11
11
|
const fs_1 = require("fs");
|
|
12
12
|
const glob = require("glob");
|
|
@@ -43,7 +43,7 @@ async function _run(options, context) {
|
|
|
43
43
|
if (options.tsConfig) {
|
|
44
44
|
const tsConfigs = Array.isArray(options.tsConfig) ? options.tsConfig : [options.tsConfig];
|
|
45
45
|
context.reportProgress(0, tsConfigs.length);
|
|
46
|
-
const allPrograms = tsConfigs.map(tsConfig => {
|
|
46
|
+
const allPrograms = tsConfigs.map((tsConfig) => {
|
|
47
47
|
return Linter.createProgram(path.resolve(systemRoot, tsConfig));
|
|
48
48
|
});
|
|
49
49
|
let i = 0;
|
|
@@ -54,8 +54,8 @@ async function _run(options, context) {
|
|
|
54
54
|
}
|
|
55
55
|
else {
|
|
56
56
|
result.failures = result.failures
|
|
57
|
-
.filter(curr => {
|
|
58
|
-
return !partial.failures.some(prev => curr.equals(prev));
|
|
57
|
+
.filter((curr) => {
|
|
58
|
+
return !partial.failures.some((prev) => curr.equals(prev));
|
|
59
59
|
})
|
|
60
60
|
.concat(partial.failures);
|
|
61
61
|
// we are not doing much with 'errorCount' and 'warningCount'
|
|
@@ -117,7 +117,7 @@ async function _lint(projectTslint, systemRoot, tslintConfigPath, options, progr
|
|
|
117
117
|
for (const file of files) {
|
|
118
118
|
if (program && allPrograms) {
|
|
119
119
|
// If it cannot be found in ANY program, then this is an error.
|
|
120
|
-
if (allPrograms.every(p => p.getSourceFile(file) === undefined)) {
|
|
120
|
+
if (allPrograms.every((p) => p.getSourceFile(file) === undefined)) {
|
|
121
121
|
throw new Error(`File ${JSON.stringify(file)} is not part of a TypeScript project '${options.tsConfig}'.`);
|
|
122
122
|
}
|
|
123
123
|
else if (program.getSourceFile(file) === undefined) {
|
|
@@ -149,9 +149,9 @@ function getFilesToLint(root, options, linter, program) {
|
|
|
149
149
|
const files = options.files || [];
|
|
150
150
|
if (files.length > 0) {
|
|
151
151
|
return files
|
|
152
|
-
.map(file => glob.sync(file, { cwd: root, ignore, nodir: true }))
|
|
152
|
+
.map((file) => glob.sync(file, { cwd: root, ignore, nodir: true }))
|
|
153
153
|
.reduce((prev, curr) => prev.concat(curr), [])
|
|
154
|
-
.map(file => path.join(root, file));
|
|
154
|
+
.map((file) => path.join(root, file));
|
|
155
155
|
}
|
|
156
156
|
if (!program) {
|
|
157
157
|
return [];
|
|
@@ -159,10 +159,8 @@ function getFilesToLint(root, options, linter, program) {
|
|
|
159
159
|
let programFiles = linter.getFileNames(program);
|
|
160
160
|
if (ignore && ignore.length > 0) {
|
|
161
161
|
// normalize to support ./ paths
|
|
162
|
-
const ignoreMatchers = ignore
|
|
163
|
-
|
|
164
|
-
programFiles = programFiles
|
|
165
|
-
.filter(file => !ignoreMatchers.some(matcher => matcher.match(path.relative(root, file))));
|
|
162
|
+
const ignoreMatchers = ignore.map((pattern) => new minimatch_1.Minimatch(path.normalize(pattern), { dot: true }));
|
|
163
|
+
programFiles = programFiles.filter((file) => !ignoreMatchers.some((matcher) => matcher.match(path.relative(root, file))));
|
|
166
164
|
}
|
|
167
165
|
return programFiles;
|
|
168
166
|
}
|
package/src/tslint/schema.json
CHANGED
package/src/typings.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright Google
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
4
|
*
|
|
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
|
+
|
|
8
9
|
declare module '@discoveryjs/json-ext' {
|
|
9
10
|
export function stringifyStream(value: unknown): import('stream').Readable;
|
|
10
11
|
}
|
|
@@ -1,3 +1,10 @@
|
|
|
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
|
+
*/
|
|
1
8
|
/// <reference types="node" />
|
|
2
9
|
import * as fs from 'fs';
|
|
3
10
|
import { ProcessBundleOptions, ProcessBundleResult } from './process-bundle';
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BundleActionCache = void 0;
|
|
4
2
|
/**
|
|
5
3
|
* @license
|
|
6
|
-
* Copyright Google
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
7
5
|
*
|
|
8
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
9
7
|
* found in the LICENSE file at https://angular.io/license
|
|
10
8
|
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.BundleActionCache = void 0;
|
|
11
11
|
const cacache = require("cacache");
|
|
12
12
|
const crypto_1 = require("crypto");
|
|
13
13
|
const fs = require("fs");
|
|
@@ -29,9 +29,7 @@ class BundleActionCache {
|
|
|
29
29
|
}
|
|
30
30
|
generateIntegrityValue(content) {
|
|
31
31
|
const algorithm = this.integrityAlgorithm || 'sha1';
|
|
32
|
-
const codeHash = crypto_1.createHash(algorithm)
|
|
33
|
-
.update(content)
|
|
34
|
-
.digest('base64');
|
|
32
|
+
const codeHash = crypto_1.createHash(algorithm).update(content).digest('base64');
|
|
35
33
|
return `${algorithm}-${codeHash}`;
|
|
36
34
|
}
|
|
37
35
|
generateBaseCacheKey(content) {
|
|
@@ -85,7 +83,7 @@ class BundleActionCache {
|
|
|
85
83
|
}
|
|
86
84
|
cacheEntries.push({
|
|
87
85
|
path: entry.path,
|
|
88
|
-
//
|
|
86
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
89
87
|
size: entry.size,
|
|
90
88
|
integrity: entry.metadata && entry.metadata.integrity,
|
|
91
89
|
});
|
|
@@ -97,7 +95,7 @@ class BundleActionCache {
|
|
|
97
95
|
return cacheEntries;
|
|
98
96
|
}
|
|
99
97
|
async getCachedBundleResult(action) {
|
|
100
|
-
const entries = action.cacheKeys && await this.getCacheEntries(action.cacheKeys);
|
|
98
|
+
const entries = action.cacheKeys && (await this.getCacheEntries(action.cacheKeys));
|
|
101
99
|
if (!entries) {
|
|
102
100
|
return null;
|
|
103
101
|
}
|
|
@@ -1,3 +1,10 @@
|
|
|
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
|
+
*/
|
|
1
8
|
import { I18nOptions } from './i18n-options';
|
|
2
9
|
import { InlineOptions, ProcessBundleOptions, ProcessBundleResult } from './process-bundle';
|
|
3
10
|
export declare class BundleActionExecutor {
|
|
@@ -1,37 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BundleActionExecutor = void 0;
|
|
4
2
|
/**
|
|
5
3
|
* @license
|
|
6
|
-
* Copyright Google
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
7
5
|
*
|
|
8
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
9
7
|
* found in the LICENSE file at https://angular.io/license
|
|
10
8
|
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.BundleActionExecutor = void 0;
|
|
11
11
|
const jest_worker_1 = require("jest-worker");
|
|
12
12
|
const os = require("os");
|
|
13
13
|
const path = require("path");
|
|
14
|
-
const
|
|
14
|
+
const v8_1 = require("v8");
|
|
15
15
|
const action_cache_1 = require("./action-cache");
|
|
16
16
|
const workers_1 = require("./workers");
|
|
17
|
-
const hasThreadSupport = (() => {
|
|
18
|
-
try {
|
|
19
|
-
require('worker_threads');
|
|
20
|
-
return true;
|
|
21
|
-
}
|
|
22
|
-
catch {
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
})();
|
|
26
|
-
// This is used to normalize serialization messaging across threads and processes
|
|
27
|
-
// Threads use the structured clone algorithm which handles more types
|
|
28
|
-
// Processes use JSON which is much more limited
|
|
29
|
-
const serialize = v8.serialize;
|
|
30
17
|
let workerFile = require.resolve('./process-bundle');
|
|
31
18
|
workerFile =
|
|
32
|
-
path.extname(workerFile) === '.ts'
|
|
33
|
-
? require.resolve('./process-bundle-bootstrap')
|
|
34
|
-
: workerFile;
|
|
19
|
+
path.extname(workerFile) === '.ts' ? require.resolve('./process-bundle-bootstrap') : workerFile;
|
|
35
20
|
class BundleActionExecutor {
|
|
36
21
|
constructor(workerOptions, integrityAlgorithm, sizeThreshold = 32 * 1024) {
|
|
37
22
|
this.workerOptions = workerOptions;
|
|
@@ -50,7 +35,7 @@ class BundleActionExecutor {
|
|
|
50
35
|
// larger files are processed in a separate process to limit memory usage in the main process
|
|
51
36
|
return (this.largeWorker = new jest_worker_1.default(workerFile, {
|
|
52
37
|
exposedMethods: ['process', 'inlineLocales'],
|
|
53
|
-
setupArgs: [[...serialize(this.workerOptions)]],
|
|
38
|
+
setupArgs: [[...v8_1.serialize(this.workerOptions)]],
|
|
54
39
|
numWorkers: workers_1.maxWorkers,
|
|
55
40
|
}));
|
|
56
41
|
}
|
|
@@ -62,9 +47,9 @@ class BundleActionExecutor {
|
|
|
62
47
|
// The limited number also prevents a large increase in memory usage for an otherwise short operation
|
|
63
48
|
return (this.smallWorker = new jest_worker_1.default(workerFile, {
|
|
64
49
|
exposedMethods: ['process', 'inlineLocales'],
|
|
65
|
-
setupArgs:
|
|
50
|
+
setupArgs: [this.workerOptions],
|
|
66
51
|
numWorkers: os.cpus().length < 2 ? 1 : 2,
|
|
67
|
-
enableWorkerThreads:
|
|
52
|
+
enableWorkerThreads: true,
|
|
68
53
|
}));
|
|
69
54
|
}
|
|
70
55
|
executeAction(method, action) {
|
|
@@ -92,19 +77,19 @@ class BundleActionExecutor {
|
|
|
92
77
|
return this.executeAction('process', action);
|
|
93
78
|
}
|
|
94
79
|
processAll(actions) {
|
|
95
|
-
return BundleActionExecutor.executeAll(actions, action => this.process(action));
|
|
80
|
+
return BundleActionExecutor.executeAll(actions, (action) => this.process(action));
|
|
96
81
|
}
|
|
97
82
|
async inline(action) {
|
|
98
83
|
return this.executeAction('inlineLocales', action);
|
|
99
84
|
}
|
|
100
85
|
inlineAll(actions) {
|
|
101
|
-
return BundleActionExecutor.executeAll(actions, action => this.inline(action));
|
|
86
|
+
return BundleActionExecutor.executeAll(actions, (action) => this.inline(action));
|
|
102
87
|
}
|
|
103
88
|
static async *executeAll(actions, executor) {
|
|
104
89
|
const executions = new Map();
|
|
105
90
|
for (const action of actions) {
|
|
106
91
|
const execution = executor(action);
|
|
107
|
-
executions.set(execution, execution.then(result => {
|
|
92
|
+
executions.set(execution, execution.then((result) => {
|
|
108
93
|
executions.delete(execution);
|
|
109
94
|
return result;
|
|
110
95
|
}));
|
|
@@ -117,11 +102,11 @@ class BundleActionExecutor {
|
|
|
117
102
|
// Floating promises are intentional here
|
|
118
103
|
// https://github.com/facebook/jest/tree/56079a5aceacf32333089cea50c64385885fee26/packages/jest-worker#end
|
|
119
104
|
if (this.largeWorker) {
|
|
120
|
-
//
|
|
105
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
121
106
|
this.largeWorker.end();
|
|
122
107
|
}
|
|
123
108
|
if (this.smallWorker) {
|
|
124
|
-
//
|
|
109
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
125
110
|
this.smallWorker.end();
|
|
126
111
|
}
|
|
127
112
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
3
|
* @license
|
|
4
|
-
* Copyright Google
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
5
5
|
*
|
|
6
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
7
7
|
* found in the LICENSE file at https://angular.io/license
|
|
@@ -38,13 +38,9 @@ class BuildBrowserFeatures {
|
|
|
38
38
|
// n: feature is unavailable
|
|
39
39
|
// a: feature is partially supported
|
|
40
40
|
// x: feature is prefixed
|
|
41
|
-
const criteria = [
|
|
42
|
-
'y',
|
|
43
|
-
'a',
|
|
44
|
-
];
|
|
41
|
+
const criteria = ['y', 'a'];
|
|
45
42
|
const data = caniuse_lite_1.feature(caniuse_lite_1.features[featureId]);
|
|
46
|
-
return !this.supportedBrowsers
|
|
47
|
-
.some(browser => {
|
|
43
|
+
return !this.supportedBrowsers.some((browser) => {
|
|
48
44
|
const [agentId, version] = browser.split(' ');
|
|
49
45
|
const browserData = data.stats[agentId];
|
|
50
46
|
const featureStatus = (browserData && browserData[version]);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright Google
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
4
|
*
|
|
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
|
|
@@ -45,7 +45,6 @@ export interface BuildOptions {
|
|
|
45
45
|
serviceWorker?: boolean;
|
|
46
46
|
webWorkerTsConfig?: string;
|
|
47
47
|
statsJson: boolean;
|
|
48
|
-
forkTypeChecker: boolean;
|
|
49
48
|
hmr?: boolean;
|
|
50
49
|
main: string;
|
|
51
50
|
polyfills?: string;
|
|
@@ -1,3 +1,10 @@
|
|
|
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
|
+
*/
|
|
1
8
|
import { StatsCompilation } from 'webpack';
|
|
2
9
|
import { Budget } from '../browser/schema';
|
|
3
10
|
import { ProcessBundleResult } from '../utils/process-bundle';
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.checkThresholds = exports.checkBudgets = exports.calculateThresholds = exports.ThresholdSeverity = void 0;
|
|
4
2
|
/**
|
|
5
3
|
* @license
|
|
6
|
-
* Copyright Google
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
7
5
|
*
|
|
8
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
9
7
|
* found in the LICENSE file at https://angular.io/license
|
|
10
8
|
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.checkThresholds = exports.checkBudgets = exports.calculateThresholds = exports.ThresholdSeverity = void 0;
|
|
11
11
|
const path_1 = require("path");
|
|
12
12
|
const schema_1 = require("../browser/schema");
|
|
13
13
|
const stats_1 = require("../webpack/utils/stats");
|
|
@@ -119,20 +119,20 @@ class Calculator {
|
|
|
119
119
|
/** Calculates the size of the given chunk for the provided build type. */
|
|
120
120
|
calculateChunkSize(chunk, buildType) {
|
|
121
121
|
// Look for a process result containing different builds for this chunk.
|
|
122
|
-
const processResult = this.processResults
|
|
123
|
-
.find((processResult) => { var _a; return processResult.name === ((_a = chunk.id) === null || _a === void 0 ? void 0 : _a.toString()); });
|
|
122
|
+
const processResult = this.processResults.find((processResult) => { var _a; return processResult.name === ((_a = chunk.id) === null || _a === void 0 ? void 0 : _a.toString()); });
|
|
124
123
|
if (processResult) {
|
|
125
124
|
// Found a differential build, use the correct size information.
|
|
126
125
|
const processResultFile = getDifferentialBuildResult(processResult, buildType);
|
|
127
|
-
return processResultFile && processResultFile.size || 0;
|
|
126
|
+
return (processResultFile && processResultFile.size) || 0;
|
|
128
127
|
}
|
|
129
128
|
else {
|
|
130
129
|
// No differential builds, get the chunk size by summing its assets.
|
|
131
130
|
if (!chunk.files) {
|
|
132
131
|
return 0;
|
|
133
132
|
}
|
|
134
|
-
return chunk.files
|
|
135
|
-
.
|
|
133
|
+
return chunk.files
|
|
134
|
+
.filter((file) => !file.endsWith('.map'))
|
|
135
|
+
.map((file) => {
|
|
136
136
|
const asset = this.assets.find((asset) => asset.name === file);
|
|
137
137
|
if (!asset) {
|
|
138
138
|
throw new Error(`Could not find asset for file: ${file}`);
|
|
@@ -144,8 +144,7 @@ class Calculator {
|
|
|
144
144
|
}
|
|
145
145
|
getAssetSize(asset) {
|
|
146
146
|
if (asset.name.endsWith('.js')) {
|
|
147
|
-
const processResult = this.processResults
|
|
148
|
-
.find((processResult) => processResult.original && path_1.basename(processResult.original.filename) === asset.name);
|
|
147
|
+
const processResult = this.processResults.find((processResult) => processResult.original && path_1.basename(processResult.original.filename) === asset.name);
|
|
149
148
|
if (processResult === null || processResult === void 0 ? void 0 : processResult.original) {
|
|
150
149
|
return processResult.original.size;
|
|
151
150
|
}
|
|
@@ -167,9 +166,8 @@ class BundleCalculator extends Calculator {
|
|
|
167
166
|
// each then check afterwards if they are all the same.
|
|
168
167
|
const buildSizes = Object.values(DifferentialBuildType).map((buildType) => {
|
|
169
168
|
const size = this.chunks
|
|
170
|
-
.filter(chunk => { var _a; return (_a = chunk === null || chunk === void 0 ? void 0 : chunk.names) === null || _a === void 0 ? void 0 : _a.includes(budgetName); })
|
|
171
|
-
|
|
172
|
-
.map(chunk => this.calculateChunkSize(chunk, buildType))
|
|
169
|
+
.filter((chunk) => { var _a; return (_a = chunk === null || chunk === void 0 ? void 0 : chunk.names) === null || _a === void 0 ? void 0 : _a.includes(budgetName); })
|
|
170
|
+
.map((chunk) => this.calculateChunkSize(chunk, buildType))
|
|
173
171
|
.reduce((l, r) => l + r, 0);
|
|
174
172
|
return { size, label: `bundle ${this.budget.name}-${buildTypeLabels[buildType]}` };
|
|
175
173
|
});
|
|
@@ -193,8 +191,8 @@ class InitialCalculator extends Calculator {
|
|
|
193
191
|
return {
|
|
194
192
|
label: `bundle initial-${buildTypeLabels[buildType]}`,
|
|
195
193
|
size: this.chunks
|
|
196
|
-
.filter(chunk => chunk.initial)
|
|
197
|
-
.map(chunk => this.calculateChunkSize(chunk, buildType))
|
|
194
|
+
.filter((chunk) => chunk.initial)
|
|
195
|
+
.map((chunk) => this.calculateChunkSize(chunk, buildType))
|
|
198
196
|
.reduce((l, r) => l + r, 0),
|
|
199
197
|
};
|
|
200
198
|
});
|
|
@@ -214,8 +212,8 @@ class InitialCalculator extends Calculator {
|
|
|
214
212
|
class AllScriptCalculator extends Calculator {
|
|
215
213
|
calculate() {
|
|
216
214
|
const size = this.assets
|
|
217
|
-
.filter(asset => asset.name.endsWith('.js'))
|
|
218
|
-
.map(asset => this.getAssetSize(asset))
|
|
215
|
+
.filter((asset) => asset.name.endsWith('.js'))
|
|
216
|
+
.map((asset) => this.getAssetSize(asset))
|
|
219
217
|
.reduce((total, size) => total + size, 0);
|
|
220
218
|
return [{ size, label: 'total scripts' }];
|
|
221
219
|
}
|
|
@@ -226,8 +224,8 @@ class AllScriptCalculator extends Calculator {
|
|
|
226
224
|
class AllCalculator extends Calculator {
|
|
227
225
|
calculate() {
|
|
228
226
|
const size = this.assets
|
|
229
|
-
.filter(asset => !asset.name.endsWith('.map'))
|
|
230
|
-
.map(asset => this.getAssetSize(asset))
|
|
227
|
+
.filter((asset) => !asset.name.endsWith('.map'))
|
|
228
|
+
.map((asset) => this.getAssetSize(asset))
|
|
231
229
|
.reduce((total, size) => total + size, 0);
|
|
232
230
|
return [{ size, label: 'total' }];
|
|
233
231
|
}
|
|
@@ -238,8 +236,8 @@ class AllCalculator extends Calculator {
|
|
|
238
236
|
class AnyScriptCalculator extends Calculator {
|
|
239
237
|
calculate() {
|
|
240
238
|
return this.assets
|
|
241
|
-
.filter(asset => asset.name.endsWith('.js'))
|
|
242
|
-
.map(asset => ({
|
|
239
|
+
.filter((asset) => asset.name.endsWith('.js'))
|
|
240
|
+
.map((asset) => ({
|
|
243
241
|
size: this.getAssetSize(asset),
|
|
244
242
|
label: asset.name,
|
|
245
243
|
}));
|
|
@@ -251,8 +249,8 @@ class AnyScriptCalculator extends Calculator {
|
|
|
251
249
|
class AnyCalculator extends Calculator {
|
|
252
250
|
calculate() {
|
|
253
251
|
return this.assets
|
|
254
|
-
.filter(asset => !asset.name.endsWith('.map'))
|
|
255
|
-
.map(asset => ({
|
|
252
|
+
.filter((asset) => !asset.name.endsWith('.map'))
|
|
253
|
+
.map((asset) => ({
|
|
256
254
|
size: this.getAssetSize(asset),
|
|
257
255
|
label: asset.name,
|
|
258
256
|
}));
|
|
@@ -266,11 +264,11 @@ function calculateBytes(input, baseline, factor = 1) {
|
|
|
266
264
|
if (!matches) {
|
|
267
265
|
return NaN;
|
|
268
266
|
}
|
|
269
|
-
const baselineBytes = baseline && calculateBytes(baseline) || 0;
|
|
267
|
+
const baselineBytes = (baseline && calculateBytes(baseline)) || 0;
|
|
270
268
|
let value = Number(matches[1]);
|
|
271
269
|
switch (matches[2] && matches[2].toLowerCase()) {
|
|
272
270
|
case '%':
|
|
273
|
-
value = baselineBytes * value / 100;
|
|
271
|
+
value = (baselineBytes * value) / 100;
|
|
274
272
|
break;
|
|
275
273
|
case 'kb':
|
|
276
274
|
value *= 1024;
|
|
@@ -333,8 +331,10 @@ exports.checkThresholds = checkThresholds;
|
|
|
333
331
|
/** Returns the {@link ProcessBundleFile} for the given {@link DifferentialBuildType}. */
|
|
334
332
|
function getDifferentialBuildResult(processResult, buildType) {
|
|
335
333
|
switch (buildType) {
|
|
336
|
-
case DifferentialBuildType.ORIGINAL:
|
|
337
|
-
|
|
334
|
+
case DifferentialBuildType.ORIGINAL:
|
|
335
|
+
return processResult.original || null;
|
|
336
|
+
case DifferentialBuildType.DOWNLEVEL:
|
|
337
|
+
return processResult.downlevel || null;
|
|
338
338
|
}
|
|
339
339
|
}
|
|
340
340
|
/**
|
|
@@ -348,10 +348,12 @@ function mergeDifferentialBuildSizes(buildSizes, mergeLabel) {
|
|
|
348
348
|
return [];
|
|
349
349
|
}
|
|
350
350
|
// Only one size.
|
|
351
|
-
return [
|
|
351
|
+
return [
|
|
352
|
+
{
|
|
352
353
|
label: mergeLabel,
|
|
353
354
|
size: buildSizes[0].size,
|
|
354
|
-
}
|
|
355
|
+
},
|
|
356
|
+
];
|
|
355
357
|
}
|
|
356
358
|
/** Returns whether or not all items in the list are equivalent to each other. */
|
|
357
359
|
function allEquivalent(items) {
|
|
@@ -360,8 +362,7 @@ function allEquivalent(items) {
|
|
|
360
362
|
function getBuildTypeLabels(processResults) {
|
|
361
363
|
var _a, _b, _c;
|
|
362
364
|
const fileNameSuffixRegExp = /\-(es20\d{2}|esnext)\./;
|
|
363
|
-
const originalFileName = (_b = (_a = processResults
|
|
364
|
-
.find(({ original }) => (original === null || original === void 0 ? void 0 : original.filename) && fileNameSuffixRegExp.test(original.filename))) === null || _a === void 0 ? void 0 : _a.original) === null || _b === void 0 ? void 0 : _b.filename;
|
|
365
|
+
const originalFileName = (_b = (_a = processResults.find(({ original }) => (original === null || original === void 0 ? void 0 : original.filename) && fileNameSuffixRegExp.test(original.filename))) === null || _a === void 0 ? void 0 : _a.original) === null || _b === void 0 ? void 0 : _b.filename;
|
|
365
366
|
let originalSuffix;
|
|
366
367
|
if (originalFileName) {
|
|
367
368
|
originalSuffix = (_c = fileNameSuffixRegExp.exec(originalFileName)) === null || _c === void 0 ? void 0 : _c[1];
|
|
@@ -1 +1,8 @@
|
|
|
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
|
+
*/
|
|
1
8
|
export declare function findCachePath(name: string): string;
|
package/src/utils/cache-path.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.findCachePath = void 0;
|
|
4
2
|
/**
|
|
5
3
|
* @license
|
|
6
|
-
* Copyright Google
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
7
5
|
*
|
|
8
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
9
7
|
* found in the LICENSE file at https://angular.io/license
|
|
10
8
|
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.findCachePath = void 0;
|
|
11
11
|
const findCacheDirectory = require("find-cache-dir");
|
|
12
12
|
const os_1 = require("os");
|
|
13
13
|
const path_1 = require("path");
|
|
@@ -1 +1,8 @@
|
|
|
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
|
+
*/
|
|
1
8
|
export declare function checkPort(port: number, host: string): Promise<number>;
|
package/src/utils/check-port.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.checkPort = void 0;
|
|
4
2
|
/**
|
|
5
3
|
* @license
|
|
6
|
-
* Copyright Google
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
7
5
|
*
|
|
8
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
9
7
|
* found in the LICENSE file at https://angular.io/license
|
|
10
8
|
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.checkPort = void 0;
|
|
11
11
|
const inquirer_1 = require("inquirer");
|
|
12
12
|
const net = require("net");
|
|
13
13
|
const tty_1 = require("./tty");
|
|
@@ -35,7 +35,7 @@ async function checkPort(port, host) {
|
|
|
35
35
|
name: 'useDifferent',
|
|
36
36
|
message: `Port ${port} is already in use.\nWould you like to use a different port?`,
|
|
37
37
|
default: true,
|
|
38
|
-
}).then((answers) => answers.useDifferent ? resolve(0) : reject(createInUseError(port)), () => reject(createInUseError(port)));
|
|
38
|
+
}).then((answers) => (answers.useDifferent ? resolve(0) : reject(createInUseError(port))), () => reject(createInUseError(port)));
|
|
39
39
|
})
|
|
40
40
|
.once('listening', () => {
|
|
41
41
|
server.close();
|
package/src/utils/color.d.ts
CHANGED
package/src/utils/color.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.colors = exports.removeColor = void 0;
|
|
4
2
|
/**
|
|
5
3
|
* @license
|
|
6
|
-
* Copyright Google
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
7
5
|
*
|
|
8
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
9
7
|
* found in the LICENSE file at https://angular.io/license
|
|
10
8
|
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.colors = exports.removeColor = void 0;
|
|
11
11
|
const ansiColors = require("ansi-colors");
|
|
12
12
|
const tty_1 = require("tty");
|
|
13
13
|
const supportsColor = process.stdout instanceof tty_1.WriteStream && process.stdout.getColorDepth() > 1;
|
|
@@ -1,3 +1,10 @@
|
|
|
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
|
+
*/
|
|
1
8
|
export declare function copyAssets(entries: {
|
|
2
9
|
glob: string;
|
|
3
10
|
ignore?: string[];
|
package/src/utils/copy-assets.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.copyAssets = void 0;
|
|
4
2
|
/**
|
|
5
3
|
* @license
|
|
6
|
-
* Copyright Google
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
7
5
|
*
|
|
8
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
9
7
|
* found in the LICENSE file at https://angular.io/license
|
|
10
8
|
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.copyAssets = void 0;
|
|
11
11
|
const fs = require("fs");
|
|
12
12
|
const glob = require("glob");
|
|
13
13
|
const path = require("path");
|
package/src/utils/copy-file.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
/**
|
|
3
2
|
* @license
|
|
4
|
-
* Copyright Google
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
5
4
|
*
|
|
6
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
7
6
|
* found in the LICENSE file at https://angular.io/license
|
|
8
7
|
*/
|
|
8
|
+
/// <reference types="node" />
|
|
9
9
|
import * as fs from 'fs';
|
|
10
10
|
export declare function copyFile(src: fs.PathLike, dest: fs.PathLike): void;
|