@angular-devkit/build-angular 17.0.0-rc.2 → 17.0.0-rc.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/package.json +9 -8
- package/src/builders/app-shell/render-worker.d.ts +1 -1
- package/src/builders/app-shell/render-worker.js +16 -9
- package/src/builders/application/build-action.js +5 -2
- package/src/builders/application/execute-build.js +49 -30
- package/src/builders/dev-server/builder.d.ts +12 -1
- package/src/builders/dev-server/builder.js +13 -4
- package/src/builders/dev-server/vite-server.d.ts +9 -6
- package/src/builders/dev-server/vite-server.js +167 -63
- package/src/builders/extract-i18n/application-extraction.js +1 -0
- package/src/builders/prerender/routes-extractor-worker.js +1 -1
- package/src/builders/ssr-dev-server/index.d.ts +1 -1
- package/src/index.d.ts +1 -0
- package/src/index.js +3 -1
- package/src/tools/babel/plugins/elide-angular-metadata.js +14 -2
- package/src/tools/esbuild/angular/compiler-plugin.js +104 -57
- package/src/tools/esbuild/application-code-bundle.d.ts +3 -2
- package/src/tools/esbuild/application-code-bundle.js +7 -19
- package/src/tools/esbuild/bundler-context.d.ts +4 -1
- package/src/tools/esbuild/bundler-context.js +13 -8
- package/src/tools/esbuild/bundler-execution-result.d.ts +16 -14
- package/src/tools/esbuild/bundler-execution-result.js +18 -3
- package/src/tools/esbuild/commonjs-checker.js +12 -7
- package/src/tools/esbuild/global-scripts.d.ts +1 -1
- package/src/tools/esbuild/global-scripts.js +2 -1
- package/src/tools/esbuild/javascript-transformer.d.ts +2 -1
- package/src/tools/esbuild/javascript-transformer.js +44 -20
- package/src/tools/esbuild/utils.d.ts +1 -1
- package/src/tools/esbuild/utils.js +18 -4
- package/src/utils/bundle-calculator.js +1 -1
- package/src/utils/environment-options.d.ts +1 -0
- package/src/utils/environment-options.js +7 -2
- package/src/utils/load-esm.js +6 -1
- package/src/utils/routes-extractor/extractor.d.ts +1 -1
- package/src/utils/routes-extractor/extractor.js +2 -2
- package/src/utils/server-rendering/esm-in-memory-loader/loader-hooks.d.ts +0 -4
- package/src/utils/server-rendering/esm-in-memory-loader/loader-hooks.js +78 -28
- 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/prerender.js +25 -30
- package/src/utils/server-rendering/render-worker.d.ts +4 -2
- package/src/utils/server-rendering/render-worker.js +10 -4
- package/src/utils/server-rendering/routes-extractor-worker.d.ts +5 -3
- package/src/utils/server-rendering/routes-extractor-worker.js +12 -6
- package/src/utils/server-rendering/prerender-server.d.ts +0 -21
- package/src/utils/server-rendering/prerender-server.js +0 -102
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-devkit/build-angular",
|
|
3
|
-
"version": "17.0.0-rc.
|
|
3
|
+
"version": "17.0.0-rc.4",
|
|
4
4
|
"description": "Angular Webpack Build Facade",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"typings": "src/index.d.ts",
|
|
7
7
|
"builders": "builders.json",
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@ampproject/remapping": "2.2.1",
|
|
10
|
-
"@angular-devkit/architect": "0.1700.0-rc.
|
|
11
|
-
"@angular-devkit/build-webpack": "0.1700.0-rc.
|
|
12
|
-
"@angular-devkit/core": "17.0.0-rc.
|
|
10
|
+
"@angular-devkit/architect": "0.1700.0-rc.4",
|
|
11
|
+
"@angular-devkit/build-webpack": "0.1700.0-rc.4",
|
|
12
|
+
"@angular-devkit/core": "17.0.0-rc.4",
|
|
13
13
|
"@babel/core": "7.23.2",
|
|
14
14
|
"@babel/generator": "7.23.0",
|
|
15
15
|
"@babel/helper-annotate-as-pure": "7.22.5",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"@babel/preset-env": "7.23.2",
|
|
21
21
|
"@babel/runtime": "7.23.2",
|
|
22
22
|
"@discoveryjs/json-ext": "0.5.7",
|
|
23
|
-
"@ngtools/webpack": "17.0.0-rc.
|
|
23
|
+
"@ngtools/webpack": "17.0.0-rc.4",
|
|
24
24
|
"@vitejs/plugin-basic-ssl": "1.0.1",
|
|
25
25
|
"ansi-colors": "4.1.3",
|
|
26
26
|
"autoprefixer": "10.4.16",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"open": "8.4.2",
|
|
50
50
|
"ora": "5.4.1",
|
|
51
51
|
"parse5-html-rewriting-stream": "7.0.0",
|
|
52
|
-
"picomatch": "
|
|
52
|
+
"picomatch": "3.0.1",
|
|
53
53
|
"piscina": "4.1.0",
|
|
54
54
|
"postcss": "8.4.31",
|
|
55
55
|
"postcss-loader": "7.3.3",
|
|
@@ -60,10 +60,11 @@
|
|
|
60
60
|
"semver": "7.5.4",
|
|
61
61
|
"source-map-loader": "4.0.1",
|
|
62
62
|
"source-map-support": "0.5.21",
|
|
63
|
-
"terser": "5.
|
|
63
|
+
"terser": "5.24.0",
|
|
64
64
|
"text-table": "0.2.0",
|
|
65
65
|
"tree-kill": "1.2.2",
|
|
66
66
|
"tslib": "2.6.2",
|
|
67
|
+
"undici": "5.27.2",
|
|
67
68
|
"vite": "4.5.0",
|
|
68
69
|
"webpack": "5.89.0",
|
|
69
70
|
"webpack-dev-middleware": "6.1.1",
|
|
@@ -128,7 +129,7 @@
|
|
|
128
129
|
"url": "https://github.com/angular/angular-cli.git"
|
|
129
130
|
},
|
|
130
131
|
"engines": {
|
|
131
|
-
"node": "
|
|
132
|
+
"node": "^18.13.0 || >=20.9.0",
|
|
132
133
|
"npm": "^6.11.0 || ^7.5.6 || >=8.0.0",
|
|
133
134
|
"yarn": ">= 1.13.0"
|
|
134
135
|
},
|
|
@@ -20,7 +20,7 @@ interface RenderRequest {
|
|
|
20
20
|
/**
|
|
21
21
|
* An optional URL path that represents the Angular route that should be rendered.
|
|
22
22
|
*/
|
|
23
|
-
url: string
|
|
23
|
+
url: string;
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
26
|
* Renders an application based on a provided server bundle path, initial document, and optional URL route.
|
|
@@ -54,23 +54,30 @@ async function render({ serverBundlePath, document, url }) {
|
|
|
54
54
|
useValue: 'app-shell',
|
|
55
55
|
},
|
|
56
56
|
];
|
|
57
|
+
let renderAppPromise;
|
|
57
58
|
// Render platform server module
|
|
58
59
|
if (isBootstrapFn(bootstrapAppFn)) {
|
|
59
60
|
(0, node_assert_1.default)(renderApplication, `renderApplication was not exported from: ${serverBundlePath}.`);
|
|
60
|
-
|
|
61
|
+
renderAppPromise = renderApplication(bootstrapAppFn, {
|
|
61
62
|
document,
|
|
62
63
|
url,
|
|
63
64
|
platformProviders,
|
|
64
65
|
});
|
|
65
66
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
67
|
+
else {
|
|
68
|
+
(0, node_assert_1.default)(renderModule, `renderModule was not exported from: ${serverBundlePath}.`);
|
|
69
|
+
const moduleClass = bootstrapAppFn || AppServerModule;
|
|
70
|
+
(0, node_assert_1.default)(moduleClass, `Neither an AppServerModule nor a bootstrapping function was exported from: ${serverBundlePath}.`);
|
|
71
|
+
renderAppPromise = renderModule(moduleClass, {
|
|
72
|
+
document,
|
|
73
|
+
url,
|
|
74
|
+
extraProviders: platformProviders,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
// The below should really handled by the framework!!!.
|
|
78
|
+
let timer;
|
|
79
|
+
const renderingTimeout = new Promise((_, reject) => (timer = setTimeout(() => reject(new Error(`Page ${new URL(url, 'resolve://').pathname} did not render in 30 seconds.`)), 30000)));
|
|
80
|
+
return Promise.race([renderAppPromise, renderingTimeout]).finally(() => clearTimeout(timer));
|
|
74
81
|
}
|
|
75
82
|
function isBootstrapFn(value) {
|
|
76
83
|
// We can differentiate between a module and a bootstrap function by reading compiler-generated `ɵmod` static property:
|
|
@@ -38,6 +38,7 @@ const promises_1 = __importDefault(require("node:fs/promises"));
|
|
|
38
38
|
const node_path_1 = __importDefault(require("node:path"));
|
|
39
39
|
const sass_language_1 = require("../../tools/esbuild/stylesheets/sass-language");
|
|
40
40
|
const utils_1 = require("../../tools/esbuild/utils");
|
|
41
|
+
const environment_options_1 = require("../../utils/environment-options");
|
|
41
42
|
const error_1 = require("../../utils/error");
|
|
42
43
|
async function* runEsBuildBuildAction(action, options) {
|
|
43
44
|
const { writeToFileSystemFilter, writeToFileSystem = true, watch, poll, logger, deleteOutputPath, cacheOptions, outputPath, verbose, projectRoot, workspaceRoot, progress, } = options;
|
|
@@ -95,8 +96,10 @@ async function* runEsBuildBuildAction(action, options) {
|
|
|
95
96
|
});
|
|
96
97
|
// Setup abort support
|
|
97
98
|
options.signal?.addEventListener('abort', () => void watcher?.close());
|
|
98
|
-
//
|
|
99
|
-
|
|
99
|
+
// Watch the entire project root if 'NG_BUILD_WATCH_ROOT' environment variable is set
|
|
100
|
+
if (environment_options_1.shouldWatchRoot) {
|
|
101
|
+
watcher.add(projectRoot);
|
|
102
|
+
}
|
|
100
103
|
// Watch workspace for package manager changes
|
|
101
104
|
const packageWatchFiles = [
|
|
102
105
|
// manifest can affect module resolution
|
|
@@ -19,6 +19,7 @@ const global_styles_1 = require("../../tools/esbuild/global-styles");
|
|
|
19
19
|
const license_extractor_1 = require("../../tools/esbuild/license-extractor");
|
|
20
20
|
const utils_1 = require("../../tools/esbuild/utils");
|
|
21
21
|
const bundle_calculator_1 = require("../../utils/bundle-calculator");
|
|
22
|
+
const color_1 = require("../../utils/color");
|
|
22
23
|
const copy_assets_1 = require("../../utils/copy-assets");
|
|
23
24
|
const supported_browsers_1 = require("../../utils/supported-browsers");
|
|
24
25
|
const execute_post_bundle_1 = require("./execute-post-bundle");
|
|
@@ -58,7 +59,7 @@ async function executeBuild(options, context, rebuildState) {
|
|
|
58
59
|
// Global Scripts
|
|
59
60
|
if (options.globalScripts.length > 0) {
|
|
60
61
|
for (const initial of [true, false]) {
|
|
61
|
-
const bundleOptions = (0, global_scripts_1.createGlobalScriptsBundleOptions)(options, initial);
|
|
62
|
+
const bundleOptions = (0, global_scripts_1.createGlobalScriptsBundleOptions)(options, target, initial);
|
|
62
63
|
if (bundleOptions) {
|
|
63
64
|
bundlerContexts.push(new bundler_context_1.BundlerContext(workspaceRoot, !!options.watch, bundleOptions, () => initial));
|
|
64
65
|
}
|
|
@@ -68,7 +69,12 @@ async function executeBuild(options, context, rebuildState) {
|
|
|
68
69
|
if (serverEntryPoint && (prerenderOptions || appShellOptions || ssrOptions)) {
|
|
69
70
|
const nodeTargets = [...target, ...(0, utils_1.getSupportedNodeTargets)()];
|
|
70
71
|
// Server application code
|
|
71
|
-
bundlerContexts.push(new bundler_context_1.BundlerContext(workspaceRoot, !!options.watch, (0, application_code_bundle_1.createServerCodeBundleOptions)(
|
|
72
|
+
bundlerContexts.push(new bundler_context_1.BundlerContext(workspaceRoot, !!options.watch, (0, application_code_bundle_1.createServerCodeBundleOptions)({
|
|
73
|
+
...options,
|
|
74
|
+
// Disable external deps for server bundles.
|
|
75
|
+
// This is because it breaks Vite 'optimizeDeps' for SSR.
|
|
76
|
+
externalPackages: false,
|
|
77
|
+
}, nodeTargets, codeBundleCache), () => false));
|
|
72
78
|
// Server polyfills code
|
|
73
79
|
const serverPolyfillBundleOptions = (0, application_code_bundle_1.createServerPolyfillBundleOptions)(options, nodeTargets, codeBundleCache);
|
|
74
80
|
if (serverPolyfillBundleOptions) {
|
|
@@ -87,11 +93,33 @@ async function executeBuild(options, context, rebuildState) {
|
|
|
87
93
|
}
|
|
88
94
|
// Analyze external imports if external options are enabled
|
|
89
95
|
if (options.externalPackages || options.externalDependencies?.length) {
|
|
96
|
+
const { browser = new Set(), server = new Set() } = bundlingResult.externalImports;
|
|
90
97
|
// TODO: Filter externalImports to generate second argument to support wildcard externalDependency values
|
|
91
|
-
executionResult.setExternalMetadata([...
|
|
98
|
+
executionResult.setExternalMetadata([...browser], [...server], options.externalDependencies);
|
|
92
99
|
}
|
|
93
100
|
const { metafile, initialFiles, outputFiles } = bundlingResult;
|
|
94
101
|
executionResult.outputFiles.push(...outputFiles);
|
|
102
|
+
const changedFiles = rebuildState && executionResult.findChangedFiles(rebuildState.previousOutputHashes);
|
|
103
|
+
// Analyze files for bundle budget failures if present
|
|
104
|
+
let budgetFailures;
|
|
105
|
+
if (options.budgets) {
|
|
106
|
+
const compatStats = (0, budget_stats_1.generateBudgetStats)(metafile, initialFiles);
|
|
107
|
+
budgetFailures = [...(0, bundle_calculator_1.checkBudgets)(options.budgets, compatStats, true)];
|
|
108
|
+
if (budgetFailures.length > 0) {
|
|
109
|
+
const errors = budgetFailures
|
|
110
|
+
.filter((failure) => failure.severity === 'error')
|
|
111
|
+
.map(({ message }) => message);
|
|
112
|
+
const warnings = budgetFailures
|
|
113
|
+
.filter((failure) => failure.severity !== 'error')
|
|
114
|
+
.map(({ message }) => message);
|
|
115
|
+
await printWarningsAndErrorsToConsoleAndAddToResult(context, executionResult, warnings, errors);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
// Calculate estimated transfer size if scripts are optimized
|
|
119
|
+
let estimatedTransferSizes;
|
|
120
|
+
if (optimizationOptions.scripts || optimizationOptions.styles.minify) {
|
|
121
|
+
estimatedTransferSizes = await (0, utils_1.calculateEstimatedTransferSizes)(executionResult.outputFiles);
|
|
122
|
+
}
|
|
95
123
|
// Check metafile for CommonJS module usage if optimizing scripts
|
|
96
124
|
if (optimizationOptions.scripts) {
|
|
97
125
|
const messages = (0, commonjs_checker_1.checkCommonJSModules)(metafile, options.allowedCommonJsDependencies);
|
|
@@ -107,25 +135,6 @@ async function executeBuild(options, context, rebuildState) {
|
|
|
107
135
|
if (options.extractLicenses) {
|
|
108
136
|
executionResult.addOutputFile('3rdpartylicenses.txt', await (0, license_extractor_1.extractLicenses)(metafile, workspaceRoot), bundler_context_1.BuildOutputFileType.Root);
|
|
109
137
|
}
|
|
110
|
-
// Analyze files for bundle budget failures if present
|
|
111
|
-
let budgetFailures;
|
|
112
|
-
if (options.budgets) {
|
|
113
|
-
const compatStats = (0, budget_stats_1.generateBudgetStats)(metafile, initialFiles);
|
|
114
|
-
budgetFailures = [...(0, bundle_calculator_1.checkBudgets)(options.budgets, compatStats, true)];
|
|
115
|
-
for (const { severity, message } of budgetFailures) {
|
|
116
|
-
if (severity === 'error') {
|
|
117
|
-
context.logger.error(message);
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
context.logger.warn(message);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
// Calculate estimated transfer size if scripts are optimized
|
|
125
|
-
let estimatedTransferSizes;
|
|
126
|
-
if (optimizationOptions.scripts || optimizationOptions.styles.minify) {
|
|
127
|
-
estimatedTransferSizes = await (0, utils_1.calculateEstimatedTransferSizes)(executionResult.outputFiles);
|
|
128
|
-
}
|
|
129
138
|
// Perform i18n translation inlining if enabled
|
|
130
139
|
let prerenderedRoutes;
|
|
131
140
|
let errors;
|
|
@@ -146,11 +155,19 @@ async function executeBuild(options, context, rebuildState) {
|
|
|
146
155
|
executionResult.outputFiles.push(...result.additionalOutputFiles);
|
|
147
156
|
executionResult.assetFiles.push(...result.additionalAssets);
|
|
148
157
|
}
|
|
158
|
+
await printWarningsAndErrorsToConsoleAndAddToResult(context, executionResult, warnings, errors);
|
|
149
159
|
if (prerenderOptions) {
|
|
150
160
|
executionResult.addOutputFile('prerendered-routes.json', JSON.stringify({ routes: prerenderedRoutes.sort((a, b) => a.localeCompare(b)) }, null, 2), bundler_context_1.BuildOutputFileType.Root);
|
|
161
|
+
let prerenderMsg = `Prerendered ${prerenderedRoutes.length} static route`;
|
|
162
|
+
if (prerenderedRoutes.length > 1) {
|
|
163
|
+
prerenderMsg += 's.';
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
prerenderMsg += '.';
|
|
167
|
+
}
|
|
168
|
+
context.logger.info(color_1.colors.magenta(prerenderMsg) + '\n');
|
|
151
169
|
}
|
|
152
|
-
|
|
153
|
-
(0, utils_1.logBuildStats)(context, metafile, initialFiles, budgetFailures, estimatedTransferSizes);
|
|
170
|
+
(0, utils_1.logBuildStats)(context, metafile, initialFiles, budgetFailures, changedFiles, estimatedTransferSizes);
|
|
154
171
|
// Write metafile if stats option is enabled
|
|
155
172
|
if (options.stats) {
|
|
156
173
|
executionResult.addOutputFile('stats.json', JSON.stringify(metafile, null, 2), bundler_context_1.BuildOutputFileType.Root);
|
|
@@ -158,11 +175,13 @@ async function executeBuild(options, context, rebuildState) {
|
|
|
158
175
|
return executionResult;
|
|
159
176
|
}
|
|
160
177
|
exports.executeBuild = executeBuild;
|
|
161
|
-
function
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
for (const warning of warnings) {
|
|
166
|
-
context.logger.warn(warning);
|
|
178
|
+
async function printWarningsAndErrorsToConsoleAndAddToResult(context, executionResult, warnings, errors) {
|
|
179
|
+
const errorMessages = errors.map((text) => ({ text, location: null }));
|
|
180
|
+
if (errorMessages.length) {
|
|
181
|
+
executionResult.addErrors(errorMessages);
|
|
167
182
|
}
|
|
183
|
+
await (0, utils_1.logMessages)(context, {
|
|
184
|
+
errors: errorMessages,
|
|
185
|
+
warnings: warnings.map((text) => ({ text, location: null })),
|
|
186
|
+
});
|
|
168
187
|
}
|
|
@@ -5,8 +5,10 @@
|
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
|
+
/// <reference types="node" />
|
|
8
9
|
import type { BuilderContext } from '@angular-devkit/architect';
|
|
9
10
|
import type { Plugin } from 'esbuild';
|
|
11
|
+
import type http from 'node:http';
|
|
10
12
|
import { Observable } from 'rxjs';
|
|
11
13
|
import type { ExecutionTransformer } from '../../transforms';
|
|
12
14
|
import type { IndexHtmlTransform } from '../../utils/index-file/index-html-generator';
|
|
@@ -14,10 +16,16 @@ import type { Schema as DevServerBuilderOptions } from './schema';
|
|
|
14
16
|
import type { DevServerBuilderOutput } from './webpack-server';
|
|
15
17
|
/**
|
|
16
18
|
* A Builder that executes a development server based on the provided browser target option.
|
|
19
|
+
*
|
|
20
|
+
* Usage of the `transforms` and/or `extensions` parameters is NOT supported and may cause
|
|
21
|
+
* unexpected build output or build failures.
|
|
22
|
+
*
|
|
17
23
|
* @param options Dev Server options.
|
|
18
24
|
* @param context The build context.
|
|
19
25
|
* @param transforms A map of transforms that can be used to hook into some logic (such as
|
|
20
26
|
* transforming webpack configuration before passing it to webpack).
|
|
27
|
+
* @param extensions An optional object containing an array of build plugins (esbuild-based)
|
|
28
|
+
* and/or HTTP request middleware.
|
|
21
29
|
*
|
|
22
30
|
* @experimental Direct usage of this function is considered experimental.
|
|
23
31
|
*/
|
|
@@ -25,4 +33,7 @@ export declare function execute(options: DevServerBuilderOptions, context: Build
|
|
|
25
33
|
webpackConfiguration?: ExecutionTransformer<import('webpack').Configuration>;
|
|
26
34
|
logging?: import('@angular-devkit/build-webpack').WebpackLoggingCallback;
|
|
27
35
|
indexHtml?: IndexHtmlTransform;
|
|
28
|
-
},
|
|
36
|
+
}, extensions?: {
|
|
37
|
+
buildPlugins?: Plugin[];
|
|
38
|
+
middleware?: ((req: http.IncomingMessage, res: http.ServerResponse, next: (err?: unknown) => void) => void)[];
|
|
39
|
+
}): Observable<DevServerBuilderOutput>;
|
|
@@ -37,14 +37,20 @@ const purge_cache_1 = require("../../utils/purge-cache");
|
|
|
37
37
|
const options_1 = require("./options");
|
|
38
38
|
/**
|
|
39
39
|
* A Builder that executes a development server based on the provided browser target option.
|
|
40
|
+
*
|
|
41
|
+
* Usage of the `transforms` and/or `extensions` parameters is NOT supported and may cause
|
|
42
|
+
* unexpected build output or build failures.
|
|
43
|
+
*
|
|
40
44
|
* @param options Dev Server options.
|
|
41
45
|
* @param context The build context.
|
|
42
46
|
* @param transforms A map of transforms that can be used to hook into some logic (such as
|
|
43
47
|
* transforming webpack configuration before passing it to webpack).
|
|
48
|
+
* @param extensions An optional object containing an array of build plugins (esbuild-based)
|
|
49
|
+
* and/or HTTP request middleware.
|
|
44
50
|
*
|
|
45
51
|
* @experimental Direct usage of this function is considered experimental.
|
|
46
52
|
*/
|
|
47
|
-
function execute(options, context, transforms = {},
|
|
53
|
+
function execute(options, context, transforms = {}, extensions) {
|
|
48
54
|
// Determine project name from builder context target
|
|
49
55
|
const projectName = context.target?.project;
|
|
50
56
|
if (!projectName) {
|
|
@@ -56,14 +62,17 @@ function execute(options, context, transforms = {}, plugins) {
|
|
|
56
62
|
if (builderName === '@angular-devkit/build-angular:application' ||
|
|
57
63
|
builderName === '@angular-devkit/build-angular:browser-esbuild' ||
|
|
58
64
|
normalizedOptions.forceEsbuild) {
|
|
59
|
-
if (
|
|
65
|
+
if (transforms?.logging || transforms?.webpackConfiguration) {
|
|
60
66
|
throw new Error('The `application` and `browser-esbuild` builders do not support Webpack transforms.');
|
|
61
67
|
}
|
|
62
|
-
return (0, rxjs_1.defer)(() => Promise.resolve().then(() => __importStar(require('./vite-server')))).pipe((0, rxjs_1.switchMap)(({ serveWithVite }) => serveWithVite(normalizedOptions, builderName, context,
|
|
68
|
+
return (0, rxjs_1.defer)(() => Promise.resolve().then(() => __importStar(require('./vite-server')))).pipe((0, rxjs_1.switchMap)(({ serveWithVite }) => serveWithVite(normalizedOptions, builderName, context, transforms, extensions)));
|
|
63
69
|
}
|
|
64
|
-
if (
|
|
70
|
+
if (extensions?.buildPlugins?.length) {
|
|
65
71
|
throw new Error('Only the `application` and `browser-esbuild` builders support plugins.');
|
|
66
72
|
}
|
|
73
|
+
if (extensions?.middleware?.length) {
|
|
74
|
+
throw new Error('Only the `application` and `browser-esbuild` builders support middleware.');
|
|
75
|
+
}
|
|
67
76
|
// Use Webpack for all other browser targets
|
|
68
77
|
return (0, rxjs_1.defer)(() => Promise.resolve().then(() => __importStar(require('./webpack-server')))).pipe((0, rxjs_1.switchMap)(({ serveWebpackBrowser }) => serveWebpackBrowser(normalizedOptions, builderName, context, transforms)));
|
|
69
78
|
}));
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import type { BuilderContext } from '@angular-devkit/architect';
|
|
9
9
|
import type { Plugin } from 'esbuild';
|
|
10
|
-
import type { InlineConfig } from 'vite';
|
|
10
|
+
import type { Connect, InlineConfig } from 'vite';
|
|
11
|
+
import { ExternalResultMetadata } from '../../tools/esbuild/bundler-execution-result';
|
|
11
12
|
import { JavaScriptTransformer } from '../../tools/esbuild/javascript-transformer';
|
|
12
13
|
import type { NormalizedDevServerOptions } from './options';
|
|
13
14
|
import type { DevServerBuilderOutput } from './webpack-server';
|
|
@@ -18,9 +19,11 @@ interface OutputFileRecord {
|
|
|
18
19
|
updated: boolean;
|
|
19
20
|
servable: boolean;
|
|
20
21
|
}
|
|
21
|
-
export declare function serveWithVite(serverOptions: NormalizedDevServerOptions, builderName: string, context: BuilderContext,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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[], extensionMiddleware?: Connect.NextHandleFunction[], indexHtmlTransformer?: (content: string) => Promise<string>): Promise<InlineConfig>;
|
|
26
29
|
export {};
|