@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/utils/copy-file.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.copyFile = 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.copyFile = void 0;
|
|
11
11
|
const fs = require("fs");
|
|
12
12
|
// Workaround Node.js issue prior to 10.16 with copyFile on macOS
|
|
13
13
|
// https://github.com/angular/angular-cli/issues/15544 & https://github.com/nodejs/node/pull/27241
|
|
14
14
|
let copyFileWorkaround = false;
|
|
15
15
|
if (process.platform === 'darwin') {
|
|
16
|
-
const version = process.versions.node.split('.').map(part => Number(part));
|
|
16
|
+
const version = process.versions.node.split('.').map((part) => Number(part));
|
|
17
17
|
if (version[0] < 10 || version[0] === 11 || (version[0] === 10 && version[1] < 16)) {
|
|
18
18
|
copyFileWorkaround = true;
|
|
19
19
|
}
|
|
@@ -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
|
/**
|
|
2
9
|
* Delete an output directory, but error out if it's the root of the project.
|
|
3
10
|
*/
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.deleteOutputDir = 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.deleteOutputDir = void 0;
|
|
11
11
|
const path_1 = require("path");
|
|
12
12
|
const rimraf = require("rimraf");
|
|
13
13
|
/**
|
package/src/utils/empty.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
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 const allowMangle: boolean;
|
|
2
9
|
export declare const shouldBeautify: boolean;
|
|
3
10
|
export declare const allowMinify: boolean;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.profilingEnabled = exports.cachingBasePath = exports.cachingDisabled = exports.allowMinify = exports.shouldBeautify = exports.allowMangle = 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.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';
|
package/src/utils/find-up.d.ts
CHANGED
|
@@ -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 findAllNodeModules(from: string, root?: string): string[];
|
package/src/utils/find-up.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.findAllNodeModules = 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.findAllNodeModules = void 0;
|
|
11
11
|
const fs_1 = require("fs");
|
|
12
12
|
const path = require("path");
|
|
13
13
|
const is_directory_1 = require("./is-directory");
|
|
@@ -1,4 +1,11 @@
|
|
|
1
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
|
+
*/
|
|
2
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
10
|
exports.i18nInlineEmittedFiles = void 0;
|
|
4
11
|
const fs = require("fs");
|
|
@@ -65,7 +72,7 @@ async function i18nInlineEmittedFiles(context, emittedFiles, i18n, baseOutputPat
|
|
|
65
72
|
glob: '**/*',
|
|
66
73
|
input: emittedPath,
|
|
67
74
|
output: '',
|
|
68
|
-
ignore: [...processedFiles].map(f => path.relative(emittedPath, f)),
|
|
75
|
+
ignore: [...processedFiles].map((f) => path.relative(emittedPath, f)),
|
|
69
76
|
},
|
|
70
77
|
], outputPaths, '');
|
|
71
78
|
}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
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
|
+
*/
|
|
2
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
10
|
exports.configureI18nBuild = exports.createI18nOptions = void 0;
|
|
4
11
|
const core_1 = require("@angular-devkit/core");
|
|
@@ -42,7 +49,8 @@ function createI18nOptions(metadata, inline) {
|
|
|
42
49
|
let rawSourceLocaleBaseHref;
|
|
43
50
|
if (core_1.json.isJsonObject(metadata.sourceLocale)) {
|
|
44
51
|
rawSourceLocale = metadata.sourceLocale.code;
|
|
45
|
-
if (metadata.sourceLocale.baseHref !== undefined &&
|
|
52
|
+
if (metadata.sourceLocale.baseHref !== undefined &&
|
|
53
|
+
typeof metadata.sourceLocale.baseHref !== 'string') {
|
|
46
54
|
throw new Error('Project i18n sourceLocale baseHref field is malformed. Expected a string.');
|
|
47
55
|
}
|
|
48
56
|
rawSourceLocaleBaseHref = metadata.sourceLocale.baseHref;
|
|
@@ -88,7 +96,7 @@ function createI18nOptions(metadata, inline) {
|
|
|
88
96
|
}
|
|
89
97
|
if (inline === true) {
|
|
90
98
|
i18n.inlineLocales.add(i18n.sourceLocale);
|
|
91
|
-
Object.keys(i18n.locales).forEach(locale => i18n.inlineLocales.add(locale));
|
|
99
|
+
Object.keys(i18n.locales).forEach((locale) => i18n.inlineLocales.add(locale));
|
|
92
100
|
}
|
|
93
101
|
else if (inline) {
|
|
94
102
|
for (const locale of inline) {
|
|
@@ -118,7 +126,7 @@ async function configureI18nBuild(context, options) {
|
|
|
118
126
|
if (!localeDataBasePath) {
|
|
119
127
|
throw new Error(`Unable to find locale data within '@angular/common'. Please ensure '@angular/common' is installed.`);
|
|
120
128
|
}
|
|
121
|
-
// Load
|
|
129
|
+
// Load locale data and translations (if present)
|
|
122
130
|
let loader;
|
|
123
131
|
const usedFormats = new Set();
|
|
124
132
|
for (const [locale, desc] of Object.entries(i18n.locales)) {
|
|
@@ -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
|
|
@@ -77,10 +77,7 @@ async function augmentIndexHtml(params) {
|
|
|
77
77
|
}
|
|
78
78
|
let linkTags = [];
|
|
79
79
|
for (const stylesheet of stylesheets) {
|
|
80
|
-
const attrs = [
|
|
81
|
-
`rel="stylesheet"`,
|
|
82
|
-
`href="${deployUrl}${stylesheet}"`,
|
|
83
|
-
];
|
|
80
|
+
const attrs = [`rel="stylesheet"`, `href="${deployUrl}${stylesheet}"`];
|
|
84
81
|
if (crossOrigin !== 'none') {
|
|
85
82
|
attrs.push(`crossorigin="${crossOrigin}"`);
|
|
86
83
|
}
|
|
@@ -93,7 +90,7 @@ async function augmentIndexHtml(params) {
|
|
|
93
90
|
const { rewriter, transformedContent } = await html_rewriting_stream_1.htmlRewritingStream(html);
|
|
94
91
|
const baseTagExists = html.includes('<base');
|
|
95
92
|
rewriter
|
|
96
|
-
.on('startTag', tag => {
|
|
93
|
+
.on('startTag', (tag) => {
|
|
97
94
|
switch (tag.tagName) {
|
|
98
95
|
case 'html':
|
|
99
96
|
// Adjust document locale if specified
|
|
@@ -118,7 +115,7 @@ async function augmentIndexHtml(params) {
|
|
|
118
115
|
}
|
|
119
116
|
rewriter.emitStartTag(tag);
|
|
120
117
|
})
|
|
121
|
-
.on('endTag', tag => {
|
|
118
|
+
.on('endTag', (tag) => {
|
|
122
119
|
switch (tag.tagName) {
|
|
123
120
|
case 'head':
|
|
124
121
|
for (const linkTag of linkTags) {
|
|
@@ -146,13 +143,11 @@ async function augmentIndexHtml(params) {
|
|
|
146
143
|
exports.augmentIndexHtml = augmentIndexHtml;
|
|
147
144
|
function generateSriAttributes(content) {
|
|
148
145
|
const algo = 'sha384';
|
|
149
|
-
const hash = crypto_1.createHash(algo)
|
|
150
|
-
.update(content, 'utf8')
|
|
151
|
-
.digest('base64');
|
|
146
|
+
const hash = crypto_1.createHash(algo).update(content, 'utf8').digest('base64');
|
|
152
147
|
return `integrity="${algo}-${hash}"`;
|
|
153
148
|
}
|
|
154
149
|
function updateAttribute(tag, name, value) {
|
|
155
|
-
const index = tag.attrs.findIndex(a => a.name === name);
|
|
150
|
+
const index = tag.attrs.findIndex((a) => a.name === name);
|
|
156
151
|
const newValue = { name, value };
|
|
157
152
|
if (index === -1) {
|
|
158
153
|
tag.attrs.push(newValue);
|
|
@@ -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
|
|
@@ -14,7 +14,7 @@ async function htmlRewritingStream(content) {
|
|
|
14
14
|
const rewriter = new (await Promise.resolve().then(() => require('parse5-html-rewriting-stream')))();
|
|
15
15
|
return {
|
|
16
16
|
rewriter,
|
|
17
|
-
transformedContent: new Promise(resolve => {
|
|
17
|
+
transformedContent: new Promise((resolve) => {
|
|
18
18
|
new stream_1.Readable({
|
|
19
19
|
encoding: 'utf8',
|
|
20
20
|
read() {
|
|
@@ -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
|
|
@@ -25,11 +25,7 @@ class IndexHtmlGenerator {
|
|
|
25
25
|
if ((_b = this.options.optimization) === null || _b === void 0 ? void 0 : _b.styles.inlineCritical) {
|
|
26
26
|
extraPlugins.push(inlineCriticalCssPlugin(this));
|
|
27
27
|
}
|
|
28
|
-
this.plugins = [
|
|
29
|
-
augmentIndexHtmlPlugin(this),
|
|
30
|
-
...extraPlugins,
|
|
31
|
-
postTransformPlugin(this),
|
|
32
|
-
];
|
|
28
|
+
this.plugins = [augmentIndexHtmlPlugin(this), ...extraPlugins, postTransformPlugin(this)];
|
|
33
29
|
}
|
|
34
30
|
async process(options) {
|
|
35
31
|
let content = strip_bom_1.stripBom(await this.readIndex(this.options.indexPath));
|
|
@@ -65,9 +61,9 @@ class IndexHtmlGenerator {
|
|
|
65
61
|
}
|
|
66
62
|
exports.IndexHtmlGenerator = IndexHtmlGenerator;
|
|
67
63
|
function augmentIndexHtmlPlugin(generator) {
|
|
68
|
-
const { deployUrl, crossOrigin, sri = false, entrypoints
|
|
64
|
+
const { deployUrl, crossOrigin, sri = false, entrypoints } = generator.options;
|
|
69
65
|
return async (html, options) => {
|
|
70
|
-
const { lang, baseHref, outputPath = '', noModuleFiles, files, moduleFiles
|
|
66
|
+
const { lang, baseHref, outputPath = '', noModuleFiles, files, moduleFiles } = options;
|
|
71
67
|
return augment_index_html_1.augmentIndexHtml({
|
|
72
68
|
html,
|
|
73
69
|
baseHref,
|
|
@@ -76,7 +72,7 @@ function augmentIndexHtmlPlugin(generator) {
|
|
|
76
72
|
sri,
|
|
77
73
|
lang,
|
|
78
74
|
entrypoints,
|
|
79
|
-
loadOutputFile: filePath => generator.readAsset(path_1.join(outputPath, filePath)),
|
|
75
|
+
loadOutputFile: (filePath) => generator.readAsset(path_1.join(outputPath, filePath)),
|
|
80
76
|
noModuleFiles,
|
|
81
77
|
moduleFiles,
|
|
82
78
|
files,
|
|
@@ -96,10 +92,10 @@ function inlineCriticalCssPlugin(generator) {
|
|
|
96
92
|
const inlineCriticalCssProcessor = new inline_critical_css_1.InlineCriticalCssProcessor({
|
|
97
93
|
minify: (_a = generator.options.optimization) === null || _a === void 0 ? void 0 : _a.styles.minify,
|
|
98
94
|
deployUrl: generator.options.deployUrl,
|
|
99
|
-
readAsset: filePath => generator.readAsset(filePath),
|
|
95
|
+
readAsset: (filePath) => generator.readAsset(filePath),
|
|
100
96
|
});
|
|
101
97
|
return async (html, options) => inlineCriticalCssProcessor.process(html, { outputPath: options.outputPath });
|
|
102
98
|
}
|
|
103
99
|
function postTransformPlugin({ options }) {
|
|
104
|
-
return async (html) => options.postTransform ? options.postTransform(html) : html;
|
|
100
|
+
return async (html) => (options.postTransform ? options.postTransform(html) : html);
|
|
105
101
|
}
|
|
@@ -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
|
|
@@ -16,11 +16,11 @@ const url_1 = require("url");
|
|
|
16
16
|
const cache_path_1 = require("../cache-path");
|
|
17
17
|
const environment_options_1 = require("../environment-options");
|
|
18
18
|
const html_rewriting_stream_1 = require("./html-rewriting-stream");
|
|
19
|
-
const cacheFontsPath = environment_options_1.cachingDisabled
|
|
19
|
+
const cacheFontsPath = environment_options_1.cachingDisabled
|
|
20
|
+
? undefined
|
|
21
|
+
: cache_path_1.findCachePath('angular-build-fonts');
|
|
20
22
|
const packageVersion = require('../../../package.json').version;
|
|
21
|
-
const SUPPORTED_PROVIDERS = [
|
|
22
|
-
'fonts.googleapis.com',
|
|
23
|
-
];
|
|
23
|
+
const SUPPORTED_PROVIDERS = ['fonts.googleapis.com'];
|
|
24
24
|
class InlineFontsProcessor {
|
|
25
25
|
constructor(options) {
|
|
26
26
|
this.options = options;
|
|
@@ -29,20 +29,20 @@ class InlineFontsProcessor {
|
|
|
29
29
|
const hrefList = [];
|
|
30
30
|
// Collector link tags with href
|
|
31
31
|
const { rewriter: collectorStream } = await html_rewriting_stream_1.htmlRewritingStream(content);
|
|
32
|
-
collectorStream.on('startTag', tag => {
|
|
32
|
+
collectorStream.on('startTag', (tag) => {
|
|
33
33
|
var _a;
|
|
34
34
|
const { tagName, attrs } = tag;
|
|
35
35
|
if (tagName !== 'link') {
|
|
36
36
|
return;
|
|
37
37
|
}
|
|
38
38
|
// <link tag with rel="stylesheet" and a href.
|
|
39
|
-
const href = attrs.find(({ name, value }) => name === 'rel' && value === 'stylesheet')
|
|
40
|
-
|
|
39
|
+
const href = attrs.find(({ name, value }) => name === 'rel' && value === 'stylesheet') &&
|
|
40
|
+
((_a = attrs.find(({ name }) => name === 'href')) === null || _a === void 0 ? void 0 : _a.value);
|
|
41
41
|
if (href) {
|
|
42
42
|
hrefList.push(href);
|
|
43
43
|
}
|
|
44
44
|
});
|
|
45
|
-
await new Promise(resolve => collectorStream.on('finish', resolve));
|
|
45
|
+
await new Promise((resolve) => collectorStream.on('finish', resolve));
|
|
46
46
|
// Download stylesheets
|
|
47
47
|
const hrefsContent = await this.processHrefs(hrefList);
|
|
48
48
|
if (hrefsContent.size === 0) {
|
|
@@ -50,14 +50,14 @@ class InlineFontsProcessor {
|
|
|
50
50
|
}
|
|
51
51
|
// Replace link with style tag.
|
|
52
52
|
const { rewriter, transformedContent } = await html_rewriting_stream_1.htmlRewritingStream(content);
|
|
53
|
-
rewriter.on('startTag', tag => {
|
|
53
|
+
rewriter.on('startTag', (tag) => {
|
|
54
54
|
const { tagName, attrs } = tag;
|
|
55
55
|
if (tagName !== 'link') {
|
|
56
56
|
rewriter.emitStartTag(tag);
|
|
57
57
|
return;
|
|
58
58
|
}
|
|
59
|
-
const hrefAttr = attrs.some(({ name, value }) => name === 'rel' && value === 'stylesheet')
|
|
60
|
-
|
|
59
|
+
const hrefAttr = attrs.some(({ name, value }) => name === 'rel' && value === 'stylesheet') &&
|
|
60
|
+
attrs.find(({ name, value }) => name === 'href' && hrefsContent.has(value));
|
|
61
61
|
if (hrefAttr) {
|
|
62
62
|
const href = hrefAttr.value;
|
|
63
63
|
const cssContent = hrefsContent.get(href);
|
|
@@ -85,22 +85,21 @@ class InlineFontsProcessor {
|
|
|
85
85
|
}
|
|
86
86
|
const data = await new Promise((resolve, reject) => {
|
|
87
87
|
let rawResponse = '';
|
|
88
|
-
https
|
|
88
|
+
https
|
|
89
|
+
.get(url, {
|
|
89
90
|
agent,
|
|
90
91
|
rejectUnauthorized: false,
|
|
91
92
|
headers: {
|
|
92
93
|
'user-agent': userAgent,
|
|
93
94
|
},
|
|
94
|
-
}, res => {
|
|
95
|
+
}, (res) => {
|
|
95
96
|
if (res.statusCode !== 200) {
|
|
96
97
|
reject(new Error(`Inlining of fonts failed. ${url} returned status code: ${res.statusCode}.`));
|
|
97
98
|
return;
|
|
98
99
|
}
|
|
99
|
-
res
|
|
100
|
-
.on('data', chunk => rawResponse += chunk)
|
|
101
|
-
.on('end', () => resolve(rawResponse));
|
|
100
|
+
res.on('data', (chunk) => (rawResponse += chunk)).on('end', () => resolve(rawResponse));
|
|
102
101
|
})
|
|
103
|
-
.on('error', e => reject(new Error(`Inlining of fonts failed. An error has occurred while retrieving ${url} over the internet.\n` +
|
|
102
|
+
.on('error', (e) => reject(new Error(`Inlining of fonts failed. An error has occurred while retrieving ${url} over the internet.\n` +
|
|
104
103
|
e.message)));
|
|
105
104
|
});
|
|
106
105
|
if (cacheFontsPath) {
|
|
@@ -138,7 +137,7 @@ class InlineFontsProcessor {
|
|
|
138
137
|
// New lines.
|
|
139
138
|
.replace(/\n/g, '')
|
|
140
139
|
// Safe spaces.
|
|
141
|
-
.replace(/\s?[\{\:\;]\s+/g, s => s.trim());
|
|
140
|
+
.replace(/\s?[\{\:\;]\s+/g, (s) => s.trim());
|
|
142
141
|
}
|
|
143
142
|
hrefsContent.set(hrefPath, cssContent);
|
|
144
143
|
}
|
package/src/utils/index.d.ts
CHANGED
package/src/utils/index.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
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
|
|
8
8
|
*/
|
|
9
|
-
// tslint:disable
|
|
10
|
-
// TODO: cleanup this file, it's copied as is from Angular CLI.
|
|
11
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
10
|
exports.isDirectory = void 0;
|
|
11
|
+
// TODO: cleanup this file, it's copied as is from Angular CLI.
|
|
13
12
|
const fs = require("fs");
|
|
14
13
|
function isDirectory(path) {
|
|
15
14
|
try {
|
|
@@ -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 type TranslationLoader = (path: string) => {
|
|
2
9
|
translations: Record<string, import('@angular/localize').ɵParsedTranslation>;
|
|
3
10
|
format: string;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createTranslationLoader = 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.createTranslationLoader = void 0;
|
|
11
11
|
const crypto_1 = require("crypto");
|
|
12
12
|
const fs = require("fs");
|
|
13
13
|
async function createTranslationLoader() {
|
|
@@ -34,7 +34,7 @@ async function createTranslationLoader() {
|
|
|
34
34
|
messages.join('\n'));
|
|
35
35
|
};
|
|
36
36
|
// TODO: `parser.canParse()` is deprecated; remove this polyfill once we are sure all parsers provide the `parser.analyze()` method.
|
|
37
|
-
//
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
38
38
|
function analyze(parser, path, content) {
|
|
39
39
|
if (parser.analyze !== undefined) {
|
|
40
40
|
return parser.analyze(path, content);
|
|
@@ -51,22 +51,12 @@ async function importParsers() {
|
|
|
51
51
|
const localizeDiag = await Promise.resolve().then(() => require('@angular/localize/src/tools/src/diagnostics'));
|
|
52
52
|
const diagnostics = new localizeDiag.Diagnostics();
|
|
53
53
|
const parsers = {
|
|
54
|
-
arb: new (await Promise.resolve().then(() => require(
|
|
55
|
-
|
|
56
|
-
'@angular/localize/src/tools/src/translate/translation_files/translation_parsers/
|
|
57
|
-
|
|
58
|
-
// tslint:disable-next-line:trailing-comma
|
|
59
|
-
'@angular/localize/src/tools/src/translate/translation_files/translation_parsers/simple_json_translation_parser'))).SimpleJsonTranslationParser(),
|
|
60
|
-
xlf: new (await Promise.resolve().then(() => require(
|
|
61
|
-
// tslint:disable-next-line:trailing-comma
|
|
62
|
-
'@angular/localize/src/tools/src/translate/translation_files/translation_parsers/xliff1_translation_parser'))).Xliff1TranslationParser(),
|
|
63
|
-
xlf2: new (await Promise.resolve().then(() => require(
|
|
64
|
-
// tslint:disable-next-line:trailing-comma
|
|
65
|
-
'@angular/localize/src/tools/src/translate/translation_files/translation_parsers/xliff2_translation_parser'))).Xliff2TranslationParser(),
|
|
54
|
+
arb: new (await Promise.resolve().then(() => require('@angular/localize/src/tools/src/translate/translation_files/translation_parsers/arb_translation_parser'))).ArbTranslationParser(),
|
|
55
|
+
json: new (await Promise.resolve().then(() => require('@angular/localize/src/tools/src/translate/translation_files/translation_parsers/simple_json_translation_parser'))).SimpleJsonTranslationParser(),
|
|
56
|
+
xlf: new (await Promise.resolve().then(() => require('@angular/localize/src/tools/src/translate/translation_files/translation_parsers/xliff1_translation_parser'))).Xliff1TranslationParser(),
|
|
57
|
+
xlf2: new (await Promise.resolve().then(() => require('@angular/localize/src/tools/src/translate/translation_files/translation_parsers/xliff2_translation_parser'))).Xliff2TranslationParser(),
|
|
66
58
|
// The name ('xmb') needs to match the AOT compiler option
|
|
67
|
-
xmb: new (await Promise.resolve().then(() => require(
|
|
68
|
-
// tslint:disable-next-line:trailing-comma
|
|
69
|
-
'@angular/localize/src/tools/src/translate/translation_files/translation_parsers/xtb_translation_parser'))).XtbTranslationParser(),
|
|
59
|
+
xmb: new (await Promise.resolve().then(() => require('@angular/localize/src/tools/src/translate/translation_files/translation_parsers/xtb_translation_parser'))).XtbTranslationParser(),
|
|
70
60
|
};
|
|
71
61
|
return { parsers, diagnostics };
|
|
72
62
|
}
|