@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,22 +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 type { ESMInMemoryFileLoaderWorkerData } from './esm-in-memory-loader/loader-hooks';
|
|
9
|
-
import { RenderResult, ServerContext } from './render-page';
|
|
10
|
-
export interface RenderWorkerData extends ESMInMemoryFileLoaderWorkerData {
|
|
11
|
-
document: string;
|
|
12
|
-
inlineCriticalCss?: boolean;
|
|
13
|
-
assetFiles: Record</** Destination */ string, /** Source */ string>;
|
|
14
|
-
}
|
|
15
|
-
export interface RenderOptions {
|
|
16
|
-
route: string;
|
|
17
|
-
serverContext: ServerContext;
|
|
18
|
-
}
|
|
19
|
-
/** Renders an application based on a provided options. */
|
|
20
|
-
declare function render(options: RenderOptions): Promise<RenderResult>;
|
|
21
|
-
declare const _default: typeof render;
|
|
22
|
-
export default _default;
|
|
@@ -1,30 +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
|
-
const node_worker_threads_1 = require("node:worker_threads");
|
|
11
|
-
const fetch_patch_1 = require("./fetch-patch");
|
|
12
|
-
const render_page_1 = require("./render-page");
|
|
13
|
-
/**
|
|
14
|
-
* This is passed as workerData when setting up the worker via the `piscina` package.
|
|
15
|
-
*/
|
|
16
|
-
const { outputFiles, document, inlineCriticalCss } = node_worker_threads_1.workerData;
|
|
17
|
-
/** Renders an application based on a provided options. */
|
|
18
|
-
function render(options) {
|
|
19
|
-
return (0, render_page_1.renderPage)({
|
|
20
|
-
...options,
|
|
21
|
-
outputFiles,
|
|
22
|
-
document,
|
|
23
|
-
inlineCriticalCss,
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
function initialize() {
|
|
27
|
-
(0, fetch_patch_1.patchFetchToLoadInMemoryAssets)();
|
|
28
|
-
return render;
|
|
29
|
-
}
|
|
30
|
-
exports.default = initialize();
|
|
@@ -1,21 +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 type { ESMInMemoryFileLoaderWorkerData } from './esm-in-memory-loader/loader-hooks';
|
|
9
|
-
export interface RoutesExtractorWorkerData extends ESMInMemoryFileLoaderWorkerData {
|
|
10
|
-
document: string;
|
|
11
|
-
verbose: boolean;
|
|
12
|
-
assetFiles: Record</** Destination */ string, /** Source */ string>;
|
|
13
|
-
}
|
|
14
|
-
export interface RoutersExtractorWorkerResult {
|
|
15
|
-
routes: string[];
|
|
16
|
-
warnings?: string[];
|
|
17
|
-
}
|
|
18
|
-
/** Renders an application based on a provided options. */
|
|
19
|
-
declare function extractRoutes(): Promise<RoutersExtractorWorkerResult>;
|
|
20
|
-
declare const _default: typeof extractRoutes;
|
|
21
|
-
export default _default;
|
|
@@ -1,53 +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
|
-
const node_worker_threads_1 = require("node:worker_threads");
|
|
11
|
-
const fetch_patch_1 = require("./fetch-patch");
|
|
12
|
-
const load_esm_from_memory_1 = require("./load-esm-from-memory");
|
|
13
|
-
/**
|
|
14
|
-
* This is passed as workerData when setting up the worker via the `piscina` package.
|
|
15
|
-
*/
|
|
16
|
-
const { document, verbose } = node_worker_threads_1.workerData;
|
|
17
|
-
/** Renders an application based on a provided options. */
|
|
18
|
-
async function extractRoutes() {
|
|
19
|
-
const { extractRoutes } = await (0, load_esm_from_memory_1.loadEsmModuleFromMemory)('./render-utils.server.mjs');
|
|
20
|
-
const { default: bootstrapAppFnOrModule } = await (0, load_esm_from_memory_1.loadEsmModuleFromMemory)('./main.server.mjs');
|
|
21
|
-
const skippedRedirects = [];
|
|
22
|
-
const skippedOthers = [];
|
|
23
|
-
const routes = [];
|
|
24
|
-
for await (const { route, success, redirect } of extractRoutes(bootstrapAppFnOrModule, document)) {
|
|
25
|
-
if (success) {
|
|
26
|
-
routes.push(route);
|
|
27
|
-
continue;
|
|
28
|
-
}
|
|
29
|
-
if (redirect) {
|
|
30
|
-
skippedRedirects.push(route);
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
skippedOthers.push(route);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
if (!verbose) {
|
|
37
|
-
return { routes };
|
|
38
|
-
}
|
|
39
|
-
let warnings;
|
|
40
|
-
if (skippedOthers.length) {
|
|
41
|
-
(warnings ??= []).push('The following routes were skipped from prerendering because they contain routes with dynamic parameters:\n' +
|
|
42
|
-
skippedOthers.join('\n'));
|
|
43
|
-
}
|
|
44
|
-
if (skippedRedirects.length) {
|
|
45
|
-
(warnings ??= []).push('The following routes were skipped from prerendering because they contain redirects:\n', skippedRedirects.join('\n'));
|
|
46
|
-
}
|
|
47
|
-
return { routes, warnings };
|
|
48
|
-
}
|
|
49
|
-
function initialize() {
|
|
50
|
-
(0, fetch_patch_1.patchFetchToLoadInMemoryAssets)();
|
|
51
|
-
return extractRoutes;
|
|
52
|
-
}
|
|
53
|
-
exports.default = initialize();
|
|
@@ -1,25 +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
|
-
/// <reference types="node" />
|
|
9
|
-
/// <reference types="node" />
|
|
10
|
-
import type { Config, Filesystem } from '@angular/service-worker/config';
|
|
11
|
-
import { promises as fsPromises } from 'node:fs';
|
|
12
|
-
import { BuildOutputFile } from '../tools/esbuild/bundler-context';
|
|
13
|
-
import { BuildOutputAsset } from '../tools/esbuild/bundler-execution-result';
|
|
14
|
-
export declare function augmentAppWithServiceWorker(appRoot: string, workspaceRoot: string, outputPath: string, baseHref: string, ngswConfigPath?: string, inputputFileSystem?: typeof fsPromises, outputFileSystem?: typeof fsPromises): Promise<void>;
|
|
15
|
-
export declare function augmentAppWithServiceWorkerEsbuild(workspaceRoot: string, configPath: string, baseHref: string, indexHtml: string | undefined, outputFiles: BuildOutputFile[], assetFiles: BuildOutputAsset[]): Promise<{
|
|
16
|
-
manifest: string;
|
|
17
|
-
assetFiles: BuildOutputAsset[];
|
|
18
|
-
}>;
|
|
19
|
-
export declare function augmentAppWithServiceWorkerCore(config: Config, serviceWorkerFilesystem: Filesystem, baseHref: string): Promise<{
|
|
20
|
-
manifest: string;
|
|
21
|
-
assetFiles: {
|
|
22
|
-
source: string;
|
|
23
|
-
destination: string;
|
|
24
|
-
}[];
|
|
25
|
-
}>;
|
|
@@ -1,211 +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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
-
}
|
|
15
|
-
Object.defineProperty(o, k2, desc);
|
|
16
|
-
}) : (function(o, m, k, k2) {
|
|
17
|
-
if (k2 === undefined) k2 = k;
|
|
18
|
-
o[k2] = m[k];
|
|
19
|
-
}));
|
|
20
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
-
}) : function(o, v) {
|
|
23
|
-
o["default"] = v;
|
|
24
|
-
});
|
|
25
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
26
|
-
if (mod && mod.__esModule) return mod;
|
|
27
|
-
var result = {};
|
|
28
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
29
|
-
__setModuleDefault(result, mod);
|
|
30
|
-
return result;
|
|
31
|
-
};
|
|
32
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
-
exports.augmentAppWithServiceWorkerCore = exports.augmentAppWithServiceWorkerEsbuild = exports.augmentAppWithServiceWorker = void 0;
|
|
34
|
-
const crypto = __importStar(require("crypto"));
|
|
35
|
-
const node_fs_1 = require("node:fs");
|
|
36
|
-
const path = __importStar(require("path"));
|
|
37
|
-
const bundler_context_1 = require("../tools/esbuild/bundler-context");
|
|
38
|
-
const error_1 = require("./error");
|
|
39
|
-
const load_esm_1 = require("./load-esm");
|
|
40
|
-
class CliFilesystem {
|
|
41
|
-
fs;
|
|
42
|
-
base;
|
|
43
|
-
constructor(fs, base) {
|
|
44
|
-
this.fs = fs;
|
|
45
|
-
this.base = base;
|
|
46
|
-
}
|
|
47
|
-
list(dir) {
|
|
48
|
-
return this._recursiveList(this._resolve(dir), []);
|
|
49
|
-
}
|
|
50
|
-
read(file) {
|
|
51
|
-
return this.fs.readFile(this._resolve(file), 'utf-8');
|
|
52
|
-
}
|
|
53
|
-
async hash(file) {
|
|
54
|
-
return crypto
|
|
55
|
-
.createHash('sha1')
|
|
56
|
-
.update(await this.fs.readFile(this._resolve(file)))
|
|
57
|
-
.digest('hex');
|
|
58
|
-
}
|
|
59
|
-
write(_file, _content) {
|
|
60
|
-
throw new Error('This should never happen.');
|
|
61
|
-
}
|
|
62
|
-
_resolve(file) {
|
|
63
|
-
return path.join(this.base, file);
|
|
64
|
-
}
|
|
65
|
-
async _recursiveList(dir, items) {
|
|
66
|
-
const subdirectories = [];
|
|
67
|
-
for (const entry of await this.fs.readdir(dir)) {
|
|
68
|
-
const entryPath = path.join(dir, entry);
|
|
69
|
-
const stats = await this.fs.stat(entryPath);
|
|
70
|
-
if (stats.isFile()) {
|
|
71
|
-
// Uses posix paths since the service worker expects URLs
|
|
72
|
-
items.push('/' + path.relative(this.base, entryPath).replace(/\\/g, '/'));
|
|
73
|
-
}
|
|
74
|
-
else if (stats.isDirectory()) {
|
|
75
|
-
subdirectories.push(entryPath);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
for (const subdirectory of subdirectories) {
|
|
79
|
-
await this._recursiveList(subdirectory, items);
|
|
80
|
-
}
|
|
81
|
-
return items;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
class ResultFilesystem {
|
|
85
|
-
fileReaders = new Map();
|
|
86
|
-
constructor(outputFiles, assetFiles) {
|
|
87
|
-
for (const file of outputFiles) {
|
|
88
|
-
if (file.type === bundler_context_1.BuildOutputFileType.Media || file.type === bundler_context_1.BuildOutputFileType.Browser) {
|
|
89
|
-
this.fileReaders.set('/' + file.path.replace(/\\/g, '/'), async () => file.contents);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
for (const file of assetFiles) {
|
|
93
|
-
this.fileReaders.set('/' + file.destination.replace(/\\/g, '/'), () => node_fs_1.promises.readFile(file.source));
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
async list(dir) {
|
|
97
|
-
if (dir !== '/') {
|
|
98
|
-
throw new Error('Serviceworker manifest generator should only list files from root.');
|
|
99
|
-
}
|
|
100
|
-
return [...this.fileReaders.keys()];
|
|
101
|
-
}
|
|
102
|
-
async read(file) {
|
|
103
|
-
const reader = this.fileReaders.get(file);
|
|
104
|
-
if (reader === undefined) {
|
|
105
|
-
throw new Error('File does not exist.');
|
|
106
|
-
}
|
|
107
|
-
const contents = await reader();
|
|
108
|
-
return Buffer.from(contents.buffer, contents.byteOffset, contents.byteLength).toString('utf-8');
|
|
109
|
-
}
|
|
110
|
-
async hash(file) {
|
|
111
|
-
const reader = this.fileReaders.get(file);
|
|
112
|
-
if (reader === undefined) {
|
|
113
|
-
throw new Error('File does not exist.');
|
|
114
|
-
}
|
|
115
|
-
return crypto
|
|
116
|
-
.createHash('sha1')
|
|
117
|
-
.update(await reader())
|
|
118
|
-
.digest('hex');
|
|
119
|
-
}
|
|
120
|
-
write() {
|
|
121
|
-
throw new Error('Serviceworker manifest generator should not attempted to write.');
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
async function augmentAppWithServiceWorker(appRoot, workspaceRoot, outputPath, baseHref, ngswConfigPath, inputputFileSystem = node_fs_1.promises, outputFileSystem = node_fs_1.promises) {
|
|
125
|
-
// Determine the configuration file path
|
|
126
|
-
const configPath = ngswConfigPath
|
|
127
|
-
? path.join(workspaceRoot, ngswConfigPath)
|
|
128
|
-
: path.join(appRoot, 'ngsw-config.json');
|
|
129
|
-
// Read the configuration file
|
|
130
|
-
let config;
|
|
131
|
-
try {
|
|
132
|
-
const configurationData = await inputputFileSystem.readFile(configPath, 'utf-8');
|
|
133
|
-
config = JSON.parse(configurationData);
|
|
134
|
-
}
|
|
135
|
-
catch (error) {
|
|
136
|
-
(0, error_1.assertIsError)(error);
|
|
137
|
-
if (error.code === 'ENOENT') {
|
|
138
|
-
throw new Error('Error: Expected to find an ngsw-config.json configuration file' +
|
|
139
|
-
` in the ${appRoot} folder. Either provide one or` +
|
|
140
|
-
' disable Service Worker in the angular.json configuration file.');
|
|
141
|
-
}
|
|
142
|
-
else {
|
|
143
|
-
throw error;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
const result = await augmentAppWithServiceWorkerCore(config, new CliFilesystem(outputFileSystem, outputPath), baseHref);
|
|
147
|
-
const copy = async (src, dest) => {
|
|
148
|
-
const resolvedDest = path.join(outputPath, dest);
|
|
149
|
-
return inputputFileSystem === outputFileSystem
|
|
150
|
-
? // Native FS (Builder).
|
|
151
|
-
inputputFileSystem.copyFile(src, resolvedDest, node_fs_1.constants.COPYFILE_FICLONE)
|
|
152
|
-
: // memfs (Webpack): Read the file from the input FS (disk) and write it to the output FS (memory).
|
|
153
|
-
outputFileSystem.writeFile(resolvedDest, await inputputFileSystem.readFile(src));
|
|
154
|
-
};
|
|
155
|
-
await outputFileSystem.writeFile(path.join(outputPath, 'ngsw.json'), result.manifest);
|
|
156
|
-
for (const { source, destination } of result.assetFiles) {
|
|
157
|
-
await copy(source, destination);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
exports.augmentAppWithServiceWorker = augmentAppWithServiceWorker;
|
|
161
|
-
// This is currently used by the esbuild-based builder
|
|
162
|
-
async function augmentAppWithServiceWorkerEsbuild(workspaceRoot, configPath, baseHref, indexHtml, outputFiles, assetFiles) {
|
|
163
|
-
// Read the configuration file
|
|
164
|
-
let config;
|
|
165
|
-
try {
|
|
166
|
-
const configurationData = await node_fs_1.promises.readFile(configPath, 'utf-8');
|
|
167
|
-
config = JSON.parse(configurationData);
|
|
168
|
-
if (indexHtml) {
|
|
169
|
-
config.index = indexHtml;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
catch (error) {
|
|
173
|
-
(0, error_1.assertIsError)(error);
|
|
174
|
-
if (error.code === 'ENOENT') {
|
|
175
|
-
// TODO: Generate an error object that can be consumed by the esbuild-based builder
|
|
176
|
-
const message = `Service worker configuration file "${path.relative(workspaceRoot, configPath)}" could not be found.`;
|
|
177
|
-
throw new Error(message);
|
|
178
|
-
}
|
|
179
|
-
else {
|
|
180
|
-
throw error;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
return augmentAppWithServiceWorkerCore(config, new ResultFilesystem(outputFiles, assetFiles), baseHref);
|
|
184
|
-
}
|
|
185
|
-
exports.augmentAppWithServiceWorkerEsbuild = augmentAppWithServiceWorkerEsbuild;
|
|
186
|
-
async function augmentAppWithServiceWorkerCore(config, serviceWorkerFilesystem, baseHref) {
|
|
187
|
-
// Load ESM `@angular/service-worker/config` using the TypeScript dynamic import workaround.
|
|
188
|
-
// Once TypeScript provides support for keeping the dynamic import this workaround can be
|
|
189
|
-
// changed to a direct dynamic import.
|
|
190
|
-
const GeneratorConstructor = (await (0, load_esm_1.loadEsmModule)('@angular/service-worker/config')).Generator;
|
|
191
|
-
// Generate the manifest
|
|
192
|
-
const generator = new GeneratorConstructor(serviceWorkerFilesystem, baseHref);
|
|
193
|
-
const output = await generator.process(config);
|
|
194
|
-
// Write the manifest
|
|
195
|
-
const manifest = JSON.stringify(output, null, 2);
|
|
196
|
-
// Find the service worker package
|
|
197
|
-
const workerPath = require.resolve('@angular/service-worker/ngsw-worker.js');
|
|
198
|
-
const result = {
|
|
199
|
-
manifest,
|
|
200
|
-
// Main worker code
|
|
201
|
-
assetFiles: [{ source: workerPath, destination: 'ngsw-worker.js' }],
|
|
202
|
-
};
|
|
203
|
-
// If present, write the safety worker code
|
|
204
|
-
const safetyPath = path.join(path.dirname(workerPath), 'safety-worker.js');
|
|
205
|
-
if ((0, node_fs_1.existsSync)(safetyPath)) {
|
|
206
|
-
result.assetFiles.push({ source: safetyPath, destination: 'worker-basic.min.js' });
|
|
207
|
-
result.assetFiles.push({ source: safetyPath, destination: 'safety-worker.js' });
|
|
208
|
-
}
|
|
209
|
-
return result;
|
|
210
|
-
}
|
|
211
|
-
exports.augmentAppWithServiceWorkerCore = augmentAppWithServiceWorkerCore;
|
|
@@ -1,10 +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 getSupportedBrowsers(projectRoot: string, logger: {
|
|
9
|
-
warn(message: string): void;
|
|
10
|
-
}): string[];
|
|
@@ -1,42 +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.getSupportedBrowsers = void 0;
|
|
14
|
-
const browserslist_1 = __importDefault(require("browserslist"));
|
|
15
|
-
function getSupportedBrowsers(projectRoot, logger) {
|
|
16
|
-
browserslist_1.default.defaults = [
|
|
17
|
-
'last 2 Chrome versions',
|
|
18
|
-
'last 1 Firefox version',
|
|
19
|
-
'last 2 Edge major versions',
|
|
20
|
-
'last 2 Safari major versions',
|
|
21
|
-
'last 2 iOS major versions',
|
|
22
|
-
'Firefox ESR',
|
|
23
|
-
];
|
|
24
|
-
// Get browsers from config or default.
|
|
25
|
-
const browsersFromConfigOrDefault = new Set((0, browserslist_1.default)(undefined, { path: projectRoot }));
|
|
26
|
-
// Get browsers that support ES6 modules.
|
|
27
|
-
const browsersThatSupportEs6 = new Set((0, browserslist_1.default)('supports es6-module'));
|
|
28
|
-
const unsupportedBrowsers = [];
|
|
29
|
-
for (const browser of browsersFromConfigOrDefault) {
|
|
30
|
-
if (!browsersThatSupportEs6.has(browser)) {
|
|
31
|
-
browsersFromConfigOrDefault.delete(browser);
|
|
32
|
-
unsupportedBrowsers.push(browser);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
if (unsupportedBrowsers.length) {
|
|
36
|
-
logger.warn(`One or more browsers which are configured in the project's Browserslist configuration ` +
|
|
37
|
-
'will be ignored as ES5 output is not supported by the Angular CLI.\n' +
|
|
38
|
-
`Ignored browsers: ${unsupportedBrowsers.join(', ')}`);
|
|
39
|
-
}
|
|
40
|
-
return Array.from(browsersFromConfigOrDefault);
|
|
41
|
-
}
|
|
42
|
-
exports.getSupportedBrowsers = getSupportedBrowsers;
|
package/src/utils/version.d.ts
DELETED
|
@@ -1,8 +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 assertCompatibleAngularVersion(projectRoot: string): void | never;
|
package/src/utils/version.js
DELETED
|
@@ -1,59 +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.assertCompatibleAngularVersion = void 0;
|
|
11
|
-
/* eslint-disable no-console */
|
|
12
|
-
const node_module_1 = require("node:module");
|
|
13
|
-
const semver_1 = require("semver");
|
|
14
|
-
function assertCompatibleAngularVersion(projectRoot) {
|
|
15
|
-
let angularCliPkgJson;
|
|
16
|
-
let angularPkgJson;
|
|
17
|
-
// Create a custom require function for ESM compliance.
|
|
18
|
-
// NOTE: The trailing slash is significant.
|
|
19
|
-
const projectRequire = (0, node_module_1.createRequire)(projectRoot + '/');
|
|
20
|
-
try {
|
|
21
|
-
const angularPackagePath = projectRequire.resolve('@angular/core/package.json');
|
|
22
|
-
angularPkgJson = projectRequire(angularPackagePath);
|
|
23
|
-
}
|
|
24
|
-
catch {
|
|
25
|
-
console.error('You seem to not be depending on "@angular/core". This is an error.');
|
|
26
|
-
process.exit(2);
|
|
27
|
-
}
|
|
28
|
-
if (!(angularPkgJson && angularPkgJson['version'])) {
|
|
29
|
-
console.error('Cannot determine versions of "@angular/core".\n' +
|
|
30
|
-
'This likely means your local installation is broken. Please reinstall your packages.');
|
|
31
|
-
process.exit(2);
|
|
32
|
-
}
|
|
33
|
-
try {
|
|
34
|
-
const angularCliPkgPath = projectRequire.resolve('@angular/cli/package.json');
|
|
35
|
-
angularCliPkgJson = projectRequire(angularCliPkgPath);
|
|
36
|
-
if (!(angularCliPkgJson && angularCliPkgJson['version'])) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
catch {
|
|
41
|
-
// Not using @angular-devkit/build-angular with @angular/cli is ok too.
|
|
42
|
-
// In this case we don't provide as many version checks.
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
if (angularCliPkgJson['version'] === '0.0.0' || angularPkgJson['version'] === '0.0.0') {
|
|
46
|
-
// Internal CLI testing version or integration testing in the angular/angular
|
|
47
|
-
// repository with the generated development @angular/core npm package which is versioned "0.0.0".
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
const supportedAngularSemver = projectRequire('@angular-devkit/build-angular/package.json')['peerDependencies']['@angular/compiler-cli'];
|
|
51
|
-
const angularVersion = new semver_1.SemVer(angularPkgJson['version']);
|
|
52
|
-
if (!(0, semver_1.satisfies)(angularVersion, supportedAngularSemver, { includePrerelease: true })) {
|
|
53
|
-
console.error(`This version of CLI is only compatible with Angular versions ${supportedAngularSemver},\n` +
|
|
54
|
-
`but Angular version ${angularVersion} was found instead.\n` +
|
|
55
|
-
'Please visit the link below to find instructions on how to update Angular.\nhttps://update.angular.io/');
|
|
56
|
-
process.exit(3);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
exports.assertCompatibleAngularVersion = assertCompatibleAngularVersion;
|