@angular-devkit/build-angular 18.0.0-next.2 → 18.0.0-next.4
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/builders.json +1 -5
- package/package.json +21 -20
- package/src/builders/app-shell/index.js +3 -5
- package/src/builders/browser/index.d.ts +1 -1
- package/src/builders/browser/index.js +9 -13
- package/src/builders/browser-esbuild/index.d.ts +2 -2
- package/src/builders/browser-esbuild/index.js +6 -9
- package/src/builders/dev-server/builder.d.ts +2 -2
- package/src/builders/dev-server/builder.js +11 -6
- package/src/builders/dev-server/index.d.ts +1 -1
- package/src/builders/dev-server/webpack-server.d.ts +1 -1
- package/src/builders/dev-server/webpack-server.js +5 -6
- package/src/builders/extract-i18n/application-extraction.js +2 -2
- package/src/builders/extract-i18n/builder.js +3 -4
- package/src/builders/extract-i18n/options.d.ts +1 -1
- package/src/builders/extract-i18n/options.js +2 -2
- package/src/builders/jest/index.js +2 -2
- package/src/builders/karma/index.js +3 -4
- package/src/builders/ng-packagr/index.js +8 -7
- package/src/builders/ng-packagr/schema.d.ts +4 -0
- package/src/builders/ng-packagr/schema.json +4 -0
- package/src/builders/prerender/index.js +2 -2
- package/src/builders/prerender/render-worker.js +1 -1
- package/src/builders/server/index.js +3 -4
- package/src/builders/server/platform-server-exports-loader.js +2 -1
- package/src/builders/ssr-dev-server/index.js +34 -34
- package/src/builders/web-test-runner/index.js +2 -2
- package/src/index.d.ts +1 -1
- package/src/index.js +2 -2
- package/src/tools/babel/presets/application.js +1 -1
- package/src/tools/webpack/configs/styles.js +2 -2
- package/src/tools/webpack/plugins/any-component-style-budget-checker.d.ts +2 -2
- package/src/tools/webpack/plugins/any-component-style-budget-checker.js +14 -17
- package/src/tools/webpack/plugins/css-optimizer-plugin.js +2 -2
- package/src/tools/webpack/plugins/index-html-webpack-plugin.d.ts +1 -1
- package/src/tools/webpack/plugins/index-html-webpack-plugin.js +3 -3
- package/src/tools/webpack/plugins/javascript-optimizer-plugin.js +2 -2
- package/src/tools/webpack/plugins/service-worker-plugin.js +2 -2
- package/src/tools/webpack/utils/stats.d.ts +1 -14
- package/src/tools/webpack/utils/stats.js +3 -207
- package/src/utils/action-executor.d.ts +1 -1
- package/src/utils/i18n-inlining.d.ts +1 -1
- package/src/utils/i18n-webpack.d.ts +16 -0
- package/src/utils/i18n-webpack.js +107 -0
- package/src/utils/index.d.ts +1 -2
- package/src/utils/index.js +4 -2
- package/src/utils/normalize-builder-schema.js +2 -2
- package/src/utils/normalize-cache.js +1 -1
- package/src/utils/normalize-optimization.d.ts +1 -1
- package/src/utils/normalize-optimization.js +0 -2
- package/src/utils/output-paths.d.ts +1 -1
- package/src/utils/webpack-browser-config.d.ts +1 -1
- package/src/utils/webpack-browser-config.js +2 -2
- package/src/builders/application/build-action.d.ts +0 -33
- package/src/builders/application/build-action.js +0 -183
- package/src/builders/application/execute-build.d.ts +0 -11
- package/src/builders/application/execute-build.js +0 -127
- package/src/builders/application/execute-post-bundle.d.ts +0 -25
- package/src/builders/application/execute-post-bundle.js +0 -96
- package/src/builders/application/i18n.d.ts +0 -29
- package/src/builders/application/i18n.js +0 -128
- package/src/builders/application/index.d.ts +0 -57
- package/src/builders/application/index.js +0 -121
- package/src/builders/application/options.d.ts +0 -149
- package/src/builders/application/options.js +0 -352
- package/src/builders/application/schema.d.ts +0 -512
- package/src/builders/application/schema.js +0 -58
- package/src/builders/application/schema.json +0 -635
- package/src/builders/application/setup-bundling.d.ts +0 -19
- package/src/builders/application/setup-bundling.js +0 -71
- package/src/builders/dev-server/vite-server.d.ts +0 -30
- package/src/builders/dev-server/vite-server.js +0 -502
- package/src/tools/babel/plugins/adjust-static-class-members.d.ts +0 -27
- package/src/tools/babel/plugins/adjust-static-class-members.js +0 -351
- package/src/tools/babel/plugins/adjust-typescript-enums.d.ts +0 -23
- package/src/tools/babel/plugins/adjust-typescript-enums.js +0 -113
- package/src/tools/babel/plugins/elide-angular-metadata.d.ts +0 -23
- package/src/tools/babel/plugins/elide-angular-metadata.js +0 -110
- package/src/tools/babel/plugins/index.d.ts +0 -11
- package/src/tools/babel/plugins/index.js +0 -21
- package/src/tools/babel/plugins/pure-toplevel-functions.d.ts +0 -16
- package/src/tools/babel/plugins/pure-toplevel-functions.js +0 -90
- package/src/tools/esbuild/angular/angular-host.d.ts +0 -26
- package/src/tools/esbuild/angular/angular-host.js +0 -72
- package/src/tools/esbuild/angular/compilation/angular-compilation.d.ts +0 -42
- package/src/tools/esbuild/angular/compilation/angular-compilation.js +0 -94
- package/src/tools/esbuild/angular/compilation/aot-compilation.d.ts +0 -21
- package/src/tools/esbuild/angular/compilation/aot-compilation.js +0 -228
- package/src/tools/esbuild/angular/compilation/factory.d.ts +0 -16
- package/src/tools/esbuild/angular/compilation/factory.js +0 -56
- package/src/tools/esbuild/angular/compilation/index.d.ts +0 -10
- package/src/tools/esbuild/angular/compilation/index.js +0 -17
- package/src/tools/esbuild/angular/compilation/jit-compilation.d.ts +0 -21
- package/src/tools/esbuild/angular/compilation/jit-compilation.js +0 -106
- package/src/tools/esbuild/angular/compilation/noop-compilation.d.ts +0 -20
- package/src/tools/esbuild/angular/compilation/noop-compilation.js +0 -26
- package/src/tools/esbuild/angular/compilation/parallel-compilation.d.ts +0 -42
- package/src/tools/esbuild/angular/compilation/parallel-compilation.js +0 -123
- package/src/tools/esbuild/angular/compilation/parallel-worker.d.ts +0 -33
- package/src/tools/esbuild/angular/compilation/parallel-worker.js +0 -90
- package/src/tools/esbuild/angular/compilation-state.d.ts +0 -15
- package/src/tools/esbuild/angular/compilation-state.js +0 -44
- package/src/tools/esbuild/angular/compiler-plugin.d.ts +0 -27
- package/src/tools/esbuild/angular/compiler-plugin.js +0 -433
- package/src/tools/esbuild/angular/component-stylesheets.d.ts +0 -44
- package/src/tools/esbuild/angular/component-stylesheets.js +0 -150
- package/src/tools/esbuild/angular/diagnostics.d.ts +0 -15
- package/src/tools/esbuild/angular/diagnostics.js +0 -69
- package/src/tools/esbuild/angular/file-reference-tracker.d.ts +0 -17
- package/src/tools/esbuild/angular/file-reference-tracker.js +0 -57
- package/src/tools/esbuild/angular/jit-plugin-callbacks.d.ts +0 -23
- package/src/tools/esbuild/angular/jit-plugin-callbacks.js +0 -117
- package/src/tools/esbuild/angular/jit-resource-transformer.d.ts +0 -17
- package/src/tools/esbuild/angular/jit-resource-transformer.js +0 -186
- package/src/tools/esbuild/angular/source-file-cache.d.ts +0 -18
- package/src/tools/esbuild/angular/source-file-cache.js +0 -65
- package/src/tools/esbuild/angular/uri.d.ts +0 -54
- package/src/tools/esbuild/angular/uri.js +0 -74
- package/src/tools/esbuild/angular/web-worker-transformer.d.ts +0 -17
- package/src/tools/esbuild/angular/web-worker-transformer.js +0 -94
- package/src/tools/esbuild/application-code-bundle.d.ts +0 -20
- package/src/tools/esbuild/application-code-bundle.js +0 -368
- package/src/tools/esbuild/budget-stats.d.ts +0 -19
- package/src/tools/esbuild/budget-stats.js +0 -59
- package/src/tools/esbuild/bundler-context.d.ts +0 -75
- package/src/tools/esbuild/bundler-context.js +0 -366
- package/src/tools/esbuild/bundler-execution-result.d.ts +0 -71
- package/src/tools/esbuild/bundler-execution-result.js +0 -131
- package/src/tools/esbuild/cache.d.ts +0 -88
- package/src/tools/esbuild/cache.js +0 -92
- package/src/tools/esbuild/commonjs-checker.d.ts +0 -28
- package/src/tools/esbuild/commonjs-checker.js +0 -151
- package/src/tools/esbuild/compiler-plugin-options.d.ts +0 -16
- package/src/tools/esbuild/compiler-plugin-options.js +0 -49
- package/src/tools/esbuild/external-packages-plugin.d.ts +0 -18
- package/src/tools/esbuild/external-packages-plugin.js +0 -70
- package/src/tools/esbuild/global-scripts.d.ts +0 -16
- package/src/tools/esbuild/global-scripts.js +0 -142
- package/src/tools/esbuild/global-styles.d.ts +0 -10
- package/src/tools/esbuild/global-styles.js +0 -74
- package/src/tools/esbuild/i18n-inliner-worker.d.ts +0 -42
- package/src/tools/esbuild/i18n-inliner-worker.js +0 -136
- package/src/tools/esbuild/i18n-inliner.d.ts +0 -44
- package/src/tools/esbuild/i18n-inliner.js +0 -150
- package/src/tools/esbuild/i18n-locale-plugin.d.ts +0 -22
- package/src/tools/esbuild/i18n-locale-plugin.js +0 -120
- package/src/tools/esbuild/index-html-generator.d.ts +0 -15
- package/src/tools/esbuild/index-html-generator.js +0 -129
- package/src/tools/esbuild/javascript-transformer-worker.d.ts +0 -19
- package/src/tools/esbuild/javascript-transformer-worker.js +0 -154
- package/src/tools/esbuild/javascript-transformer.d.ts +0 -54
- package/src/tools/esbuild/javascript-transformer.js +0 -143
- package/src/tools/esbuild/license-extractor.d.ts +0 -25
- package/src/tools/esbuild/license-extractor.js +0 -158
- package/src/tools/esbuild/load-result-cache.d.ts +0 -21
- package/src/tools/esbuild/load-result-cache.js +0 -75
- package/src/tools/esbuild/profiling.d.ts +0 -11
- package/src/tools/esbuild/profiling.js +0 -78
- package/src/tools/esbuild/rxjs-esm-resolution-plugin.d.ts +0 -18
- package/src/tools/esbuild/rxjs-esm-resolution-plugin.js +0 -44
- package/src/tools/esbuild/sourcemap-ignorelist-plugin.d.ts +0 -17
- package/src/tools/esbuild/sourcemap-ignorelist-plugin.js +0 -73
- package/src/tools/esbuild/stylesheets/bundle-options.d.ts +0 -35
- package/src/tools/esbuild/stylesheets/bundle-options.js +0 -64
- package/src/tools/esbuild/stylesheets/css-inline-fonts-plugin.d.ts +0 -25
- package/src/tools/esbuild/stylesheets/css-inline-fonts-plugin.js +0 -57
- package/src/tools/esbuild/stylesheets/css-language.d.ts +0 -9
- package/src/tools/esbuild/stylesheets/css-language.js +0 -15
- package/src/tools/esbuild/stylesheets/css-resource-plugin.d.ts +0 -18
- package/src/tools/esbuild/stylesheets/css-resource-plugin.js +0 -107
- package/src/tools/esbuild/stylesheets/less-language.d.ts +0 -9
- package/src/tools/esbuild/stylesheets/less-language.js +0 -155
- package/src/tools/esbuild/stylesheets/sass-language.d.ts +0 -10
- package/src/tools/esbuild/stylesheets/sass-language.js +0 -185
- package/src/tools/esbuild/stylesheets/stylesheet-plugin-factory.d.ts +0 -58
- package/src/tools/esbuild/stylesheets/stylesheet-plugin-factory.js +0 -282
- package/src/tools/esbuild/utils.d.ts +0 -41
- package/src/tools/esbuild/utils.js +0 -378
- package/src/tools/esbuild/virtual-module-plugin.d.ts +0 -33
- package/src/tools/esbuild/virtual-module-plugin.js +0 -43
- package/src/tools/esbuild/watcher.d.ts +0 -25
- package/src/tools/esbuild/watcher.js +0 -118
- package/src/tools/sass/lexer.d.ts +0 -18
- package/src/tools/sass/lexer.js +0 -161
- package/src/tools/sass/rebasing-importer.d.ts +0 -101
- package/src/tools/sass/rebasing-importer.js +0 -337
- package/src/tools/sass/sass-service.d.ts +0 -49
- package/src/tools/sass/sass-service.js +0 -213
- package/src/tools/sass/worker.d.ts +0 -8
- package/src/tools/sass/worker.js +0 -164
- package/src/tools/vite/angular-memory-plugin.d.ts +0 -24
- package/src/tools/vite/angular-memory-plugin.js +0 -268
- package/src/tools/vite/i18n-locale-plugin.d.ts +0 -18
- package/src/tools/vite/i18n-locale-plugin.js +0 -55
- package/src/typings.d.ts +0 -21
- package/src/utils/bundle-calculator.d.ts +0 -44
- package/src/utils/bundle-calculator.js +0 -302
- package/src/utils/check-port.d.ts +0 -8
- package/src/utils/check-port.js +0 -58
- package/src/utils/delete-output-dir.d.ts +0 -11
- package/src/utils/delete-output-dir.js +0 -46
- package/src/utils/i18n-options.d.ts +0 -40
- package/src/utils/i18n-options.js +0 -254
- package/src/utils/index-file/augment-index-html.d.ts +0 -40
- package/src/utils/index-file/augment-index-html.js +0 -238
- package/src/utils/index-file/html-rewriting-stream.d.ts +0 -11
- package/src/utils/index-file/html-rewriting-stream.js +0 -28
- package/src/utils/index-file/index-html-generator.d.ts +0 -47
- package/src/utils/index-file/index-html-generator.js +0 -119
- package/src/utils/index-file/inline-critical-css.d.ts +0 -24
- package/src/utils/index-file/inline-critical-css.js +0 -179
- package/src/utils/index-file/inline-fonts.d.ts +0 -23
- package/src/utils/index-file/inline-fonts.js +0 -267
- package/src/utils/index-file/style-nonce.d.ts +0 -12
- package/src/utils/index-file/style-nonce.js +0 -53
- package/src/utils/load-proxy-config.d.ts +0 -8
- package/src/utils/load-proxy-config.js +0 -192
- package/src/utils/load-translations.d.ts +0 -16
- package/src/utils/load-translations.js +0 -84
- package/src/utils/postcss-configuration.d.ts +0 -17
- package/src/utils/postcss-configuration.js +0 -86
- package/src/utils/purge-cache.d.ts +0 -10
- package/src/utils/purge-cache.js +0 -40
- package/src/utils/routes-extractor/extractor.d.ts +0 -15
- package/src/utils/routes-extractor/extractor.js +0 -97
- package/src/utils/server-rendering/esm-in-memory-loader/loader-hooks.d.ts +0 -18
- package/src/utils/server-rendering/esm-in-memory-loader/loader-hooks.js +0 -129
- package/src/utils/server-rendering/esm-in-memory-loader/register-hooks.d.ts +0 -8
- package/src/utils/server-rendering/esm-in-memory-loader/register-hooks.js +0 -13
- package/src/utils/server-rendering/fetch-patch.d.ts +0 -8
- package/src/utils/server-rendering/fetch-patch.js +0 -66
- package/src/utils/server-rendering/load-esm-from-memory.d.ts +0 -10
- package/src/utils/server-rendering/load-esm-from-memory.js +0 -26
- package/src/utils/server-rendering/main-bundle-exports.d.ts +0 -27
- package/src/utils/server-rendering/main-bundle-exports.js +0 -9
- package/src/utils/server-rendering/prerender.d.ts +0 -23
- package/src/utils/server-rendering/prerender.js +0 -192
- package/src/utils/server-rendering/render-page.d.ts +0 -26
- package/src/utils/server-rendering/render-page.js +0 -110
- package/src/utils/server-rendering/render-worker.d.ts +0 -22
- package/src/utils/server-rendering/render-worker.js +0 -30
- package/src/utils/server-rendering/routes-extractor-worker.d.ts +0 -21
- package/src/utils/server-rendering/routes-extractor-worker.js +0 -53
- package/src/utils/service-worker.d.ts +0 -25
- package/src/utils/service-worker.js +0 -211
- package/src/utils/supported-browsers.d.ts +0 -10
- package/src/utils/supported-browsers.js +0 -42
- package/src/utils/version.d.ts +0 -8
- package/src/utils/version.js +0 -59
|
@@ -1,254 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @license
|
|
4
|
-
* Copyright Google LLC All Rights Reserved.
|
|
5
|
-
*
|
|
6
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
-
* found in the LICENSE file at https://angular.io/license
|
|
8
|
-
*/
|
|
9
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.loadTranslations = exports.configureI18nBuild = exports.createI18nOptions = void 0;
|
|
14
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
15
|
-
const node_module_1 = require("node:module");
|
|
16
|
-
const node_os_1 = __importDefault(require("node:os"));
|
|
17
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
18
|
-
const schema_1 = require("../builders/browser/schema");
|
|
19
|
-
const read_tsconfig_1 = require("../utils/read-tsconfig");
|
|
20
|
-
const load_translations_1 = require("./load-translations");
|
|
21
|
-
/**
|
|
22
|
-
* The base module location used to search for locale specific data.
|
|
23
|
-
*/
|
|
24
|
-
const LOCALE_DATA_BASE_MODULE = '@angular/common/locales/global';
|
|
25
|
-
function normalizeTranslationFileOption(option, locale, expectObjectInError) {
|
|
26
|
-
if (typeof option === 'string') {
|
|
27
|
-
return [option];
|
|
28
|
-
}
|
|
29
|
-
if (Array.isArray(option) && option.every((element) => typeof element === 'string')) {
|
|
30
|
-
return option;
|
|
31
|
-
}
|
|
32
|
-
let errorMessage = `Project i18n locales translation field value for '${locale}' is malformed. `;
|
|
33
|
-
if (expectObjectInError) {
|
|
34
|
-
errorMessage += 'Expected a string, array of strings, or object.';
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
errorMessage += 'Expected a string or array of strings.';
|
|
38
|
-
}
|
|
39
|
-
throw new Error(errorMessage);
|
|
40
|
-
}
|
|
41
|
-
function ensureObject(value, name) {
|
|
42
|
-
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
43
|
-
throw new Error(`Project ${name} field is malformed. Expected an object.`);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
function ensureString(value, name) {
|
|
47
|
-
if (typeof value !== 'string') {
|
|
48
|
-
throw new Error(`Project ${name} field is malformed. Expected a string.`);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
function createI18nOptions(projectMetadata, inline) {
|
|
52
|
-
const { i18n: metadata = {} } = projectMetadata;
|
|
53
|
-
ensureObject(metadata, 'i18n');
|
|
54
|
-
const i18n = {
|
|
55
|
-
inlineLocales: new Set(),
|
|
56
|
-
// en-US is the default locale added to Angular applications (https://angular.io/guide/i18n#i18n-pipes)
|
|
57
|
-
sourceLocale: 'en-US',
|
|
58
|
-
locales: {},
|
|
59
|
-
get shouldInline() {
|
|
60
|
-
return this.inlineLocales.size > 0;
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
let rawSourceLocale;
|
|
64
|
-
let rawSourceLocaleBaseHref;
|
|
65
|
-
if (typeof metadata.sourceLocale === 'string') {
|
|
66
|
-
rawSourceLocale = metadata.sourceLocale;
|
|
67
|
-
}
|
|
68
|
-
else if (metadata.sourceLocale !== undefined) {
|
|
69
|
-
ensureObject(metadata.sourceLocale, 'i18n sourceLocale');
|
|
70
|
-
if (metadata.sourceLocale.code !== undefined) {
|
|
71
|
-
ensureString(metadata.sourceLocale.code, 'i18n sourceLocale code');
|
|
72
|
-
rawSourceLocale = metadata.sourceLocale.code;
|
|
73
|
-
}
|
|
74
|
-
if (metadata.sourceLocale.baseHref !== undefined) {
|
|
75
|
-
ensureString(metadata.sourceLocale.baseHref, 'i18n sourceLocale baseHref');
|
|
76
|
-
rawSourceLocaleBaseHref = metadata.sourceLocale.baseHref;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
if (rawSourceLocale !== undefined) {
|
|
80
|
-
i18n.sourceLocale = rawSourceLocale;
|
|
81
|
-
i18n.hasDefinedSourceLocale = true;
|
|
82
|
-
}
|
|
83
|
-
i18n.locales[i18n.sourceLocale] = {
|
|
84
|
-
files: [],
|
|
85
|
-
baseHref: rawSourceLocaleBaseHref,
|
|
86
|
-
};
|
|
87
|
-
if (metadata.locales !== undefined) {
|
|
88
|
-
ensureObject(metadata.locales, 'i18n locales');
|
|
89
|
-
for (const [locale, options] of Object.entries(metadata.locales)) {
|
|
90
|
-
let translationFiles;
|
|
91
|
-
let baseHref;
|
|
92
|
-
if (options && typeof options === 'object' && 'translation' in options) {
|
|
93
|
-
translationFiles = normalizeTranslationFileOption(options.translation, locale, false);
|
|
94
|
-
if ('baseHref' in options) {
|
|
95
|
-
ensureString(options.baseHref, `i18n locales ${locale} baseHref`);
|
|
96
|
-
baseHref = options.baseHref;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
translationFiles = normalizeTranslationFileOption(options, locale, true);
|
|
101
|
-
}
|
|
102
|
-
if (locale === i18n.sourceLocale) {
|
|
103
|
-
throw new Error(`An i18n locale ('${locale}') cannot both be a source locale and provide a translation.`);
|
|
104
|
-
}
|
|
105
|
-
i18n.locales[locale] = {
|
|
106
|
-
files: translationFiles.map((file) => ({ path: file })),
|
|
107
|
-
baseHref,
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
if (inline === true) {
|
|
112
|
-
i18n.inlineLocales.add(i18n.sourceLocale);
|
|
113
|
-
Object.keys(i18n.locales).forEach((locale) => i18n.inlineLocales.add(locale));
|
|
114
|
-
}
|
|
115
|
-
else if (inline) {
|
|
116
|
-
for (const locale of inline) {
|
|
117
|
-
if (!i18n.locales[locale] && i18n.sourceLocale !== locale) {
|
|
118
|
-
throw new Error(`Requested locale '${locale}' is not defined for the project.`);
|
|
119
|
-
}
|
|
120
|
-
i18n.inlineLocales.add(locale);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
return i18n;
|
|
124
|
-
}
|
|
125
|
-
exports.createI18nOptions = createI18nOptions;
|
|
126
|
-
async function configureI18nBuild(context, options) {
|
|
127
|
-
if (!context.target) {
|
|
128
|
-
throw new Error('The builder requires a target.');
|
|
129
|
-
}
|
|
130
|
-
const buildOptions = { ...options };
|
|
131
|
-
const tsConfig = await (0, read_tsconfig_1.readTsconfig)(buildOptions.tsConfig, context.workspaceRoot);
|
|
132
|
-
const metadata = await context.getProjectMetadata(context.target);
|
|
133
|
-
const i18n = createI18nOptions(metadata, buildOptions.localize);
|
|
134
|
-
// No additional processing needed if no inlining requested and no source locale defined.
|
|
135
|
-
if (!i18n.shouldInline && !i18n.hasDefinedSourceLocale) {
|
|
136
|
-
return { buildOptions, i18n };
|
|
137
|
-
}
|
|
138
|
-
const projectRoot = node_path_1.default.join(context.workspaceRoot, metadata.root || '');
|
|
139
|
-
// The trailing slash is required to signal that the path is a directory and not a file.
|
|
140
|
-
const projectRequire = (0, node_module_1.createRequire)(projectRoot + '/');
|
|
141
|
-
const localeResolver = (locale) => projectRequire.resolve(node_path_1.default.join(LOCALE_DATA_BASE_MODULE, locale));
|
|
142
|
-
// Load locale data and translations (if present)
|
|
143
|
-
let loader;
|
|
144
|
-
const usedFormats = new Set();
|
|
145
|
-
for (const [locale, desc] of Object.entries(i18n.locales)) {
|
|
146
|
-
if (!i18n.inlineLocales.has(locale) && locale !== i18n.sourceLocale) {
|
|
147
|
-
continue;
|
|
148
|
-
}
|
|
149
|
-
let localeDataPath = findLocaleDataPath(locale, localeResolver);
|
|
150
|
-
if (!localeDataPath) {
|
|
151
|
-
const [first] = locale.split('-');
|
|
152
|
-
if (first) {
|
|
153
|
-
localeDataPath = findLocaleDataPath(first.toLowerCase(), localeResolver);
|
|
154
|
-
if (localeDataPath) {
|
|
155
|
-
context.logger.warn(`Locale data for '${locale}' cannot be found. Using locale data for '${first}'.`);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
if (!localeDataPath) {
|
|
160
|
-
context.logger.warn(`Locale data for '${locale}' cannot be found. No locale data will be included for this locale.`);
|
|
161
|
-
}
|
|
162
|
-
else {
|
|
163
|
-
desc.dataPath = localeDataPath;
|
|
164
|
-
}
|
|
165
|
-
if (!desc.files.length) {
|
|
166
|
-
continue;
|
|
167
|
-
}
|
|
168
|
-
loader ??= await (0, load_translations_1.createTranslationLoader)();
|
|
169
|
-
loadTranslations(locale, desc, context.workspaceRoot, loader, {
|
|
170
|
-
warn(message) {
|
|
171
|
-
context.logger.warn(message);
|
|
172
|
-
},
|
|
173
|
-
error(message) {
|
|
174
|
-
throw new Error(message);
|
|
175
|
-
},
|
|
176
|
-
}, usedFormats, buildOptions.i18nDuplicateTranslation);
|
|
177
|
-
if (usedFormats.size > 1 && tsConfig.options.enableI18nLegacyMessageIdFormat !== false) {
|
|
178
|
-
// This limitation is only for legacy message id support (defaults to true as of 9.0)
|
|
179
|
-
throw new Error('Localization currently only supports using one type of translation file format for the entire application.');
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
// If inlining store the output in a temporary location to facilitate post-processing
|
|
183
|
-
if (i18n.shouldInline) {
|
|
184
|
-
// TODO: we should likely save these in the .angular directory in the next major version.
|
|
185
|
-
// We'd need to do a migration to add the temp directory to gitignore.
|
|
186
|
-
const tempPath = node_fs_1.default.mkdtempSync(node_path_1.default.join(node_fs_1.default.realpathSync(node_os_1.default.tmpdir()), 'angular-cli-i18n-'));
|
|
187
|
-
buildOptions.outputPath = tempPath;
|
|
188
|
-
process.on('exit', () => {
|
|
189
|
-
try {
|
|
190
|
-
node_fs_1.default.rmSync(tempPath, { force: true, recursive: true, maxRetries: 3 });
|
|
191
|
-
}
|
|
192
|
-
catch { }
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
return { buildOptions, i18n };
|
|
196
|
-
}
|
|
197
|
-
exports.configureI18nBuild = configureI18nBuild;
|
|
198
|
-
function findLocaleDataPath(locale, resolver) {
|
|
199
|
-
// Remove private use subtags
|
|
200
|
-
const scrubbedLocale = locale.replace(/-x(-[a-zA-Z0-9]{1,8})+$/, '');
|
|
201
|
-
try {
|
|
202
|
-
return resolver(scrubbedLocale);
|
|
203
|
-
}
|
|
204
|
-
catch {
|
|
205
|
-
// fallback to known existing en-US locale data as of 14.0
|
|
206
|
-
return scrubbedLocale === 'en-US' ? findLocaleDataPath('en', resolver) : null;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
function loadTranslations(locale, desc, workspaceRoot, loader, logger, usedFormats, duplicateTranslation) {
|
|
210
|
-
let translations = undefined;
|
|
211
|
-
for (const file of desc.files) {
|
|
212
|
-
const loadResult = loader(node_path_1.default.join(workspaceRoot, file.path));
|
|
213
|
-
for (const diagnostics of loadResult.diagnostics.messages) {
|
|
214
|
-
if (diagnostics.type === 'error') {
|
|
215
|
-
logger.error(`Error parsing translation file '${file.path}': ${diagnostics.message}`);
|
|
216
|
-
}
|
|
217
|
-
else {
|
|
218
|
-
logger.warn(`WARNING [${file.path}]: ${diagnostics.message}`);
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
if (loadResult.locale !== undefined && loadResult.locale !== locale) {
|
|
222
|
-
logger.warn(`WARNING [${file.path}]: File target locale ('${loadResult.locale}') does not match configured locale ('${locale}')`);
|
|
223
|
-
}
|
|
224
|
-
usedFormats?.add(loadResult.format);
|
|
225
|
-
file.format = loadResult.format;
|
|
226
|
-
file.integrity = loadResult.integrity;
|
|
227
|
-
if (translations) {
|
|
228
|
-
// Merge translations
|
|
229
|
-
for (const [id, message] of Object.entries(loadResult.translations)) {
|
|
230
|
-
if (translations[id] !== undefined) {
|
|
231
|
-
const duplicateTranslationMessage = `[${file.path}]: Duplicate translations for message '${id}' when merging.`;
|
|
232
|
-
switch (duplicateTranslation) {
|
|
233
|
-
case schema_1.I18NTranslation.Ignore:
|
|
234
|
-
break;
|
|
235
|
-
case schema_1.I18NTranslation.Error:
|
|
236
|
-
logger.error(`ERROR ${duplicateTranslationMessage}`);
|
|
237
|
-
break;
|
|
238
|
-
case schema_1.I18NTranslation.Warning:
|
|
239
|
-
default:
|
|
240
|
-
logger.warn(`WARNING ${duplicateTranslationMessage}`);
|
|
241
|
-
break;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
translations[id] = message;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
else {
|
|
248
|
-
// First or only translation file
|
|
249
|
-
translations = loadResult.translations;
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
desc.translation = translations;
|
|
253
|
-
}
|
|
254
|
-
exports.loadTranslations = loadTranslations;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright Google LLC All Rights Reserved.
|
|
4
|
-
*
|
|
5
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
-
* found in the LICENSE file at https://angular.io/license
|
|
7
|
-
*/
|
|
8
|
-
export type LoadOutputFileFunctionType = (file: string) => Promise<string>;
|
|
9
|
-
export type CrossOriginValue = 'none' | 'anonymous' | 'use-credentials';
|
|
10
|
-
export type Entrypoint = [name: string, isModule: boolean];
|
|
11
|
-
export interface AugmentIndexHtmlOptions {
|
|
12
|
-
html: string;
|
|
13
|
-
baseHref?: string;
|
|
14
|
-
deployUrl?: string;
|
|
15
|
-
sri: boolean;
|
|
16
|
-
/** crossorigin attribute setting of elements that provide CORS support */
|
|
17
|
-
crossOrigin?: CrossOriginValue;
|
|
18
|
-
files: FileInfo[];
|
|
19
|
-
loadOutputFile: LoadOutputFileFunctionType;
|
|
20
|
-
/** Used to sort the inseration of files in the HTML file */
|
|
21
|
-
entrypoints: Entrypoint[];
|
|
22
|
-
/** Used to set the document default locale */
|
|
23
|
-
lang?: string;
|
|
24
|
-
hints?: {
|
|
25
|
-
url: string;
|
|
26
|
-
mode: string;
|
|
27
|
-
as?: string;
|
|
28
|
-
}[];
|
|
29
|
-
imageDomains?: string[];
|
|
30
|
-
}
|
|
31
|
-
export interface FileInfo {
|
|
32
|
-
file: string;
|
|
33
|
-
name?: string;
|
|
34
|
-
extension: string;
|
|
35
|
-
}
|
|
36
|
-
export declare function augmentIndexHtml(params: AugmentIndexHtmlOptions): Promise<{
|
|
37
|
-
content: string;
|
|
38
|
-
warnings: string[];
|
|
39
|
-
errors: string[];
|
|
40
|
-
}>;
|
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @license
|
|
4
|
-
* Copyright Google LLC All Rights Reserved.
|
|
5
|
-
*
|
|
6
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
-
* found in the LICENSE file at https://angular.io/license
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.augmentIndexHtml = void 0;
|
|
11
|
-
const node_crypto_1 = require("node:crypto");
|
|
12
|
-
const node_path_1 = require("node:path");
|
|
13
|
-
const load_esm_1 = require("../load-esm");
|
|
14
|
-
const html_rewriting_stream_1 = require("./html-rewriting-stream");
|
|
15
|
-
/*
|
|
16
|
-
* Helper function used by the IndexHtmlWebpackPlugin.
|
|
17
|
-
* Can also be directly used by builder, e. g. in order to generate an index.html
|
|
18
|
-
* after processing several configurations in order to build different sets of
|
|
19
|
-
* bundles for differential serving.
|
|
20
|
-
*/
|
|
21
|
-
// eslint-disable-next-line max-lines-per-function
|
|
22
|
-
async function augmentIndexHtml(params) {
|
|
23
|
-
const { loadOutputFile, files, entrypoints, sri, deployUrl = '', lang, baseHref, html, imageDomains, } = params;
|
|
24
|
-
const warnings = [];
|
|
25
|
-
const errors = [];
|
|
26
|
-
let { crossOrigin = 'none' } = params;
|
|
27
|
-
if (sri && crossOrigin === 'none') {
|
|
28
|
-
crossOrigin = 'anonymous';
|
|
29
|
-
}
|
|
30
|
-
const stylesheets = new Set();
|
|
31
|
-
const scripts = new Map();
|
|
32
|
-
// Sort files in the order we want to insert them by entrypoint
|
|
33
|
-
for (const [entrypoint, isModule] of entrypoints) {
|
|
34
|
-
for (const { extension, file, name } of files) {
|
|
35
|
-
if (name !== entrypoint || scripts.has(file) || stylesheets.has(file)) {
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
switch (extension) {
|
|
39
|
-
case '.js':
|
|
40
|
-
// Also, non entrypoints need to be loaded as no module as they can contain problematic code.
|
|
41
|
-
scripts.set(file, isModule);
|
|
42
|
-
break;
|
|
43
|
-
case '.mjs':
|
|
44
|
-
if (!isModule) {
|
|
45
|
-
// It would be very confusing to link an `*.mjs` file in a non-module script context,
|
|
46
|
-
// so we disallow it entirely.
|
|
47
|
-
throw new Error('`.mjs` files *must* set `isModule` to `true`.');
|
|
48
|
-
}
|
|
49
|
-
scripts.set(file, true /* isModule */);
|
|
50
|
-
break;
|
|
51
|
-
case '.css':
|
|
52
|
-
stylesheets.add(file);
|
|
53
|
-
break;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
let scriptTags = [];
|
|
58
|
-
for (const [src, isModule] of scripts) {
|
|
59
|
-
const attrs = [`src="${deployUrl}${src}"`];
|
|
60
|
-
// This is also need for non entry-points as they may contain problematic code.
|
|
61
|
-
if (isModule) {
|
|
62
|
-
attrs.push('type="module"');
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
attrs.push('defer');
|
|
66
|
-
}
|
|
67
|
-
if (crossOrigin !== 'none') {
|
|
68
|
-
attrs.push(`crossorigin="${crossOrigin}"`);
|
|
69
|
-
}
|
|
70
|
-
if (sri) {
|
|
71
|
-
const content = await loadOutputFile(src);
|
|
72
|
-
attrs.push(generateSriAttributes(content));
|
|
73
|
-
}
|
|
74
|
-
scriptTags.push(`<script ${attrs.join(' ')}></script>`);
|
|
75
|
-
}
|
|
76
|
-
let linkTags = [];
|
|
77
|
-
for (const src of stylesheets) {
|
|
78
|
-
const attrs = [`rel="stylesheet"`, `href="${deployUrl}${src}"`];
|
|
79
|
-
if (crossOrigin !== 'none') {
|
|
80
|
-
attrs.push(`crossorigin="${crossOrigin}"`);
|
|
81
|
-
}
|
|
82
|
-
if (sri) {
|
|
83
|
-
const content = await loadOutputFile(src);
|
|
84
|
-
attrs.push(generateSriAttributes(content));
|
|
85
|
-
}
|
|
86
|
-
linkTags.push(`<link ${attrs.join(' ')}>`);
|
|
87
|
-
}
|
|
88
|
-
if (params.hints?.length) {
|
|
89
|
-
for (const hint of params.hints) {
|
|
90
|
-
const attrs = [`rel="${hint.mode}"`, `href="${deployUrl}${hint.url}"`];
|
|
91
|
-
if (hint.mode !== 'modulepreload' && crossOrigin !== 'none') {
|
|
92
|
-
// Value is considered anonymous by the browser when not present or empty
|
|
93
|
-
attrs.push(crossOrigin === 'anonymous' ? 'crossorigin' : `crossorigin="${crossOrigin}"`);
|
|
94
|
-
}
|
|
95
|
-
if (hint.mode === 'preload' || hint.mode === 'prefetch') {
|
|
96
|
-
switch ((0, node_path_1.extname)(hint.url)) {
|
|
97
|
-
case '.js':
|
|
98
|
-
attrs.push('as="script"');
|
|
99
|
-
break;
|
|
100
|
-
case '.css':
|
|
101
|
-
attrs.push('as="style"');
|
|
102
|
-
break;
|
|
103
|
-
default:
|
|
104
|
-
if (hint.as) {
|
|
105
|
-
attrs.push(`as="${hint.as}"`);
|
|
106
|
-
}
|
|
107
|
-
break;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
if (sri &&
|
|
111
|
-
(hint.mode === 'preload' || hint.mode === 'prefetch' || hint.mode === 'modulepreload')) {
|
|
112
|
-
const content = await loadOutputFile(hint.url);
|
|
113
|
-
attrs.push(generateSriAttributes(content));
|
|
114
|
-
}
|
|
115
|
-
linkTags.push(`<link ${attrs.join(' ')}>`);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
const dir = lang ? await getLanguageDirection(lang, warnings) : undefined;
|
|
119
|
-
const { rewriter, transformedContent } = await (0, html_rewriting_stream_1.htmlRewritingStream)(html);
|
|
120
|
-
const baseTagExists = html.includes('<base');
|
|
121
|
-
const foundPreconnects = new Set();
|
|
122
|
-
rewriter
|
|
123
|
-
.on('startTag', (tag) => {
|
|
124
|
-
switch (tag.tagName) {
|
|
125
|
-
case 'html':
|
|
126
|
-
// Adjust document locale if specified
|
|
127
|
-
if (isString(lang)) {
|
|
128
|
-
updateAttribute(tag, 'lang', lang);
|
|
129
|
-
}
|
|
130
|
-
if (dir) {
|
|
131
|
-
updateAttribute(tag, 'dir', dir);
|
|
132
|
-
}
|
|
133
|
-
break;
|
|
134
|
-
case 'head':
|
|
135
|
-
// Base href should be added before any link, meta tags
|
|
136
|
-
if (!baseTagExists && isString(baseHref)) {
|
|
137
|
-
rewriter.emitStartTag(tag);
|
|
138
|
-
rewriter.emitRaw(`<base href="${baseHref}">`);
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
break;
|
|
142
|
-
case 'base':
|
|
143
|
-
// Adjust base href if specified
|
|
144
|
-
if (isString(baseHref)) {
|
|
145
|
-
updateAttribute(tag, 'href', baseHref);
|
|
146
|
-
}
|
|
147
|
-
break;
|
|
148
|
-
case 'link':
|
|
149
|
-
if (readAttribute(tag, 'rel') === 'preconnect') {
|
|
150
|
-
const href = readAttribute(tag, 'href');
|
|
151
|
-
if (href) {
|
|
152
|
-
foundPreconnects.add(href);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
rewriter.emitStartTag(tag);
|
|
157
|
-
})
|
|
158
|
-
.on('endTag', (tag) => {
|
|
159
|
-
switch (tag.tagName) {
|
|
160
|
-
case 'head':
|
|
161
|
-
for (const linkTag of linkTags) {
|
|
162
|
-
rewriter.emitRaw(linkTag);
|
|
163
|
-
}
|
|
164
|
-
if (imageDomains) {
|
|
165
|
-
for (const imageDomain of imageDomains) {
|
|
166
|
-
if (!foundPreconnects.has(imageDomain)) {
|
|
167
|
-
rewriter.emitRaw(`<link rel="preconnect" href="${imageDomain}" data-ngimg>`);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
linkTags = [];
|
|
172
|
-
break;
|
|
173
|
-
case 'body':
|
|
174
|
-
// Add script tags
|
|
175
|
-
for (const scriptTag of scriptTags) {
|
|
176
|
-
rewriter.emitRaw(scriptTag);
|
|
177
|
-
}
|
|
178
|
-
scriptTags = [];
|
|
179
|
-
break;
|
|
180
|
-
}
|
|
181
|
-
rewriter.emitEndTag(tag);
|
|
182
|
-
});
|
|
183
|
-
const content = await transformedContent();
|
|
184
|
-
return {
|
|
185
|
-
content: linkTags.length || scriptTags.length
|
|
186
|
-
? // In case no body/head tags are not present (dotnet partial templates)
|
|
187
|
-
linkTags.join('') + scriptTags.join('') + content
|
|
188
|
-
: content,
|
|
189
|
-
warnings,
|
|
190
|
-
errors,
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
exports.augmentIndexHtml = augmentIndexHtml;
|
|
194
|
-
function generateSriAttributes(content) {
|
|
195
|
-
const algo = 'sha384';
|
|
196
|
-
const hash = (0, node_crypto_1.createHash)(algo).update(content, 'utf8').digest('base64');
|
|
197
|
-
return `integrity="${algo}-${hash}"`;
|
|
198
|
-
}
|
|
199
|
-
function updateAttribute(tag, name, value) {
|
|
200
|
-
const index = tag.attrs.findIndex((a) => a.name === name);
|
|
201
|
-
const newValue = { name, value };
|
|
202
|
-
if (index === -1) {
|
|
203
|
-
tag.attrs.push(newValue);
|
|
204
|
-
}
|
|
205
|
-
else {
|
|
206
|
-
tag.attrs[index] = newValue;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
function readAttribute(tag, name) {
|
|
210
|
-
const targetAttr = tag.attrs.find((attr) => attr.name === name);
|
|
211
|
-
return targetAttr ? targetAttr.value : undefined;
|
|
212
|
-
}
|
|
213
|
-
function isString(value) {
|
|
214
|
-
return typeof value === 'string';
|
|
215
|
-
}
|
|
216
|
-
async function getLanguageDirection(locale, warnings) {
|
|
217
|
-
const dir = await getLanguageDirectionFromLocales(locale);
|
|
218
|
-
if (!dir) {
|
|
219
|
-
warnings.push(`Locale data for '${locale}' cannot be found. 'dir' attribute will not be set for this locale.`);
|
|
220
|
-
}
|
|
221
|
-
return dir;
|
|
222
|
-
}
|
|
223
|
-
async function getLanguageDirectionFromLocales(locale) {
|
|
224
|
-
try {
|
|
225
|
-
const localeData = (await (0, load_esm_1.loadEsmModule)(`@angular/common/locales/${locale}`)).default;
|
|
226
|
-
const dir = localeData[localeData.length - 2];
|
|
227
|
-
return isString(dir) ? dir : undefined;
|
|
228
|
-
}
|
|
229
|
-
catch {
|
|
230
|
-
// In some cases certain locales might map to files which are named only with language id.
|
|
231
|
-
// Example: `en-US` -> `en`.
|
|
232
|
-
const [languageId] = locale.split('-', 1);
|
|
233
|
-
if (languageId !== locale) {
|
|
234
|
-
return getLanguageDirectionFromLocales(languageId);
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
return undefined;
|
|
238
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright Google LLC All Rights Reserved.
|
|
4
|
-
*
|
|
5
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
-
* found in the LICENSE file at https://angular.io/license
|
|
7
|
-
*/
|
|
8
|
-
export declare function htmlRewritingStream(content: string): Promise<{
|
|
9
|
-
rewriter: import('parse5-html-rewriting-stream').RewritingStream;
|
|
10
|
-
transformedContent: () => Promise<string>;
|
|
11
|
-
}>;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @license
|
|
4
|
-
* Copyright Google LLC All Rights Reserved.
|
|
5
|
-
*
|
|
6
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
-
* found in the LICENSE file at https://angular.io/license
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.htmlRewritingStream = void 0;
|
|
11
|
-
const node_stream_1 = require("node:stream");
|
|
12
|
-
const promises_1 = require("node:stream/promises");
|
|
13
|
-
const load_esm_1 = require("../load-esm");
|
|
14
|
-
async function htmlRewritingStream(content) {
|
|
15
|
-
const { RewritingStream } = await (0, load_esm_1.loadEsmModule)('parse5-html-rewriting-stream');
|
|
16
|
-
const rewriter = new RewritingStream();
|
|
17
|
-
return {
|
|
18
|
-
rewriter,
|
|
19
|
-
transformedContent: () => (0, promises_1.pipeline)(node_stream_1.Readable.from(content), rewriter, async function (source) {
|
|
20
|
-
const chunks = [];
|
|
21
|
-
for await (const chunk of source) {
|
|
22
|
-
chunks.push(Buffer.from(chunk));
|
|
23
|
-
}
|
|
24
|
-
return Buffer.concat(chunks).toString('utf-8');
|
|
25
|
-
}),
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
exports.htmlRewritingStream = htmlRewritingStream;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright Google LLC All Rights Reserved.
|
|
4
|
-
*
|
|
5
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
-
* found in the LICENSE file at https://angular.io/license
|
|
7
|
-
*/
|
|
8
|
-
import { NormalizedCachedOptions } from '../normalize-cache';
|
|
9
|
-
import { NormalizedOptimizationOptions } from '../normalize-optimization';
|
|
10
|
-
import { CrossOriginValue, Entrypoint, FileInfo } from './augment-index-html';
|
|
11
|
-
export type HintMode = 'prefetch' | 'preload' | 'modulepreload' | 'preconnect' | 'dns-prefetch';
|
|
12
|
-
export interface IndexHtmlGeneratorProcessOptions {
|
|
13
|
-
lang: string | undefined;
|
|
14
|
-
baseHref: string | undefined;
|
|
15
|
-
outputPath: string;
|
|
16
|
-
files: FileInfo[];
|
|
17
|
-
hints?: {
|
|
18
|
-
url: string;
|
|
19
|
-
mode: HintMode;
|
|
20
|
-
as?: string;
|
|
21
|
-
}[];
|
|
22
|
-
}
|
|
23
|
-
export interface IndexHtmlGeneratorOptions {
|
|
24
|
-
indexPath: string;
|
|
25
|
-
deployUrl?: string;
|
|
26
|
-
sri?: boolean;
|
|
27
|
-
entrypoints: Entrypoint[];
|
|
28
|
-
postTransform?: IndexHtmlTransform;
|
|
29
|
-
crossOrigin?: CrossOriginValue;
|
|
30
|
-
optimization?: NormalizedOptimizationOptions;
|
|
31
|
-
cache?: NormalizedCachedOptions;
|
|
32
|
-
imageDomains?: string[];
|
|
33
|
-
}
|
|
34
|
-
export type IndexHtmlTransform = (content: string) => Promise<string>;
|
|
35
|
-
export interface IndexHtmlTransformResult {
|
|
36
|
-
content: string;
|
|
37
|
-
warnings: string[];
|
|
38
|
-
errors: string[];
|
|
39
|
-
}
|
|
40
|
-
export declare class IndexHtmlGenerator {
|
|
41
|
-
readonly options: IndexHtmlGeneratorOptions;
|
|
42
|
-
private readonly plugins;
|
|
43
|
-
constructor(options: IndexHtmlGeneratorOptions);
|
|
44
|
-
process(options: IndexHtmlGeneratorProcessOptions): Promise<IndexHtmlTransformResult>;
|
|
45
|
-
readAsset(path: string): Promise<string>;
|
|
46
|
-
protected readIndex(path: string): Promise<string>;
|
|
47
|
-
}
|