@angular-devkit/build-angular 18.0.0-next.3 → 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 +14 -13
- package/src/builders/app-shell/index.js +3 -5
- package/src/builders/browser/index.d.ts +1 -1
- package/src/builders/browser/index.js +8 -12
- 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 +3 -4
- 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 +7 -7
- 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 +1 -1
- package/src/tools/webpack/plugins/any-component-style-budget-checker.js +5 -5
- 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 +2 -2
- 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 -1
- package/src/tools/webpack/utils/stats.js +2 -2
- package/src/utils/i18n-webpack.d.ts +1 -1
- package/src/utils/i18n-webpack.js +5 -6
- 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/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 -125
- package/src/builders/application/execute-post-bundle.d.ts +0 -25
- package/src/builders/application/execute-post-bundle.js +0 -93
- 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 -369
- 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 -441
- 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 -81
- 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 -147
- 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 -114
- 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 -334
- package/src/tools/sass/sass-service.d.ts +0 -72
- 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 -192
- 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 -303
- 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/format-bytes.d.ts +0 -8
- package/src/utils/format-bytes.js +0 -22
- package/src/utils/i18n-options.d.ts +0 -33
- package/src/utils/i18n-options.js +0 -161
- package/src/utils/index-file/add-event-dispatch-contract.d.ts +0 -8
- package/src/utils/index-file/add-event-dispatch-contract.js +0 -28
- package/src/utils/index-file/augment-index-html.d.ts +0 -40
- package/src/utils/index-file/augment-index-html.js +0 -239
- 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 -57
- package/src/utils/index-file/index-html-generator.js +0 -135
- 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/nonce.d.ts +0 -12
- package/src/utils/index-file/nonce.js +0 -55
- package/src/utils/load-proxy-config.d.ts +0 -8
- package/src/utils/load-proxy-config.js +0 -189
- 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/resolve-assets.d.ts +0 -18
- package/src/utils/resolve-assets.js +0 -35
- 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/stats-table.d.ts +0 -20
- package/src/utils/stats-table.js +0 -205
- 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,268 +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.createAngularMemoryPlugin = void 0;
|
|
14
|
-
const remapping_1 = __importDefault(require("@ampproject/remapping"));
|
|
15
|
-
const mrmime_1 = require("mrmime");
|
|
16
|
-
const node_assert_1 = __importDefault(require("node:assert"));
|
|
17
|
-
const promises_1 = require("node:fs/promises");
|
|
18
|
-
const node_path_1 = require("node:path");
|
|
19
|
-
const render_page_1 = require("../../utils/server-rendering/render-page");
|
|
20
|
-
// eslint-disable-next-line max-lines-per-function
|
|
21
|
-
function createAngularMemoryPlugin(options) {
|
|
22
|
-
const { workspaceRoot, virtualProjectRoot, outputFiles, assets, external, ssr, extensionMiddleware, extraHeaders, indexHtmlTransformer, normalizePath, } = options;
|
|
23
|
-
return {
|
|
24
|
-
name: 'vite:angular-memory',
|
|
25
|
-
// Ensures plugin hooks run before built-in Vite hooks
|
|
26
|
-
enforce: 'pre',
|
|
27
|
-
async resolveId(source, importer) {
|
|
28
|
-
// Prevent vite from resolving an explicit external dependency (`externalDependencies` option)
|
|
29
|
-
if (external?.includes(source)) {
|
|
30
|
-
// This is still not ideal since Vite will still transform the import specifier to
|
|
31
|
-
// `/@id/${source}` but is currently closer to a raw external than a resolved file path.
|
|
32
|
-
return source;
|
|
33
|
-
}
|
|
34
|
-
if (importer && source[0] === '.' && importer.startsWith(virtualProjectRoot)) {
|
|
35
|
-
// Remove query if present
|
|
36
|
-
const [importerFile] = importer.split('?', 1);
|
|
37
|
-
source =
|
|
38
|
-
'/' + normalizePath((0, node_path_1.join)((0, node_path_1.dirname)((0, node_path_1.relative)(virtualProjectRoot, importerFile)), source));
|
|
39
|
-
}
|
|
40
|
-
const [file] = source.split('?', 1);
|
|
41
|
-
if (outputFiles.has(file)) {
|
|
42
|
-
return (0, node_path_1.join)(virtualProjectRoot, source);
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
async load(id) {
|
|
46
|
-
const [file] = id.split('?', 1);
|
|
47
|
-
const relativeFile = '/' + normalizePath((0, node_path_1.relative)(virtualProjectRoot, file));
|
|
48
|
-
const codeContents = outputFiles.get(relativeFile)?.contents;
|
|
49
|
-
if (codeContents === undefined) {
|
|
50
|
-
if (relativeFile.endsWith('/node_modules/vite/dist/client/client.mjs')) {
|
|
51
|
-
return {
|
|
52
|
-
code: await loadViteClientCode(file),
|
|
53
|
-
map: await (0, promises_1.readFile)(file + '.map', 'utf-8'),
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
const code = Buffer.from(codeContents).toString('utf-8');
|
|
59
|
-
const mapContents = outputFiles.get(relativeFile + '.map')?.contents;
|
|
60
|
-
return {
|
|
61
|
-
// Remove source map URL comments from the code if a sourcemap is present.
|
|
62
|
-
// Vite will inline and add an additional sourcemap URL for the sourcemap.
|
|
63
|
-
code: mapContents ? code.replace(/^\/\/# sourceMappingURL=[^\r\n]*/gm, '') : code,
|
|
64
|
-
map: mapContents && Buffer.from(mapContents).toString('utf-8'),
|
|
65
|
-
};
|
|
66
|
-
},
|
|
67
|
-
// eslint-disable-next-line max-lines-per-function
|
|
68
|
-
configureServer(server) {
|
|
69
|
-
const originalssrTransform = server.ssrTransform;
|
|
70
|
-
server.ssrTransform = async (code, map, url, originalCode) => {
|
|
71
|
-
const result = await originalssrTransform(code, null, url, originalCode);
|
|
72
|
-
if (!result || !result.map || !map) {
|
|
73
|
-
return result;
|
|
74
|
-
}
|
|
75
|
-
const remappedMap = (0, remapping_1.default)([result.map, map], () => null);
|
|
76
|
-
// Set the sourcemap root to the workspace root. This is needed since we set a virtual path as root.
|
|
77
|
-
remappedMap.sourceRoot = normalizePath(workspaceRoot) + '/';
|
|
78
|
-
return {
|
|
79
|
-
...result,
|
|
80
|
-
map: remappedMap,
|
|
81
|
-
};
|
|
82
|
-
};
|
|
83
|
-
// Assets and resources get handled first
|
|
84
|
-
server.middlewares.use(function angularAssetsMiddleware(req, res, next) {
|
|
85
|
-
if (req.url === undefined || res.writableEnded) {
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
// Parse the incoming request.
|
|
89
|
-
// The base of the URL is unused but required to parse the URL.
|
|
90
|
-
const pathname = pathnameWithoutBasePath(req.url, server.config.base);
|
|
91
|
-
const extension = (0, node_path_1.extname)(pathname);
|
|
92
|
-
// Rewrite all build assets to a vite raw fs URL
|
|
93
|
-
const assetSourcePath = assets.get(pathname);
|
|
94
|
-
if (assetSourcePath !== undefined) {
|
|
95
|
-
// Workaround to disable Vite transformer middleware.
|
|
96
|
-
// See: https://github.com/vitejs/vite/blob/746a1daab0395f98f0afbdee8f364cb6cf2f3b3f/packages/vite/src/node/server/middlewares/transform.ts#L201 and
|
|
97
|
-
// https://github.com/vitejs/vite/blob/746a1daab0395f98f0afbdee8f364cb6cf2f3b3f/packages/vite/src/node/server/transformRequest.ts#L204-L206
|
|
98
|
-
req.headers.accept = 'text/html';
|
|
99
|
-
// The encoding needs to match what happens in the vite static middleware.
|
|
100
|
-
// ref: https://github.com/vitejs/vite/blob/d4f13bd81468961c8c926438e815ab6b1c82735e/packages/vite/src/node/server/middlewares/static.ts#L163
|
|
101
|
-
req.url = `${server.config.base}@fs/${encodeURI(assetSourcePath)}`;
|
|
102
|
-
next();
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
// HTML fallbacking
|
|
106
|
-
// This matches what happens in the vite html fallback middleware.
|
|
107
|
-
// ref: https://github.com/vitejs/vite/blob/main/packages/vite/src/node/server/middlewares/htmlFallback.ts#L9
|
|
108
|
-
const htmlAssetSourcePath = pathname[pathname.length - 1] === '/'
|
|
109
|
-
? // Trailing slash check for `index.html`.
|
|
110
|
-
assets.get(pathname + 'index.html')
|
|
111
|
-
: // Non-trailing slash check for fallback `.html`
|
|
112
|
-
assets.get(pathname + '.html');
|
|
113
|
-
if (htmlAssetSourcePath) {
|
|
114
|
-
req.url = `${server.config.base}@fs/${encodeURI(htmlAssetSourcePath)}`;
|
|
115
|
-
next();
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
// Resource files are handled directly.
|
|
119
|
-
// Global stylesheets (CSS files) are currently considered resources to workaround
|
|
120
|
-
// dev server sourcemap issues with stylesheets.
|
|
121
|
-
if (extension !== '.js' && extension !== '.html') {
|
|
122
|
-
const outputFile = outputFiles.get(pathname);
|
|
123
|
-
if (outputFile?.servable) {
|
|
124
|
-
const mimeType = (0, mrmime_1.lookup)(extension);
|
|
125
|
-
if (mimeType) {
|
|
126
|
-
res.setHeader('Content-Type', mimeType);
|
|
127
|
-
}
|
|
128
|
-
res.setHeader('Cache-Control', 'no-cache');
|
|
129
|
-
if (extraHeaders) {
|
|
130
|
-
Object.entries(extraHeaders).forEach(([name, value]) => res.setHeader(name, value));
|
|
131
|
-
}
|
|
132
|
-
res.end(outputFile.contents);
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
next();
|
|
137
|
-
});
|
|
138
|
-
if (extensionMiddleware?.length) {
|
|
139
|
-
extensionMiddleware.forEach((middleware) => server.middlewares.use(middleware));
|
|
140
|
-
}
|
|
141
|
-
// Returning a function, installs middleware after the main transform middleware but
|
|
142
|
-
// before the built-in HTML middleware
|
|
143
|
-
return () => {
|
|
144
|
-
server.middlewares.use(angularHtmlFallbackMiddleware);
|
|
145
|
-
function angularSSRMiddleware(req, res, next) {
|
|
146
|
-
const url = req.originalUrl;
|
|
147
|
-
if (!req.url ||
|
|
148
|
-
// Skip if path is not defined.
|
|
149
|
-
!url ||
|
|
150
|
-
// Skip if path is like a file.
|
|
151
|
-
// NOTE: We use a mime type lookup to mitigate against matching requests like: /browse/pl.0ef59752c0cd457dbf1391f08cbd936f
|
|
152
|
-
lookupMimeTypeFromRequest(url)) {
|
|
153
|
-
next();
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
const rawHtml = outputFiles.get('/index.server.html')?.contents;
|
|
157
|
-
if (!rawHtml) {
|
|
158
|
-
next();
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
transformIndexHtmlAndAddHeaders(req.url, rawHtml, res, next, async (html) => {
|
|
162
|
-
const resolvedUrls = server.resolvedUrls;
|
|
163
|
-
const baseUrl = resolvedUrls?.local[0] ?? resolvedUrls?.network[0];
|
|
164
|
-
const { content } = await (0, render_page_1.renderPage)({
|
|
165
|
-
document: html,
|
|
166
|
-
route: new URL(req.originalUrl ?? '/', baseUrl).toString(),
|
|
167
|
-
serverContext: 'ssr',
|
|
168
|
-
loadBundle: (uri) =>
|
|
169
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
170
|
-
server.ssrLoadModule(uri.slice(1)),
|
|
171
|
-
// Files here are only needed for critical CSS inlining.
|
|
172
|
-
outputFiles: {},
|
|
173
|
-
// TODO: add support for critical css inlining.
|
|
174
|
-
inlineCriticalCss: false,
|
|
175
|
-
});
|
|
176
|
-
return indexHtmlTransformer && content ? await indexHtmlTransformer(content) : content;
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
if (ssr) {
|
|
180
|
-
server.middlewares.use(angularSSRMiddleware);
|
|
181
|
-
}
|
|
182
|
-
server.middlewares.use(function angularIndexMiddleware(req, res, next) {
|
|
183
|
-
if (!req.url) {
|
|
184
|
-
next();
|
|
185
|
-
return;
|
|
186
|
-
}
|
|
187
|
-
// Parse the incoming request.
|
|
188
|
-
// The base of the URL is unused but required to parse the URL.
|
|
189
|
-
const pathname = pathnameWithoutBasePath(req.url, server.config.base);
|
|
190
|
-
if (pathname === '/' || pathname === `/index.html`) {
|
|
191
|
-
const rawHtml = outputFiles.get('/index.html')?.contents;
|
|
192
|
-
if (rawHtml) {
|
|
193
|
-
transformIndexHtmlAndAddHeaders(req.url, rawHtml, res, next, indexHtmlTransformer);
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
next();
|
|
198
|
-
});
|
|
199
|
-
};
|
|
200
|
-
function transformIndexHtmlAndAddHeaders(url, rawHtml, res, next, additionalTransformer) {
|
|
201
|
-
server
|
|
202
|
-
.transformIndexHtml(url, Buffer.from(rawHtml).toString('utf-8'))
|
|
203
|
-
.then(async (processedHtml) => {
|
|
204
|
-
if (additionalTransformer) {
|
|
205
|
-
const content = await additionalTransformer(processedHtml);
|
|
206
|
-
if (!content) {
|
|
207
|
-
next();
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
processedHtml = content;
|
|
211
|
-
}
|
|
212
|
-
res.setHeader('Content-Type', 'text/html');
|
|
213
|
-
res.setHeader('Cache-Control', 'no-cache');
|
|
214
|
-
if (extraHeaders) {
|
|
215
|
-
Object.entries(extraHeaders).forEach(([name, value]) => res.setHeader(name, value));
|
|
216
|
-
}
|
|
217
|
-
res.end(processedHtml);
|
|
218
|
-
})
|
|
219
|
-
.catch((error) => next(error));
|
|
220
|
-
}
|
|
221
|
-
},
|
|
222
|
-
};
|
|
223
|
-
}
|
|
224
|
-
exports.createAngularMemoryPlugin = createAngularMemoryPlugin;
|
|
225
|
-
/**
|
|
226
|
-
* Reads the resolved Vite client code from disk and updates the content to remove
|
|
227
|
-
* an unactionable suggestion to update the Vite configuration file to disable the
|
|
228
|
-
* error overlay. The Vite configuration file is not present when used in the Angular
|
|
229
|
-
* CLI.
|
|
230
|
-
* @param file The absolute path to the Vite client code.
|
|
231
|
-
* @returns
|
|
232
|
-
*/
|
|
233
|
-
async function loadViteClientCode(file) {
|
|
234
|
-
const originalContents = await (0, promises_1.readFile)(file, 'utf-8');
|
|
235
|
-
const updatedContents = originalContents.replace(`h('br'), 'You can also disable this overlay by setting ', ` +
|
|
236
|
-
`h('code', { part: 'config-option-name' }, 'server.hmr.overlay'), '` +
|
|
237
|
-
` to ', h('code', { part: 'config-option-value' }, 'false'), ' in ', h('code', { part: 'config-file-name' }, hmrConfigName), '.'`, '');
|
|
238
|
-
(0, node_assert_1.default)(originalContents !== updatedContents, 'Failed to update Vite client error overlay text.');
|
|
239
|
-
return updatedContents;
|
|
240
|
-
}
|
|
241
|
-
function pathnameWithoutBasePath(url, basePath) {
|
|
242
|
-
const parsedUrl = new URL(url, 'http://localhost');
|
|
243
|
-
const pathname = decodeURIComponent(parsedUrl.pathname);
|
|
244
|
-
// slice(basePath.length - 1) to retain the trailing slash
|
|
245
|
-
return basePath !== '/' && pathname.startsWith(basePath)
|
|
246
|
-
? pathname.slice(basePath.length - 1)
|
|
247
|
-
: pathname;
|
|
248
|
-
}
|
|
249
|
-
function angularHtmlFallbackMiddleware(req, res, next) {
|
|
250
|
-
// Similar to how it is handled in vite
|
|
251
|
-
// https://github.com/vitejs/vite/blob/main/packages/vite/src/node/server/middlewares/htmlFallback.ts#L15C19-L15C45
|
|
252
|
-
if ((req.method === 'GET' || req.method === 'HEAD') &&
|
|
253
|
-
(!req.url || !lookupMimeTypeFromRequest(req.url)) &&
|
|
254
|
-
(!req.headers.accept ||
|
|
255
|
-
req.headers.accept.includes('text/html') ||
|
|
256
|
-
req.headers.accept.includes('text/*') ||
|
|
257
|
-
req.headers.accept.includes('*/*'))) {
|
|
258
|
-
req.url = '/index.html';
|
|
259
|
-
}
|
|
260
|
-
next();
|
|
261
|
-
}
|
|
262
|
-
function lookupMimeTypeFromRequest(url) {
|
|
263
|
-
const extension = (0, node_path_1.extname)(url.split('?')[0]);
|
|
264
|
-
if (extension === '.ico') {
|
|
265
|
-
return 'image/x-icon';
|
|
266
|
-
}
|
|
267
|
-
return extension && (0, mrmime_1.lookup)(extension);
|
|
268
|
-
}
|
|
@@ -1,18 +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 { Plugin } from 'vite';
|
|
9
|
-
/**
|
|
10
|
-
* The base module location used to search for locale specific data.
|
|
11
|
-
*/
|
|
12
|
-
export declare const LOCALE_DATA_BASE_MODULE = "@angular/common/locales/global";
|
|
13
|
-
/**
|
|
14
|
-
* Creates a Vite plugin that resolves Angular locale data files from `@angular/common`.
|
|
15
|
-
*
|
|
16
|
-
* @returns A Vite plugin.
|
|
17
|
-
*/
|
|
18
|
-
export declare function createAngularLocaleDataPlugin(): Plugin;
|
|
@@ -1,55 +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.createAngularLocaleDataPlugin = exports.LOCALE_DATA_BASE_MODULE = void 0;
|
|
11
|
-
/**
|
|
12
|
-
* The base module location used to search for locale specific data.
|
|
13
|
-
*/
|
|
14
|
-
exports.LOCALE_DATA_BASE_MODULE = '@angular/common/locales/global';
|
|
15
|
-
/**
|
|
16
|
-
* Creates a Vite plugin that resolves Angular locale data files from `@angular/common`.
|
|
17
|
-
*
|
|
18
|
-
* @returns A Vite plugin.
|
|
19
|
-
*/
|
|
20
|
-
function createAngularLocaleDataPlugin() {
|
|
21
|
-
return {
|
|
22
|
-
name: 'angular-locale-data',
|
|
23
|
-
enforce: 'pre',
|
|
24
|
-
async resolveId(source) {
|
|
25
|
-
if (!source.startsWith('angular:locale/data:')) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
// Extract the locale from the path
|
|
29
|
-
const originalLocale = source.split(':', 3)[2];
|
|
30
|
-
// Remove any private subtags since these will never match
|
|
31
|
-
let partialLocale = originalLocale.replace(/-x(-[a-zA-Z0-9]{1,8})+$/, '');
|
|
32
|
-
let exact = true;
|
|
33
|
-
while (partialLocale) {
|
|
34
|
-
const potentialPath = `${exports.LOCALE_DATA_BASE_MODULE}/${partialLocale}`;
|
|
35
|
-
const result = await this.resolve(potentialPath);
|
|
36
|
-
if (result) {
|
|
37
|
-
if (!exact) {
|
|
38
|
-
this.warn(`Locale data for '${originalLocale}' cannot be found. Using locale data for '${partialLocale}'.`);
|
|
39
|
-
}
|
|
40
|
-
return result;
|
|
41
|
-
}
|
|
42
|
-
// Remove the last subtag and try again with a less specific locale
|
|
43
|
-
const parts = partialLocale.split('-');
|
|
44
|
-
partialLocale = parts.slice(0, -1).join('-');
|
|
45
|
-
exact = false;
|
|
46
|
-
// The locales "en" and "en-US" are considered exact to retain existing behavior
|
|
47
|
-
if (originalLocale === 'en-US' && partialLocale === 'en') {
|
|
48
|
-
exact = true;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return null;
|
|
52
|
-
},
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
exports.createAngularLocaleDataPlugin = createAngularLocaleDataPlugin;
|
package/src/typings.d.ts
DELETED
|
@@ -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
|
-
|
|
9
|
-
declare module '@babel/helper-annotate-as-pure' {
|
|
10
|
-
export default function annotateAsPure(
|
|
11
|
-
pathOrNode: import('@babel/types').Node | { node: import('@babel/types').Node },
|
|
12
|
-
): void;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
declare module '@babel/helper-split-export-declaration' {
|
|
16
|
-
export default function splitExportDeclaration(
|
|
17
|
-
exportDeclaration: import('@babel/core').NodePath<
|
|
18
|
-
import('@babel/types').ExportDefaultDeclaration
|
|
19
|
-
>,
|
|
20
|
-
): void;
|
|
21
|
-
}
|
|
@@ -1,44 +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 { Budget as BudgetEntry, Type as BudgetType } from '../builders/application/schema';
|
|
9
|
-
export { BudgetEntry, BudgetType };
|
|
10
|
-
export interface Threshold {
|
|
11
|
-
limit: number;
|
|
12
|
-
type: ThresholdType;
|
|
13
|
-
severity: ThresholdSeverity;
|
|
14
|
-
}
|
|
15
|
-
declare enum ThresholdType {
|
|
16
|
-
Max = "maximum",
|
|
17
|
-
Min = "minimum"
|
|
18
|
-
}
|
|
19
|
-
export declare enum ThresholdSeverity {
|
|
20
|
-
Warning = "warning",
|
|
21
|
-
Error = "error"
|
|
22
|
-
}
|
|
23
|
-
export interface BudgetCalculatorResult {
|
|
24
|
-
severity: ThresholdSeverity;
|
|
25
|
-
message: string;
|
|
26
|
-
label?: string;
|
|
27
|
-
}
|
|
28
|
-
export interface BudgetChunk {
|
|
29
|
-
files?: string[];
|
|
30
|
-
names?: string[];
|
|
31
|
-
initial?: boolean;
|
|
32
|
-
}
|
|
33
|
-
export interface BudgetAsset {
|
|
34
|
-
name: string;
|
|
35
|
-
size: number;
|
|
36
|
-
componentStyle?: boolean;
|
|
37
|
-
}
|
|
38
|
-
export interface BudgetStats {
|
|
39
|
-
chunks?: BudgetChunk[];
|
|
40
|
-
assets?: BudgetAsset[];
|
|
41
|
-
}
|
|
42
|
-
export declare function calculateThresholds(budget: BudgetEntry): IterableIterator<Threshold>;
|
|
43
|
-
export declare function checkBudgets(budgets: BudgetEntry[], stats: BudgetStats, checkComponentStyles?: boolean): IterableIterator<BudgetCalculatorResult>;
|
|
44
|
-
export declare function checkThresholds(thresholds: Iterable<Threshold>, size: number, label?: string): IterableIterator<BudgetCalculatorResult>;
|