@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,71 +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.setupBundlerContexts = void 0;
|
|
11
|
-
const application_code_bundle_1 = require("../../tools/esbuild/application-code-bundle");
|
|
12
|
-
const bundler_context_1 = require("../../tools/esbuild/bundler-context");
|
|
13
|
-
const global_scripts_1 = require("../../tools/esbuild/global-scripts");
|
|
14
|
-
const global_styles_1 = require("../../tools/esbuild/global-styles");
|
|
15
|
-
const utils_1 = require("../../tools/esbuild/utils");
|
|
16
|
-
/**
|
|
17
|
-
* Generates one or more BundlerContext instances based on the builder provided
|
|
18
|
-
* configuration.
|
|
19
|
-
* @param options The normalized application builder options to use.
|
|
20
|
-
* @param browsers An string array of browserslist browsers to support.
|
|
21
|
-
* @param codeBundleCache An instance of the TypeScript source file cache.
|
|
22
|
-
* @returns An array of BundlerContext objects.
|
|
23
|
-
*/
|
|
24
|
-
function setupBundlerContexts(options, browsers, codeBundleCache) {
|
|
25
|
-
const { appShellOptions, prerenderOptions, serverEntryPoint, ssrOptions, workspaceRoot } = options;
|
|
26
|
-
const target = (0, utils_1.transformSupportedBrowsersToTargets)(browsers);
|
|
27
|
-
const bundlerContexts = [];
|
|
28
|
-
// Browser application code
|
|
29
|
-
bundlerContexts.push(new bundler_context_1.BundlerContext(workspaceRoot, !!options.watch, (0, application_code_bundle_1.createBrowserCodeBundleOptions)(options, target, codeBundleCache)));
|
|
30
|
-
// Browser polyfills code
|
|
31
|
-
const browserPolyfillBundleOptions = (0, application_code_bundle_1.createBrowserPolyfillBundleOptions)(options, target, codeBundleCache);
|
|
32
|
-
if (browserPolyfillBundleOptions) {
|
|
33
|
-
bundlerContexts.push(new bundler_context_1.BundlerContext(workspaceRoot, !!options.watch, browserPolyfillBundleOptions));
|
|
34
|
-
}
|
|
35
|
-
// Global Stylesheets
|
|
36
|
-
if (options.globalStyles.length > 0) {
|
|
37
|
-
for (const initial of [true, false]) {
|
|
38
|
-
const bundleOptions = (0, global_styles_1.createGlobalStylesBundleOptions)(options, target, initial);
|
|
39
|
-
if (bundleOptions) {
|
|
40
|
-
bundlerContexts.push(new bundler_context_1.BundlerContext(workspaceRoot, !!options.watch, bundleOptions, () => initial));
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
// Global Scripts
|
|
45
|
-
if (options.globalScripts.length > 0) {
|
|
46
|
-
for (const initial of [true, false]) {
|
|
47
|
-
const bundleOptions = (0, global_scripts_1.createGlobalScriptsBundleOptions)(options, target, initial);
|
|
48
|
-
if (bundleOptions) {
|
|
49
|
-
bundlerContexts.push(new bundler_context_1.BundlerContext(workspaceRoot, !!options.watch, bundleOptions, () => initial));
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
// Skip server build when none of the features are enabled.
|
|
54
|
-
if (serverEntryPoint && (prerenderOptions || appShellOptions || ssrOptions)) {
|
|
55
|
-
const nodeTargets = [...target, ...(0, utils_1.getSupportedNodeTargets)()];
|
|
56
|
-
// Server application code
|
|
57
|
-
bundlerContexts.push(new bundler_context_1.BundlerContext(workspaceRoot, !!options.watch, (0, application_code_bundle_1.createServerCodeBundleOptions)({
|
|
58
|
-
...options,
|
|
59
|
-
// Disable external deps for server bundles.
|
|
60
|
-
// This is because it breaks Vite 'optimizeDeps' for SSR.
|
|
61
|
-
externalPackages: false,
|
|
62
|
-
}, nodeTargets, codeBundleCache)));
|
|
63
|
-
// Server polyfills code
|
|
64
|
-
const serverPolyfillBundleOptions = (0, application_code_bundle_1.createServerPolyfillBundleOptions)(options, nodeTargets, codeBundleCache);
|
|
65
|
-
if (serverPolyfillBundleOptions) {
|
|
66
|
-
bundlerContexts.push(new bundler_context_1.BundlerContext(workspaceRoot, !!options.watch, serverPolyfillBundleOptions));
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return bundlerContexts;
|
|
70
|
-
}
|
|
71
|
-
exports.setupBundlerContexts = setupBundlerContexts;
|
|
@@ -1,30 +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 { BuilderContext } from '@angular-devkit/architect';
|
|
9
|
-
import type { Plugin } from 'esbuild';
|
|
10
|
-
import type { Connect, DepOptimizationConfig, InlineConfig } from 'vite';
|
|
11
|
-
import { ExternalResultMetadata } from '../../tools/esbuild/bundler-execution-result';
|
|
12
|
-
import { JavaScriptTransformer } from '../../tools/esbuild/javascript-transformer';
|
|
13
|
-
import type { NormalizedDevServerOptions } from './options';
|
|
14
|
-
import type { DevServerBuilderOutput } from './webpack-server';
|
|
15
|
-
interface OutputFileRecord {
|
|
16
|
-
contents: Uint8Array;
|
|
17
|
-
size: number;
|
|
18
|
-
hash?: string;
|
|
19
|
-
updated: boolean;
|
|
20
|
-
servable: boolean;
|
|
21
|
-
}
|
|
22
|
-
export declare function serveWithVite(serverOptions: NormalizedDevServerOptions, builderName: string, context: BuilderContext, transformers?: {
|
|
23
|
-
indexHtml?: (content: string) => Promise<string>;
|
|
24
|
-
}, extensions?: {
|
|
25
|
-
middleware?: Connect.NextHandleFunction[];
|
|
26
|
-
buildPlugins?: Plugin[];
|
|
27
|
-
}): AsyncIterableIterator<DevServerBuilderOutput>;
|
|
28
|
-
export declare function setupServer(serverOptions: NormalizedDevServerOptions, outputFiles: Map<string, OutputFileRecord>, assets: Map<string, string>, preserveSymlinks: boolean | undefined, externalMetadata: ExternalResultMetadata, ssr: boolean, prebundleTransformer: JavaScriptTransformer, target: string[], prebundleLoaderExtensions: EsbuildLoaderOption | undefined, extensionMiddleware?: Connect.NextHandleFunction[], indexHtmlTransformer?: (content: string) => Promise<string>, thirdPartySourcemaps?: boolean): Promise<InlineConfig>;
|
|
29
|
-
type EsbuildLoaderOption = Exclude<DepOptimizationConfig['esbuildOptions'], undefined>['loader'];
|
|
30
|
-
export {};
|
|
@@ -1,502 +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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
33
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
34
|
-
};
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.setupServer = exports.serveWithVite = void 0;
|
|
37
|
-
const node_assert_1 = __importDefault(require("node:assert"));
|
|
38
|
-
const promises_1 = require("node:fs/promises");
|
|
39
|
-
const node_path_1 = require("node:path");
|
|
40
|
-
const bundler_context_1 = require("../../tools/esbuild/bundler-context");
|
|
41
|
-
const javascript_transformer_1 = require("../../tools/esbuild/javascript-transformer");
|
|
42
|
-
const rxjs_esm_resolution_plugin_1 = require("../../tools/esbuild/rxjs-esm-resolution-plugin");
|
|
43
|
-
const utils_1 = require("../../tools/esbuild/utils");
|
|
44
|
-
const angular_memory_plugin_1 = require("../../tools/vite/angular-memory-plugin");
|
|
45
|
-
const i18n_locale_plugin_1 = require("../../tools/vite/i18n-locale-plugin");
|
|
46
|
-
const utils_2 = require("../../utils");
|
|
47
|
-
const load_esm_1 = require("../../utils/load-esm");
|
|
48
|
-
const supported_browsers_1 = require("../../utils/supported-browsers");
|
|
49
|
-
const webpack_browser_config_1 = require("../../utils/webpack-browser-config");
|
|
50
|
-
const application_1 = require("../application");
|
|
51
|
-
const browser_esbuild_1 = require("../browser-esbuild");
|
|
52
|
-
/**
|
|
53
|
-
* Build options that are also present on the dev server but are only passed
|
|
54
|
-
* to the build.
|
|
55
|
-
*/
|
|
56
|
-
const CONVENIENCE_BUILD_OPTIONS = ['watch', 'poll', 'verbose'];
|
|
57
|
-
// eslint-disable-next-line max-lines-per-function
|
|
58
|
-
async function* serveWithVite(serverOptions, builderName, context, transformers, extensions) {
|
|
59
|
-
// Get the browser configuration from the target name.
|
|
60
|
-
const rawBrowserOptions = await context.getTargetOptions(serverOptions.buildTarget);
|
|
61
|
-
// Deploy url is not used in the dev-server.
|
|
62
|
-
delete rawBrowserOptions.deployUrl;
|
|
63
|
-
// Copy convenience options to build
|
|
64
|
-
for (const optionName of CONVENIENCE_BUILD_OPTIONS) {
|
|
65
|
-
const optionValue = serverOptions[optionName];
|
|
66
|
-
if (optionValue !== undefined) {
|
|
67
|
-
rawBrowserOptions[optionName] = optionValue;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
const browserOptions = await context.validateOptions(rawBrowserOptions, builderName);
|
|
71
|
-
if (browserOptions.prerender || browserOptions.ssr) {
|
|
72
|
-
// Disable prerendering if enabled and force SSR.
|
|
73
|
-
// This is so instead of prerendering all the routes for every change, the page is "prerendered" when it is requested.
|
|
74
|
-
browserOptions.prerender = false;
|
|
75
|
-
// Avoid bundling and processing the ssr entry-point as this is not used by the dev-server.
|
|
76
|
-
browserOptions.ssr = true;
|
|
77
|
-
// https://nodejs.org/api/process.html#processsetsourcemapsenabledval
|
|
78
|
-
process.setSourceMapsEnabled(true);
|
|
79
|
-
}
|
|
80
|
-
// Set all packages as external to support Vite's prebundle caching
|
|
81
|
-
browserOptions.externalPackages = serverOptions.prebundle;
|
|
82
|
-
const baseHref = browserOptions.baseHref;
|
|
83
|
-
if (serverOptions.servePath === undefined && baseHref !== undefined) {
|
|
84
|
-
// Remove trailing slash
|
|
85
|
-
serverOptions.servePath =
|
|
86
|
-
baseHref !== './' && baseHref[baseHref.length - 1] === '/' ? baseHref.slice(0, -1) : baseHref;
|
|
87
|
-
}
|
|
88
|
-
// The development server currently only supports a single locale when localizing.
|
|
89
|
-
// This matches the behavior of the Webpack-based development server but could be expanded in the future.
|
|
90
|
-
if (browserOptions.localize === true ||
|
|
91
|
-
(Array.isArray(browserOptions.localize) && browserOptions.localize.length > 1)) {
|
|
92
|
-
context.logger.warn('Localization (`localize` option) has been disabled. The development server only supports localizing a single locale per build.');
|
|
93
|
-
browserOptions.localize = false;
|
|
94
|
-
}
|
|
95
|
-
else if (browserOptions.localize) {
|
|
96
|
-
// When localization is enabled with a single locale, force a flat path to maintain behavior with the existing Webpack-based dev server.
|
|
97
|
-
browserOptions.forceI18nFlatOutput = true;
|
|
98
|
-
}
|
|
99
|
-
const { vendor: thirdPartySourcemaps } = (0, utils_2.normalizeSourceMaps)(browserOptions.sourceMap ?? false);
|
|
100
|
-
// Setup the prebundling transformer that will be shared across Vite prebundling requests
|
|
101
|
-
const prebundleTransformer = new javascript_transformer_1.JavaScriptTransformer(
|
|
102
|
-
// Always enable JIT linking to support applications built with and without AOT.
|
|
103
|
-
// In a development environment the additional scope information does not
|
|
104
|
-
// have a negative effect unlike production where final output size is relevant.
|
|
105
|
-
{ sourcemap: true, jit: true, thirdPartySourcemaps }, 1);
|
|
106
|
-
// Extract output index from options
|
|
107
|
-
// TODO: Provide this info from the build results
|
|
108
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
109
|
-
const htmlIndexPath = (0, webpack_browser_config_1.getIndexOutputFile)(browserOptions.index);
|
|
110
|
-
// dynamically import Vite for ESM compatibility
|
|
111
|
-
const { createServer, normalizePath } = await (0, load_esm_1.loadEsmModule)('vite');
|
|
112
|
-
let server;
|
|
113
|
-
let serverUrl;
|
|
114
|
-
let hadError = false;
|
|
115
|
-
const generatedFiles = new Map();
|
|
116
|
-
const assetFiles = new Map();
|
|
117
|
-
const externalMetadata = {
|
|
118
|
-
implicitBrowser: [],
|
|
119
|
-
implicitServer: [],
|
|
120
|
-
explicit: [],
|
|
121
|
-
};
|
|
122
|
-
// Add cleanup logic via a builder teardown.
|
|
123
|
-
let deferred;
|
|
124
|
-
context.addTeardown(async () => {
|
|
125
|
-
await server?.close();
|
|
126
|
-
await prebundleTransformer.close();
|
|
127
|
-
deferred?.();
|
|
128
|
-
});
|
|
129
|
-
const build = builderName === '@angular-devkit/build-angular:browser-esbuild'
|
|
130
|
-
? browser_esbuild_1.buildEsbuildBrowser.bind(undefined, browserOptions, context, { write: false }, extensions?.buildPlugins)
|
|
131
|
-
: application_1.buildApplicationInternal.bind(undefined, browserOptions, context, { write: false }, { codePlugins: extensions?.buildPlugins });
|
|
132
|
-
// TODO: Switch this to an architect schedule call when infrastructure settings are supported
|
|
133
|
-
for await (const result of build()) {
|
|
134
|
-
(0, node_assert_1.default)(result.outputFiles, 'Builder did not provide result files.');
|
|
135
|
-
// If build failed, nothing to serve
|
|
136
|
-
if (!result.success) {
|
|
137
|
-
// If server is active, send an error notification
|
|
138
|
-
if (result.errors?.length && server) {
|
|
139
|
-
hadError = true;
|
|
140
|
-
server.ws.send({
|
|
141
|
-
type: 'error',
|
|
142
|
-
err: {
|
|
143
|
-
message: result.errors[0].text,
|
|
144
|
-
stack: '',
|
|
145
|
-
loc: result.errors[0].location,
|
|
146
|
-
},
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
continue;
|
|
150
|
-
}
|
|
151
|
-
else if (hadError && server) {
|
|
152
|
-
hadError = false;
|
|
153
|
-
// Send an empty update to clear the error overlay
|
|
154
|
-
server.ws.send({
|
|
155
|
-
'type': 'update',
|
|
156
|
-
updates: [],
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
// Analyze result files for changes
|
|
160
|
-
analyzeResultFiles(normalizePath, htmlIndexPath, result.outputFiles, generatedFiles);
|
|
161
|
-
assetFiles.clear();
|
|
162
|
-
if (result.assetFiles) {
|
|
163
|
-
for (const asset of result.assetFiles) {
|
|
164
|
-
assetFiles.set('/' + normalizePath(asset.destination), normalizePath(asset.source));
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
// To avoid disconnecting the array objects from the option, these arrays need to be mutated instead of replaced.
|
|
168
|
-
if (result.externalMetadata) {
|
|
169
|
-
const { implicitBrowser, implicitServer, explicit } = result.externalMetadata;
|
|
170
|
-
// Empty Arrays to avoid growing unlimited with every re-build.
|
|
171
|
-
externalMetadata.explicit.length = 0;
|
|
172
|
-
externalMetadata.implicitServer.length = 0;
|
|
173
|
-
externalMetadata.implicitBrowser.length = 0;
|
|
174
|
-
externalMetadata.explicit.push(...explicit);
|
|
175
|
-
// Remove any absolute URLs (http://, https://, //) to avoid Vite's prebundling from processing them as files
|
|
176
|
-
externalMetadata.implicitServer.push(...implicitServer.filter((value) => !/^(?:https?:)?\/\//.test(value)));
|
|
177
|
-
externalMetadata.implicitBrowser.push(...implicitBrowser.filter((value) => !/^(?:https?:)?\/\//.test(value)));
|
|
178
|
-
// The below needs to be sorted as Vite uses these options are part of the hashing invalidation algorithm.
|
|
179
|
-
// See: https://github.com/vitejs/vite/blob/0873bae0cfe0f0718ad2f5743dd34a17e4ab563d/packages/vite/src/node/optimizer/index.ts#L1203-L1239
|
|
180
|
-
externalMetadata.explicit.sort();
|
|
181
|
-
externalMetadata.implicitServer.sort();
|
|
182
|
-
externalMetadata.implicitBrowser.sort();
|
|
183
|
-
}
|
|
184
|
-
if (server) {
|
|
185
|
-
// Update fs allow list to include any new assets from the build option.
|
|
186
|
-
server.config.server.fs.allow = [
|
|
187
|
-
...new Set([...server.config.server.fs.allow, ...assetFiles.values()]),
|
|
188
|
-
];
|
|
189
|
-
handleUpdate(normalizePath, generatedFiles, server, serverOptions, context.logger);
|
|
190
|
-
}
|
|
191
|
-
else {
|
|
192
|
-
const projectName = context.target?.project;
|
|
193
|
-
if (!projectName) {
|
|
194
|
-
throw new Error('The builder requires a target.');
|
|
195
|
-
}
|
|
196
|
-
const { root = '' } = await context.getProjectMetadata(projectName);
|
|
197
|
-
const projectRoot = (0, node_path_1.join)(context.workspaceRoot, root);
|
|
198
|
-
const browsers = (0, supported_browsers_1.getSupportedBrowsers)(projectRoot, context.logger);
|
|
199
|
-
const target = (0, utils_1.transformSupportedBrowsersToTargets)(browsers);
|
|
200
|
-
// Setup server and start listening
|
|
201
|
-
const serverConfiguration = await setupServer(serverOptions, generatedFiles, assetFiles, browserOptions.preserveSymlinks, externalMetadata, !!browserOptions.ssr, prebundleTransformer, target, browserOptions.loader, extensions?.middleware, transformers?.indexHtml, thirdPartySourcemaps);
|
|
202
|
-
server = await createServer(serverConfiguration);
|
|
203
|
-
await server.listen();
|
|
204
|
-
if (serverConfiguration.ssr?.optimizeDeps?.disabled === false) {
|
|
205
|
-
/**
|
|
206
|
-
* Vite will only start dependency optimization of SSR modules when the first request comes in.
|
|
207
|
-
* In some cases, this causes a long waiting time. To mitigate this, we call `ssrLoadModule` to
|
|
208
|
-
* initiate this process before the first request.
|
|
209
|
-
*
|
|
210
|
-
* NOTE: This will intentionally fail from the unknown module, but currently there is no other way
|
|
211
|
-
* to initiate the SSR dep optimizer.
|
|
212
|
-
*/
|
|
213
|
-
void server.ssrLoadModule('<deps-caller>').catch(() => { });
|
|
214
|
-
}
|
|
215
|
-
const urls = server.resolvedUrls;
|
|
216
|
-
if (urls && (urls.local.length || urls.network.length)) {
|
|
217
|
-
serverUrl = new URL(urls.local[0] ?? urls.network[0]);
|
|
218
|
-
}
|
|
219
|
-
// log connection information
|
|
220
|
-
server.printUrls();
|
|
221
|
-
server.bindCLIShortcuts({
|
|
222
|
-
print: true,
|
|
223
|
-
customShortcuts: [
|
|
224
|
-
{
|
|
225
|
-
key: 'r',
|
|
226
|
-
description: 'force reload browser',
|
|
227
|
-
action(server) {
|
|
228
|
-
server.ws.send({
|
|
229
|
-
type: 'full-reload',
|
|
230
|
-
path: '*',
|
|
231
|
-
});
|
|
232
|
-
},
|
|
233
|
-
},
|
|
234
|
-
],
|
|
235
|
-
});
|
|
236
|
-
}
|
|
237
|
-
// TODO: adjust output typings to reflect both development servers
|
|
238
|
-
yield {
|
|
239
|
-
success: true,
|
|
240
|
-
port: serverUrl?.port,
|
|
241
|
-
baseUrl: serverUrl?.href,
|
|
242
|
-
};
|
|
243
|
-
}
|
|
244
|
-
await new Promise((resolve) => (deferred = resolve));
|
|
245
|
-
}
|
|
246
|
-
exports.serveWithVite = serveWithVite;
|
|
247
|
-
function handleUpdate(normalizePath, generatedFiles, server, serverOptions, logger) {
|
|
248
|
-
const updatedFiles = [];
|
|
249
|
-
// Invalidate any updated files
|
|
250
|
-
for (const [file, record] of generatedFiles) {
|
|
251
|
-
if (record.updated) {
|
|
252
|
-
updatedFiles.push(file);
|
|
253
|
-
const updatedModules = server.moduleGraph.getModulesByFile(normalizePath((0, node_path_1.join)(server.config.root, file)));
|
|
254
|
-
updatedModules?.forEach((m) => server?.moduleGraph.invalidateModule(m));
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
if (!updatedFiles.length) {
|
|
258
|
-
return;
|
|
259
|
-
}
|
|
260
|
-
if (serverOptions.liveReload || serverOptions.hmr) {
|
|
261
|
-
if (updatedFiles.every((f) => f.endsWith('.css'))) {
|
|
262
|
-
const timestamp = Date.now();
|
|
263
|
-
server.ws.send({
|
|
264
|
-
type: 'update',
|
|
265
|
-
updates: updatedFiles.map((filePath) => {
|
|
266
|
-
return {
|
|
267
|
-
type: 'css-update',
|
|
268
|
-
timestamp,
|
|
269
|
-
path: filePath,
|
|
270
|
-
acceptedPath: filePath,
|
|
271
|
-
};
|
|
272
|
-
}),
|
|
273
|
-
});
|
|
274
|
-
logger.info('HMR update sent to client(s).');
|
|
275
|
-
return;
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
// Send reload command to clients
|
|
279
|
-
if (serverOptions.liveReload) {
|
|
280
|
-
server.ws.send({
|
|
281
|
-
type: 'full-reload',
|
|
282
|
-
path: '*',
|
|
283
|
-
});
|
|
284
|
-
logger.info('Page reload sent to client(s).');
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
function analyzeResultFiles(normalizePath, htmlIndexPath, resultFiles, generatedFiles) {
|
|
288
|
-
const seen = new Set(['/index.html']);
|
|
289
|
-
for (const file of resultFiles) {
|
|
290
|
-
let filePath;
|
|
291
|
-
if (file.path === htmlIndexPath) {
|
|
292
|
-
// Convert custom index output path to standard index path for dev-server usage.
|
|
293
|
-
// This mimics the Webpack dev-server behavior.
|
|
294
|
-
filePath = '/index.html';
|
|
295
|
-
}
|
|
296
|
-
else {
|
|
297
|
-
filePath = '/' + normalizePath(file.path);
|
|
298
|
-
}
|
|
299
|
-
seen.add(filePath);
|
|
300
|
-
// Skip analysis of sourcemaps
|
|
301
|
-
if (filePath.endsWith('.map')) {
|
|
302
|
-
generatedFiles.set(filePath, {
|
|
303
|
-
contents: file.contents,
|
|
304
|
-
servable: file.type === bundler_context_1.BuildOutputFileType.Browser || file.type === bundler_context_1.BuildOutputFileType.Media,
|
|
305
|
-
size: file.contents.byteLength,
|
|
306
|
-
updated: false,
|
|
307
|
-
});
|
|
308
|
-
continue;
|
|
309
|
-
}
|
|
310
|
-
const existingRecord = generatedFiles.get(filePath);
|
|
311
|
-
if (existingRecord &&
|
|
312
|
-
existingRecord.size === file.contents.byteLength &&
|
|
313
|
-
existingRecord.hash === file.hash) {
|
|
314
|
-
// Same file
|
|
315
|
-
existingRecord.updated = false;
|
|
316
|
-
continue;
|
|
317
|
-
}
|
|
318
|
-
// New or updated file
|
|
319
|
-
generatedFiles.set(filePath, {
|
|
320
|
-
contents: file.contents,
|
|
321
|
-
size: file.contents.byteLength,
|
|
322
|
-
hash: file.hash,
|
|
323
|
-
updated: true,
|
|
324
|
-
servable: file.type === bundler_context_1.BuildOutputFileType.Browser || file.type === bundler_context_1.BuildOutputFileType.Media,
|
|
325
|
-
});
|
|
326
|
-
}
|
|
327
|
-
// Clear stale output files
|
|
328
|
-
for (const file of generatedFiles.keys()) {
|
|
329
|
-
if (!seen.has(file)) {
|
|
330
|
-
generatedFiles.delete(file);
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
async function setupServer(serverOptions, outputFiles, assets, preserveSymlinks, externalMetadata, ssr, prebundleTransformer, target, prebundleLoaderExtensions, extensionMiddleware, indexHtmlTransformer, thirdPartySourcemaps = false) {
|
|
335
|
-
const proxy = await (0, utils_2.loadProxyConfiguration)(serverOptions.workspaceRoot, serverOptions.proxyConfig, true);
|
|
336
|
-
// dynamically import Vite for ESM compatibility
|
|
337
|
-
const { normalizePath } = await (0, load_esm_1.loadEsmModule)('vite');
|
|
338
|
-
// Path will not exist on disk and only used to provide separate path for Vite requests
|
|
339
|
-
const virtualProjectRoot = normalizePath((0, node_path_1.join)(serverOptions.workspaceRoot, `.angular/vite-root`, serverOptions.buildTarget.project));
|
|
340
|
-
const serverExplicitExternal = [
|
|
341
|
-
...(await Promise.resolve().then(() => __importStar(require('node:module')))).builtinModules,
|
|
342
|
-
...externalMetadata.explicit,
|
|
343
|
-
];
|
|
344
|
-
const cacheDir = (0, node_path_1.join)(serverOptions.cacheOptions.path, 'vite');
|
|
345
|
-
const configuration = {
|
|
346
|
-
configFile: false,
|
|
347
|
-
envFile: false,
|
|
348
|
-
cacheDir,
|
|
349
|
-
root: virtualProjectRoot,
|
|
350
|
-
publicDir: false,
|
|
351
|
-
esbuild: false,
|
|
352
|
-
mode: 'development',
|
|
353
|
-
// We use custom as we do not rely on Vite's htmlFallbackMiddleware and indexHtmlMiddleware.
|
|
354
|
-
appType: 'custom',
|
|
355
|
-
css: {
|
|
356
|
-
devSourcemap: true,
|
|
357
|
-
},
|
|
358
|
-
// Vite will normalize the `base` option by adding a leading slash.
|
|
359
|
-
base: serverOptions.servePath,
|
|
360
|
-
resolve: {
|
|
361
|
-
mainFields: ['es2020', 'browser', 'module', 'main'],
|
|
362
|
-
preserveSymlinks,
|
|
363
|
-
},
|
|
364
|
-
server: {
|
|
365
|
-
port: serverOptions.port,
|
|
366
|
-
strictPort: true,
|
|
367
|
-
host: serverOptions.host,
|
|
368
|
-
open: serverOptions.open,
|
|
369
|
-
headers: serverOptions.headers,
|
|
370
|
-
proxy,
|
|
371
|
-
cors: {
|
|
372
|
-
// Allow preflight requests to be proxied.
|
|
373
|
-
preflightContinue: true,
|
|
374
|
-
},
|
|
375
|
-
// File watching is handled by the build directly. `null` disables file watching for Vite.
|
|
376
|
-
watch: null,
|
|
377
|
-
fs: {
|
|
378
|
-
// Ensure cache directory, node modules, and all assets are accessible by the client.
|
|
379
|
-
// The first two are required for Vite to function in prebundling mode (the default) and to load
|
|
380
|
-
// the Vite client-side code for browser reloading. These would be available by default but when
|
|
381
|
-
// the `allow` option is explicitly configured, they must be included manually.
|
|
382
|
-
allow: [cacheDir, (0, node_path_1.join)(serverOptions.workspaceRoot, 'node_modules'), ...assets.values()],
|
|
383
|
-
// Temporary disable cached FS checks.
|
|
384
|
-
// This is because we configure `config.base` to a virtual directory which causes `getRealPath` to fail.
|
|
385
|
-
// See: https://github.com/vitejs/vite/blob/b2873ac3936de25ca8784327cb9ef16bd4881805/packages/vite/src/node/fsUtils.ts#L45-L67
|
|
386
|
-
cachedChecks: false,
|
|
387
|
-
},
|
|
388
|
-
// This is needed when `externalDependencies` is used to prevent Vite load errors.
|
|
389
|
-
// NOTE: If Vite adds direct support for externals, this can be removed.
|
|
390
|
-
preTransformRequests: externalMetadata.explicit.length === 0,
|
|
391
|
-
},
|
|
392
|
-
ssr: {
|
|
393
|
-
// Note: `true` and `/.*/` have different sematics. When true, the `external` option is ignored.
|
|
394
|
-
noExternal: /.*/,
|
|
395
|
-
// Exclude any Node.js built in module and provided dependencies (currently build defined externals)
|
|
396
|
-
external: serverExplicitExternal,
|
|
397
|
-
optimizeDeps: getDepOptimizationConfig({
|
|
398
|
-
/**
|
|
399
|
-
* *********************************************
|
|
400
|
-
* NOTE: Temporary disable 'optimizeDeps' for SSR.
|
|
401
|
-
* *********************************************
|
|
402
|
-
*
|
|
403
|
-
* Currently this causes a number of issues.
|
|
404
|
-
* - Deps are re-optimized everytime the server is started.
|
|
405
|
-
* - Added deps after a rebuild are not optimized.
|
|
406
|
-
* - Breaks RxJs (Unless it is added as external). See: https://github.com/angular/angular-cli/issues/26235
|
|
407
|
-
*/
|
|
408
|
-
// Only enable with caching since it causes prebundle dependencies to be cached
|
|
409
|
-
disabled: true, // serverOptions.prebundle === false,
|
|
410
|
-
// Exclude any explicitly defined dependencies (currently build defined externals and node.js built-ins)
|
|
411
|
-
exclude: serverExplicitExternal,
|
|
412
|
-
// Include all implict dependencies from the external packages internal option
|
|
413
|
-
include: externalMetadata.implicitServer,
|
|
414
|
-
ssr: true,
|
|
415
|
-
prebundleTransformer,
|
|
416
|
-
target,
|
|
417
|
-
loader: prebundleLoaderExtensions,
|
|
418
|
-
thirdPartySourcemaps,
|
|
419
|
-
}),
|
|
420
|
-
},
|
|
421
|
-
plugins: [
|
|
422
|
-
(0, i18n_locale_plugin_1.createAngularLocaleDataPlugin)(),
|
|
423
|
-
(0, angular_memory_plugin_1.createAngularMemoryPlugin)({
|
|
424
|
-
workspaceRoot: serverOptions.workspaceRoot,
|
|
425
|
-
virtualProjectRoot,
|
|
426
|
-
outputFiles,
|
|
427
|
-
assets,
|
|
428
|
-
ssr,
|
|
429
|
-
external: externalMetadata.explicit,
|
|
430
|
-
indexHtmlTransformer,
|
|
431
|
-
extensionMiddleware,
|
|
432
|
-
normalizePath,
|
|
433
|
-
}),
|
|
434
|
-
],
|
|
435
|
-
// Browser only optimizeDeps. (This does not run for SSR dependencies).
|
|
436
|
-
optimizeDeps: getDepOptimizationConfig({
|
|
437
|
-
// Only enable with caching since it causes prebundle dependencies to be cached
|
|
438
|
-
disabled: serverOptions.prebundle === false,
|
|
439
|
-
// Exclude any explicitly defined dependencies (currently build defined externals)
|
|
440
|
-
exclude: externalMetadata.explicit,
|
|
441
|
-
// Include all implict dependencies from the external packages internal option
|
|
442
|
-
include: externalMetadata.implicitBrowser,
|
|
443
|
-
ssr: false,
|
|
444
|
-
prebundleTransformer,
|
|
445
|
-
target,
|
|
446
|
-
loader: prebundleLoaderExtensions,
|
|
447
|
-
thirdPartySourcemaps,
|
|
448
|
-
}),
|
|
449
|
-
};
|
|
450
|
-
if (serverOptions.ssl) {
|
|
451
|
-
if (serverOptions.sslCert && serverOptions.sslKey) {
|
|
452
|
-
// server configuration is defined above
|
|
453
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
454
|
-
configuration.server.https = {
|
|
455
|
-
cert: await (0, promises_1.readFile)(serverOptions.sslCert),
|
|
456
|
-
key: await (0, promises_1.readFile)(serverOptions.sslKey),
|
|
457
|
-
};
|
|
458
|
-
}
|
|
459
|
-
else {
|
|
460
|
-
const { default: basicSslPlugin } = await Promise.resolve().then(() => __importStar(require('@vitejs/plugin-basic-ssl')));
|
|
461
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
462
|
-
configuration.plugins ??= [];
|
|
463
|
-
configuration.plugins.push(basicSslPlugin());
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
return configuration;
|
|
467
|
-
}
|
|
468
|
-
exports.setupServer = setupServer;
|
|
469
|
-
function getDepOptimizationConfig({ disabled, exclude, include, target, prebundleTransformer, ssr, loader, thirdPartySourcemaps, }) {
|
|
470
|
-
const plugins = [
|
|
471
|
-
{
|
|
472
|
-
name: `angular-vite-optimize-deps${ssr ? '-ssr' : ''}${thirdPartySourcemaps ? '-vendor-sourcemap' : ''}`,
|
|
473
|
-
setup(build) {
|
|
474
|
-
build.onLoad({ filter: /\.[cm]?js$/ }, async (args) => {
|
|
475
|
-
return {
|
|
476
|
-
contents: await prebundleTransformer.transformFile(args.path),
|
|
477
|
-
loader: 'js',
|
|
478
|
-
};
|
|
479
|
-
});
|
|
480
|
-
},
|
|
481
|
-
},
|
|
482
|
-
];
|
|
483
|
-
if (ssr) {
|
|
484
|
-
plugins.unshift((0, rxjs_esm_resolution_plugin_1.createRxjsEsmResolutionPlugin)());
|
|
485
|
-
}
|
|
486
|
-
return {
|
|
487
|
-
// Exclude any explicitly defined dependencies (currently build defined externals)
|
|
488
|
-
exclude,
|
|
489
|
-
// NB: to disable the deps optimizer, set optimizeDeps.noDiscovery to true and optimizeDeps.include as undefined.
|
|
490
|
-
// Include all implict dependencies from the external packages internal option
|
|
491
|
-
include: disabled ? undefined : include,
|
|
492
|
-
noDiscovery: disabled,
|
|
493
|
-
// Add an esbuild plugin to run the Angular linker on dependencies
|
|
494
|
-
esbuildOptions: {
|
|
495
|
-
// Set esbuild supported targets.
|
|
496
|
-
target,
|
|
497
|
-
supported: (0, utils_1.getFeatureSupport)(target),
|
|
498
|
-
plugins,
|
|
499
|
-
loader,
|
|
500
|
-
},
|
|
501
|
-
};
|
|
502
|
-
}
|
|
@@ -1,27 +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 path="../../../../../../../../../../packages/angular_devkit/build_angular/src/babel-bazel.d.ts" />
|
|
9
|
-
/// <reference types="@angular/compiler-cli/private/babel" />
|
|
10
|
-
import { PluginObj } from '@babel/core';
|
|
11
|
-
/**
|
|
12
|
-
* Provides one or more keywords that if found within the content of a source file indicate
|
|
13
|
-
* that this plugin should be used with a source file.
|
|
14
|
-
*
|
|
15
|
-
* @returns An a string iterable containing one or more keywords.
|
|
16
|
-
*/
|
|
17
|
-
export declare function getKeywords(): Iterable<string>;
|
|
18
|
-
/**
|
|
19
|
-
* A babel plugin factory function for adjusting classes; primarily with Angular metadata.
|
|
20
|
-
* The adjustments include wrapping classes with known safe or no side effects with pure
|
|
21
|
-
* annotations to support dead code removal of unused classes. Angular compiler generated
|
|
22
|
-
* metadata static fields not required in AOT mode are also elided to better support bundler-
|
|
23
|
-
* level treeshaking.
|
|
24
|
-
*
|
|
25
|
-
* @returns A babel plugin object instance.
|
|
26
|
-
*/
|
|
27
|
-
export default function (): PluginObj;
|