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