@angular/build 19.0.0-rc.0 → 19.0.0-rc.1
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 +6 -6
- package/src/builders/application/build-action.js +13 -1
- package/src/builders/application/execute-build.js +38 -31
- package/src/builders/application/execute-post-bundle.js +19 -4
- package/src/builders/application/options.d.ts +10 -1
- package/src/builders/application/options.js +9 -0
- package/src/builders/application/setup-bundling.d.ts +4 -1
- package/src/builders/application/setup-bundling.js +18 -11
- package/src/builders/dev-server/options.d.ts +2 -2
- package/src/builders/dev-server/options.js +2 -2
- package/src/builders/dev-server/schema.d.ts +2 -1
- package/src/builders/dev-server/schema.json +1 -2
- package/src/builders/dev-server/vite-server.d.ts +2 -1
- package/src/builders/dev-server/vite-server.js +94 -61
- package/src/tools/angular/angular-host.js +13 -2
- package/src/tools/esbuild/angular/compiler-plugin.d.ts +1 -0
- package/src/tools/esbuild/angular/compiler-plugin.js +5 -0
- package/src/tools/esbuild/angular/component-stylesheets.d.ts +1 -0
- package/src/tools/esbuild/angular/component-stylesheets.js +3 -0
- package/src/tools/esbuild/angular/source-file-cache.d.ts +1 -1
- package/src/tools/esbuild/angular/source-file-cache.js +6 -2
- package/src/tools/esbuild/application-code-bundle.d.ts +5 -4
- package/src/tools/esbuild/application-code-bundle.js +245 -239
- package/src/tools/esbuild/bundler-execution-result.d.ts +10 -2
- package/src/tools/esbuild/bundler-execution-result.js +12 -9
- package/src/tools/esbuild/compiler-plugin-options.d.ts +2 -1
- package/src/tools/esbuild/compiler-plugin-options.js +3 -2
- package/src/tools/esbuild/javascript-transformer.js +2 -1
- package/src/tools/esbuild/server-bundle-metadata-plugin.d.ts +1 -1
- package/src/tools/esbuild/server-bundle-metadata-plugin.js +1 -1
- package/src/tools/vite/middlewares/assets-middleware.d.ts +6 -1
- package/src/tools/vite/middlewares/assets-middleware.js +27 -23
- package/src/tools/vite/middlewares/component-middleware.js +1 -1
- package/src/tools/vite/middlewares/index.d.ts +1 -1
- package/src/tools/vite/middlewares/ssr-middleware.js +5 -2
- package/src/tools/vite/plugins/angular-memory-plugin.d.ts +1 -0
- package/src/tools/vite/plugins/angular-memory-plugin.js +5 -13
- package/src/tools/vite/plugins/setup-middlewares-plugin.d.ts +2 -1
- package/src/tools/vite/plugins/setup-middlewares-plugin.js +11 -3
- package/src/utils/environment-options.d.ts +1 -0
- package/src/utils/environment-options.js +3 -1
- package/src/utils/normalize-cache.js +1 -1
- package/src/utils/server-rendering/esm-in-memory-loader/utils.d.ts +8 -0
- package/src/utils/server-rendering/esm-in-memory-loader/utils.js +13 -0
- package/src/utils/server-rendering/manifest.d.ts +9 -8
- package/src/utils/server-rendering/manifest.js +17 -23
- package/src/utils/server-rendering/prerender.js +25 -16
- package/src/utils/server-rendering/render-worker.js +4 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular/build",
|
|
3
|
-
"version": "19.0.0-rc.
|
|
3
|
+
"version": "19.0.0-rc.1",
|
|
4
4
|
"description": "Official build system for Angular",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Angular CLI",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"builders": "builders.json",
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@ampproject/remapping": "2.3.0",
|
|
26
|
-
"@angular-devkit/architect": "0.1900.0-rc.
|
|
26
|
+
"@angular-devkit/architect": "0.1900.0-rc.1",
|
|
27
27
|
"@babel/core": "7.26.0",
|
|
28
28
|
"@babel/helper-annotate-as-pure": "7.25.9",
|
|
29
29
|
"@babel/helper-split-export-declaration": "7.24.7",
|
|
@@ -42,14 +42,14 @@
|
|
|
42
42
|
"parse5-html-rewriting-stream": "7.0.0",
|
|
43
43
|
"picomatch": "4.0.2",
|
|
44
44
|
"piscina": "4.7.0",
|
|
45
|
-
"rollup": "4.24.
|
|
46
|
-
"sass": "1.80.
|
|
45
|
+
"rollup": "4.24.4",
|
|
46
|
+
"sass": "1.80.6",
|
|
47
47
|
"semver": "7.6.3",
|
|
48
48
|
"vite": "5.4.10",
|
|
49
49
|
"watchpack": "2.4.2"
|
|
50
50
|
},
|
|
51
51
|
"optionalDependencies": {
|
|
52
|
-
"lmdb": "3.1.
|
|
52
|
+
"lmdb": "3.1.4"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
55
|
"@angular/compiler": "^19.0.0-next.9",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"@angular/localize": "^19.0.0-next.9",
|
|
58
58
|
"@angular/platform-server": "^19.0.0-next.9",
|
|
59
59
|
"@angular/service-worker": "^19.0.0-next.9",
|
|
60
|
-
"@angular/ssr": "^19.0.0-rc.
|
|
60
|
+
"@angular/ssr": "^19.0.0-rc.1",
|
|
61
61
|
"less": "^4.2.0",
|
|
62
62
|
"postcss": "^8.4.0",
|
|
63
63
|
"tailwindcss": "^2.0.0 || ^3.0.0",
|
|
@@ -162,7 +162,7 @@ async function* runEsBuildBuildAction(action, options) {
|
|
|
162
162
|
(0, sass_language_1.shutdownSassWorkerPool)();
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
|
-
async function emitOutputResult({ outputFiles, assetFiles, errors, warnings, externalMetadata, htmlIndexPath, htmlBaseHref, }, outputOptions) {
|
|
165
|
+
async function emitOutputResult({ outputFiles, assetFiles, errors, warnings, externalMetadata, htmlIndexPath, htmlBaseHref, templateUpdates, }, outputOptions) {
|
|
166
166
|
if (errors.length > 0) {
|
|
167
167
|
return {
|
|
168
168
|
kind: results_1.ResultKind.Failure,
|
|
@@ -173,6 +173,18 @@ async function emitOutputResult({ outputFiles, assetFiles, errors, warnings, ext
|
|
|
173
173
|
},
|
|
174
174
|
};
|
|
175
175
|
}
|
|
176
|
+
// Template updates only exist if no other changes have occurred
|
|
177
|
+
if (templateUpdates?.size) {
|
|
178
|
+
const updateResult = {
|
|
179
|
+
kind: results_1.ResultKind.ComponentUpdate,
|
|
180
|
+
updates: Array.from(templateUpdates).map(([id, content]) => ({
|
|
181
|
+
type: 'template',
|
|
182
|
+
id,
|
|
183
|
+
content,
|
|
184
|
+
})),
|
|
185
|
+
};
|
|
186
|
+
return updateResult;
|
|
187
|
+
}
|
|
176
188
|
const result = {
|
|
177
189
|
kind: results_1.ResultKind.Full,
|
|
178
190
|
warnings: warnings,
|
|
@@ -6,12 +6,8 @@
|
|
|
6
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
7
7
|
* found in the LICENSE file at https://angular.dev/license
|
|
8
8
|
*/
|
|
9
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
-
};
|
|
12
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
10
|
exports.executeBuild = executeBuild;
|
|
14
|
-
const node_assert_1 = __importDefault(require("node:assert"));
|
|
15
11
|
const source_file_cache_1 = require("../../tools/esbuild/angular/source-file-cache");
|
|
16
12
|
const budget_stats_1 = require("../../tools/esbuild/budget-stats");
|
|
17
13
|
const bundler_context_1 = require("../../tools/esbuild/bundler-context");
|
|
@@ -28,11 +24,10 @@ const supported_browsers_1 = require("../../utils/supported-browsers");
|
|
|
28
24
|
const chunk_optimizer_1 = require("./chunk-optimizer");
|
|
29
25
|
const execute_post_bundle_1 = require("./execute-post-bundle");
|
|
30
26
|
const i18n_1 = require("./i18n");
|
|
31
|
-
const schema_1 = require("./schema");
|
|
32
27
|
const setup_bundling_1 = require("./setup-bundling");
|
|
33
28
|
// eslint-disable-next-line max-lines-per-function
|
|
34
29
|
async function executeBuild(options, context, rebuildState) {
|
|
35
|
-
const { projectRoot, workspaceRoot, i18nOptions, optimizationOptions, assets,
|
|
30
|
+
const { projectRoot, workspaceRoot, i18nOptions, optimizationOptions, assets, cacheOptions, serverEntryPoint, baseHref, ssrOptions, verbose, colors, jsonLogs, } = options;
|
|
36
31
|
// TODO: Consider integrating into watch mode. Would require full rebuild on target changes.
|
|
37
32
|
const browsers = (0, supported_browsers_1.getSupportedBrowsers)(projectRoot, context.logger);
|
|
38
33
|
// Load active translations if inlining
|
|
@@ -44,34 +39,55 @@ async function executeBuild(options, context, rebuildState) {
|
|
|
44
39
|
let bundlerContexts;
|
|
45
40
|
let componentStyleBundler;
|
|
46
41
|
let codeBundleCache;
|
|
42
|
+
let bundlingResult;
|
|
43
|
+
let templateUpdates;
|
|
47
44
|
if (rebuildState) {
|
|
48
45
|
bundlerContexts = rebuildState.rebuildContexts;
|
|
49
46
|
componentStyleBundler = rebuildState.componentStyleBundler;
|
|
50
47
|
codeBundleCache = rebuildState.codeBundleCache;
|
|
48
|
+
templateUpdates = rebuildState.templateUpdates;
|
|
49
|
+
// Reset template updates for new rebuild
|
|
50
|
+
templateUpdates?.clear();
|
|
51
|
+
const allFileChanges = rebuildState.fileChanges.all;
|
|
52
|
+
// Bundle all contexts that do not require TypeScript changed file checks.
|
|
53
|
+
// These will automatically use cached results based on the changed files.
|
|
54
|
+
bundlingResult = await bundler_context_1.BundlerContext.bundleAll(bundlerContexts.otherContexts, allFileChanges);
|
|
55
|
+
// Check the TypeScript code bundling cache for changes. If invalid, force a rebundle of
|
|
56
|
+
// all TypeScript related contexts.
|
|
57
|
+
const forceTypeScriptRebuild = codeBundleCache?.invalidate(allFileChanges);
|
|
58
|
+
const typescriptResults = [];
|
|
59
|
+
for (const typescriptContext of bundlerContexts.typescriptContexts) {
|
|
60
|
+
typescriptContext.invalidate(allFileChanges);
|
|
61
|
+
const result = await typescriptContext.bundle(forceTypeScriptRebuild);
|
|
62
|
+
typescriptResults.push(result);
|
|
63
|
+
}
|
|
64
|
+
bundlingResult = bundler_context_1.BundlerContext.mergeResults([bundlingResult, ...typescriptResults]);
|
|
51
65
|
}
|
|
52
66
|
else {
|
|
53
67
|
const target = (0, utils_1.transformSupportedBrowsersToTargets)(browsers);
|
|
54
68
|
codeBundleCache = new source_file_cache_1.SourceFileCache(cacheOptions.enabled ? cacheOptions.path : undefined);
|
|
55
69
|
componentStyleBundler = (0, setup_bundling_1.createComponentStyleBundler)(options, target);
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
let bundlingResult = await bundler_context_1.BundlerContext.bundleAll(bundlerContexts, rebuildState?.fileChanges.all);
|
|
59
|
-
if (rebuildState && options.externalRuntimeStyles) {
|
|
60
|
-
const invalidatedStylesheetEntries = componentStyleBundler.invalidate(rebuildState.fileChanges.all);
|
|
61
|
-
if (invalidatedStylesheetEntries?.length) {
|
|
62
|
-
const componentResults = [];
|
|
63
|
-
for (const stylesheetFile of invalidatedStylesheetEntries) {
|
|
64
|
-
// externalId is already linked in the bundler context so only enabling is required here
|
|
65
|
-
const result = await componentStyleBundler.bundleFile(stylesheetFile, true, true);
|
|
66
|
-
componentResults.push(result);
|
|
67
|
-
}
|
|
68
|
-
bundlingResult = bundler_context_1.BundlerContext.mergeResults([bundlingResult, ...componentResults]);
|
|
70
|
+
if (options.templateUpdates) {
|
|
71
|
+
templateUpdates = new Map();
|
|
69
72
|
}
|
|
73
|
+
bundlerContexts = (0, setup_bundling_1.setupBundlerContexts)(options, target, codeBundleCache, componentStyleBundler, templateUpdates);
|
|
74
|
+
// Bundle everything on initial build
|
|
75
|
+
bundlingResult = await bundler_context_1.BundlerContext.bundleAll([
|
|
76
|
+
...bundlerContexts.typescriptContexts,
|
|
77
|
+
...bundlerContexts.otherContexts,
|
|
78
|
+
]);
|
|
79
|
+
}
|
|
80
|
+
// Update any external component styles if enabled and rebuilding.
|
|
81
|
+
// TODO: Only attempt rebundling of invalidated styles once incremental build results are supported.
|
|
82
|
+
if (rebuildState && options.externalRuntimeStyles) {
|
|
83
|
+
componentStyleBundler.invalidate(rebuildState.fileChanges.all);
|
|
84
|
+
const componentResults = await componentStyleBundler.bundleAllFiles(true, true);
|
|
85
|
+
bundlingResult = bundler_context_1.BundlerContext.mergeResults([bundlingResult, ...componentResults]);
|
|
70
86
|
}
|
|
71
87
|
if (options.optimizationOptions.scripts && environment_options_1.shouldOptimizeChunks) {
|
|
72
88
|
bundlingResult = await (0, profiling_1.profileAsync)('OPTIMIZE_CHUNKS', () => (0, chunk_optimizer_1.optimizeChunks)(bundlingResult, options.sourcemapOptions.scripts ? !options.sourcemapOptions.hidden || 'hidden' : false));
|
|
73
89
|
}
|
|
74
|
-
const executionResult = new bundler_execution_result_1.ExecutionResult(bundlerContexts, componentStyleBundler, codeBundleCache);
|
|
90
|
+
const executionResult = new bundler_execution_result_1.ExecutionResult(bundlerContexts, componentStyleBundler, codeBundleCache, templateUpdates);
|
|
75
91
|
executionResult.addWarnings(bundlingResult.warnings);
|
|
76
92
|
// Add used external component style referenced files to be watched
|
|
77
93
|
if (options.externalRuntimeStyles) {
|
|
@@ -137,7 +153,7 @@ async function executeBuild(options, context, rebuildState) {
|
|
|
137
153
|
}
|
|
138
154
|
// Create server app engine manifest
|
|
139
155
|
if (serverEntryPoint) {
|
|
140
|
-
executionResult.addOutputFile(manifest_1.SERVER_APP_ENGINE_MANIFEST_FILENAME, (0, manifest_1.generateAngularServerAppEngineManifest)(i18nOptions, baseHref
|
|
156
|
+
executionResult.addOutputFile(manifest_1.SERVER_APP_ENGINE_MANIFEST_FILENAME, (0, manifest_1.generateAngularServerAppEngineManifest)(i18nOptions, baseHref), bundler_context_1.BuildOutputFileType.ServerRoot);
|
|
141
157
|
}
|
|
142
158
|
// Override auto-CSP settings if we are serving through Vite middleware.
|
|
143
159
|
if (context.builder.builderName === 'dev-server' && options.security) {
|
|
@@ -160,16 +176,7 @@ async function executeBuild(options, context, rebuildState) {
|
|
|
160
176
|
executionResult.outputFiles.push(...result.additionalOutputFiles);
|
|
161
177
|
executionResult.assetFiles.push(...result.additionalAssets);
|
|
162
178
|
}
|
|
163
|
-
|
|
164
|
-
const prerenderedRoutes = executionResult.prerenderedRoutes;
|
|
165
|
-
// Regenerate the manifest to append prerendered routes data. This is only needed if SSR is enabled.
|
|
166
|
-
if (outputMode === schema_1.OutputMode.Server && Object.keys(prerenderedRoutes).length) {
|
|
167
|
-
const manifest = executionResult.outputFiles.find((f) => f.path === manifest_1.SERVER_APP_ENGINE_MANIFEST_FILENAME);
|
|
168
|
-
(0, node_assert_1.default)(manifest, `${manifest_1.SERVER_APP_ENGINE_MANIFEST_FILENAME} was not found in output files.`);
|
|
169
|
-
manifest.contents = new TextEncoder().encode((0, manifest_1.generateAngularServerAppEngineManifest)(i18nOptions, baseHref, prerenderedRoutes));
|
|
170
|
-
}
|
|
171
|
-
executionResult.addOutputFile('prerendered-routes.json', JSON.stringify({ routes: prerenderedRoutes }, null, 2), bundler_context_1.BuildOutputFileType.Root);
|
|
172
|
-
}
|
|
179
|
+
executionResult.addOutputFile('prerendered-routes.json', JSON.stringify({ routes: executionResult.prerenderedRoutes }, null, 2), bundler_context_1.BuildOutputFileType.Root);
|
|
173
180
|
// Write metafile if stats option is enabled
|
|
174
181
|
if (options.stats) {
|
|
175
182
|
executionResult.addOutputFile('stats.json', JSON.stringify(metafile, null, 2), bundler_context_1.BuildOutputFileType.Root);
|
|
@@ -30,6 +30,7 @@ const schema_1 = require("./schema");
|
|
|
30
30
|
* @param initialFiles A map containing initial file information for the executed build.
|
|
31
31
|
* @param locale A language locale to insert in the index.html.
|
|
32
32
|
*/
|
|
33
|
+
// eslint-disable-next-line max-lines-per-function
|
|
33
34
|
async function executePostBundleSteps(options, outputFiles, assetFiles, initialFiles, locale) {
|
|
34
35
|
const additionalAssets = [];
|
|
35
36
|
const additionalOutputFiles = [];
|
|
@@ -55,7 +56,8 @@ async function executePostBundleSteps(options, outputFiles, assetFiles, initialF
|
|
|
55
56
|
}
|
|
56
57
|
// Create server manifest
|
|
57
58
|
if (serverEntryPoint) {
|
|
58
|
-
|
|
59
|
+
const { manifestContent, serverAssetsChunks } = (0, manifest_1.generateAngularServerAppManifest)(additionalHtmlOutputFiles, outputFiles, optimizationOptions.styles.inlineCritical ?? false, undefined, locale);
|
|
60
|
+
additionalOutputFiles.push(...serverAssetsChunks, (0, utils_1.createOutputFile)(manifest_1.SERVER_APP_MANIFEST_FILENAME, manifestContent, bundler_context_1.BuildOutputFileType.ServerApplication));
|
|
59
61
|
}
|
|
60
62
|
// Pre-render (SSG) and App-shell
|
|
61
63
|
// If localization is enabled, prerendering is handled in the inlining process.
|
|
@@ -87,8 +89,11 @@ async function executePostBundleSteps(options, outputFiles, assetFiles, initialF
|
|
|
87
89
|
switch (metadata.renderMode) {
|
|
88
90
|
case models_1.RouteRenderMode.Prerender:
|
|
89
91
|
case /* Legacy building mode */ undefined: {
|
|
90
|
-
if (!metadata.redirectTo
|
|
91
|
-
|
|
92
|
+
if (!metadata.redirectTo) {
|
|
93
|
+
serializableRouteTreeNodeForManifest.push(metadata);
|
|
94
|
+
if (!metadata.route.includes('*')) {
|
|
95
|
+
prerenderedRoutes[metadata.route] = { headers: metadata.headers };
|
|
96
|
+
}
|
|
92
97
|
}
|
|
93
98
|
break;
|
|
94
99
|
}
|
|
@@ -102,7 +107,17 @@ async function executePostBundleSteps(options, outputFiles, assetFiles, initialF
|
|
|
102
107
|
// Regenerate the manifest to append route tree. This is only needed if SSR is enabled.
|
|
103
108
|
const manifest = additionalOutputFiles.find((f) => f.path === manifest_1.SERVER_APP_MANIFEST_FILENAME);
|
|
104
109
|
(0, node_assert_1.default)(manifest, `${manifest_1.SERVER_APP_MANIFEST_FILENAME} was not found in output files.`);
|
|
105
|
-
|
|
110
|
+
const { manifestContent, serverAssetsChunks } = (0, manifest_1.generateAngularServerAppManifest)(additionalHtmlOutputFiles, outputFiles, optimizationOptions.styles.inlineCritical ?? false, serializableRouteTreeNodeForManifest, locale);
|
|
111
|
+
for (const chunk of serverAssetsChunks) {
|
|
112
|
+
const idx = additionalOutputFiles.findIndex(({ path }) => path === chunk.path);
|
|
113
|
+
if (idx === -1) {
|
|
114
|
+
additionalOutputFiles.push(chunk);
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
additionalOutputFiles[idx] = chunk;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
manifest.contents = new TextEncoder().encode(manifestContent);
|
|
106
121
|
}
|
|
107
122
|
}
|
|
108
123
|
additionalOutputFiles.push(...additionalHtmlOutputFiles.values());
|
|
@@ -36,8 +36,10 @@ interface InternalOptions {
|
|
|
36
36
|
* If given a relative path, it is resolved relative to the current workspace and will generate an output at the same relative location
|
|
37
37
|
* in the output directory. If given an absolute path, the output will be generated in the root of the output directory with the same base
|
|
38
38
|
* name.
|
|
39
|
+
*
|
|
40
|
+
* If provided a Map, the key is the name of the output bundle and the value is the entry point file.
|
|
39
41
|
*/
|
|
40
|
-
entryPoints?: Set<string>;
|
|
42
|
+
entryPoints?: Set<string> | Map<string, string>;
|
|
41
43
|
/** File extension to use for the generated output files. */
|
|
42
44
|
outExtension?: 'js' | 'mjs';
|
|
43
45
|
/**
|
|
@@ -66,6 +68,12 @@ interface InternalOptions {
|
|
|
66
68
|
* styles.
|
|
67
69
|
*/
|
|
68
70
|
externalRuntimeStyles?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Enables the AOT compiler to generate template component update functions.
|
|
73
|
+
* This option is only intended to be used with a development server that can process and serve component
|
|
74
|
+
* template updates.
|
|
75
|
+
*/
|
|
76
|
+
templateUpdates?: boolean;
|
|
69
77
|
/**
|
|
70
78
|
* Enables instrumentation to collect code coverage data for specific files.
|
|
71
79
|
*
|
|
@@ -184,6 +192,7 @@ export declare function normalizeOptions(context: BuilderContext, projectName: s
|
|
|
184
192
|
externalRuntimeStyles: boolean | undefined;
|
|
185
193
|
instrumentForCoverage: ((filename: string) => boolean) | undefined;
|
|
186
194
|
security: import("./schema").Security | undefined;
|
|
195
|
+
templateUpdates: boolean;
|
|
187
196
|
}>;
|
|
188
197
|
export declare function getLocaleBaseHref(baseHref: string | undefined, i18n: NormalizedApplicationBuildOptions['i18nOptions'], locale: string): string | undefined;
|
|
189
198
|
export {};
|
|
@@ -296,6 +296,7 @@ async function normalizeOptions(context, projectName, options, extensions) {
|
|
|
296
296
|
externalRuntimeStyles,
|
|
297
297
|
instrumentForCoverage,
|
|
298
298
|
security,
|
|
299
|
+
templateUpdates: !!options.templateUpdates,
|
|
299
300
|
};
|
|
300
301
|
}
|
|
301
302
|
async function getTailwindConfig(searchDirectories, workspaceRoot, context) {
|
|
@@ -348,6 +349,14 @@ function normalizeEntryPoints(workspaceRoot, browser, entryPoints = new Set()) {
|
|
|
348
349
|
// Use `browser` alone.
|
|
349
350
|
return { 'main': node_path_1.default.join(workspaceRoot, browser) };
|
|
350
351
|
}
|
|
352
|
+
else if (entryPoints instanceof Map) {
|
|
353
|
+
return Object.fromEntries(Array.from(entryPoints.entries(), ([name, entryPoint]) => {
|
|
354
|
+
// Get the full file path to a relative entry point input. Leave bare specifiers alone so they are resolved as modules.
|
|
355
|
+
const isRelativePath = entryPoint.startsWith('.');
|
|
356
|
+
const entryPointPath = isRelativePath ? node_path_1.default.join(workspaceRoot, entryPoint) : entryPoint;
|
|
357
|
+
return [name, entryPointPath];
|
|
358
|
+
}));
|
|
359
|
+
}
|
|
351
360
|
else {
|
|
352
361
|
// Use `entryPoints` alone.
|
|
353
362
|
const entryPointPaths = {};
|
|
@@ -17,5 +17,8 @@ import { NormalizedApplicationBuildOptions } from './options';
|
|
|
17
17
|
* @param codeBundleCache An instance of the TypeScript source file cache.
|
|
18
18
|
* @returns An array of BundlerContext objects.
|
|
19
19
|
*/
|
|
20
|
-
export declare function setupBundlerContexts(options: NormalizedApplicationBuildOptions, target: string[], codeBundleCache: SourceFileCache, stylesheetBundler: ComponentStylesheetBundler):
|
|
20
|
+
export declare function setupBundlerContexts(options: NormalizedApplicationBuildOptions, target: string[], codeBundleCache: SourceFileCache, stylesheetBundler: ComponentStylesheetBundler, templateUpdates: Map<string, string> | undefined): {
|
|
21
|
+
typescriptContexts: BundlerContext[];
|
|
22
|
+
otherContexts: BundlerContext[];
|
|
23
|
+
};
|
|
21
24
|
export declare function createComponentStyleBundler(options: NormalizedApplicationBuildOptions, target: string[]): ComponentStylesheetBundler;
|
|
@@ -23,22 +23,29 @@ const utils_1 = require("../../tools/esbuild/utils");
|
|
|
23
23
|
* @param codeBundleCache An instance of the TypeScript source file cache.
|
|
24
24
|
* @returns An array of BundlerContext objects.
|
|
25
25
|
*/
|
|
26
|
-
function setupBundlerContexts(options, target, codeBundleCache, stylesheetBundler) {
|
|
26
|
+
function setupBundlerContexts(options, target, codeBundleCache, stylesheetBundler, templateUpdates) {
|
|
27
27
|
const { outputMode, serverEntryPoint, appShellOptions, prerenderOptions, ssrOptions, workspaceRoot, watch = false, } = options;
|
|
28
|
-
const
|
|
28
|
+
const typescriptContexts = [];
|
|
29
|
+
const otherContexts = [];
|
|
29
30
|
// Browser application code
|
|
30
|
-
|
|
31
|
+
typescriptContexts.push(new bundler_context_1.BundlerContext(workspaceRoot, watch, (0, application_code_bundle_1.createBrowserCodeBundleOptions)(options, target, codeBundleCache, stylesheetBundler, templateUpdates)));
|
|
31
32
|
// Browser polyfills code
|
|
32
33
|
const browserPolyfillBundleOptions = (0, application_code_bundle_1.createBrowserPolyfillBundleOptions)(options, target, codeBundleCache, stylesheetBundler);
|
|
33
34
|
if (browserPolyfillBundleOptions) {
|
|
34
|
-
|
|
35
|
+
const browserPolyfillContext = new bundler_context_1.BundlerContext(workspaceRoot, watch, browserPolyfillBundleOptions);
|
|
36
|
+
if (typeof browserPolyfillBundleOptions === 'function') {
|
|
37
|
+
otherContexts.push(browserPolyfillContext);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
typescriptContexts.push(browserPolyfillContext);
|
|
41
|
+
}
|
|
35
42
|
}
|
|
36
43
|
// Global Stylesheets
|
|
37
44
|
if (options.globalStyles.length > 0) {
|
|
38
45
|
for (const initial of [true, false]) {
|
|
39
46
|
const bundleOptions = (0, global_styles_1.createGlobalStylesBundleOptions)(options, target, initial);
|
|
40
47
|
if (bundleOptions) {
|
|
41
|
-
|
|
48
|
+
otherContexts.push(new bundler_context_1.BundlerContext(workspaceRoot, watch, bundleOptions, () => initial));
|
|
42
49
|
}
|
|
43
50
|
}
|
|
44
51
|
}
|
|
@@ -47,25 +54,25 @@ function setupBundlerContexts(options, target, codeBundleCache, stylesheetBundle
|
|
|
47
54
|
for (const initial of [true, false]) {
|
|
48
55
|
const bundleOptions = (0, global_scripts_1.createGlobalScriptsBundleOptions)(options, target, initial);
|
|
49
56
|
if (bundleOptions) {
|
|
50
|
-
|
|
57
|
+
otherContexts.push(new bundler_context_1.BundlerContext(workspaceRoot, watch, bundleOptions, () => initial));
|
|
51
58
|
}
|
|
52
59
|
}
|
|
53
60
|
}
|
|
54
61
|
// Skip server build when none of the features are enabled.
|
|
55
62
|
if (serverEntryPoint && (outputMode || prerenderOptions || appShellOptions || ssrOptions)) {
|
|
56
63
|
const nodeTargets = [...target, ...(0, utils_1.getSupportedNodeTargets)()];
|
|
57
|
-
|
|
64
|
+
typescriptContexts.push(new bundler_context_1.BundlerContext(workspaceRoot, watch, (0, application_code_bundle_1.createServerMainCodeBundleOptions)(options, nodeTargets, codeBundleCache, stylesheetBundler)));
|
|
58
65
|
if (outputMode && ssrOptions?.entry) {
|
|
59
66
|
// New behavior introduced: 'server.ts' is now bundled separately from 'main.server.ts'.
|
|
60
|
-
|
|
67
|
+
typescriptContexts.push(new bundler_context_1.BundlerContext(workspaceRoot, watch, (0, application_code_bundle_1.createSsrEntryCodeBundleOptions)(options, nodeTargets, codeBundleCache, stylesheetBundler)));
|
|
61
68
|
}
|
|
62
69
|
// Server polyfills code
|
|
63
|
-
const serverPolyfillBundleOptions = (0, application_code_bundle_1.createServerPolyfillBundleOptions)(options, nodeTargets, codeBundleCache);
|
|
70
|
+
const serverPolyfillBundleOptions = (0, application_code_bundle_1.createServerPolyfillBundleOptions)(options, nodeTargets, codeBundleCache.loadResultCache);
|
|
64
71
|
if (serverPolyfillBundleOptions) {
|
|
65
|
-
|
|
72
|
+
otherContexts.push(new bundler_context_1.BundlerContext(workspaceRoot, watch, serverPolyfillBundleOptions));
|
|
66
73
|
}
|
|
67
74
|
}
|
|
68
|
-
return
|
|
75
|
+
return { typescriptContexts, otherContexts };
|
|
69
76
|
}
|
|
70
77
|
function createComponentStyleBundler(options, target) {
|
|
71
78
|
const { workspaceRoot, optimizationOptions, sourcemapOptions, outputNames, externalDependencies, preserveSymlinks, stylePreprocessorOptions, inlineStyleLanguage, cacheOptions, tailwindConfiguration, postcssConfiguration, publicPath, } = options;
|
|
@@ -26,8 +26,8 @@ export declare function normalizeOptions(context: BuilderContext, projectName: s
|
|
|
26
26
|
open: boolean | undefined;
|
|
27
27
|
verbose: boolean | undefined;
|
|
28
28
|
watch: boolean | undefined;
|
|
29
|
-
liveReload: boolean
|
|
30
|
-
hmr: boolean
|
|
29
|
+
liveReload: boolean;
|
|
30
|
+
hmr: boolean;
|
|
31
31
|
headers: {
|
|
32
32
|
[key: string]: string;
|
|
33
33
|
} | undefined;
|
|
@@ -15,7 +15,8 @@ export interface Schema {
|
|
|
15
15
|
[key: string]: string;
|
|
16
16
|
};
|
|
17
17
|
/**
|
|
18
|
-
* Enable hot module replacement.
|
|
18
|
+
* Enable hot module replacement. Defaults to the value of 'liveReload'. Currently, only
|
|
19
|
+
* global and component stylesheets are supported.
|
|
19
20
|
*/
|
|
20
21
|
hmr?: boolean;
|
|
21
22
|
/**
|
|
@@ -67,8 +67,7 @@
|
|
|
67
67
|
},
|
|
68
68
|
"hmr": {
|
|
69
69
|
"type": "boolean",
|
|
70
|
-
"description": "Enable hot module replacement."
|
|
71
|
-
"default": false
|
|
70
|
+
"description": "Enable hot module replacement. Defaults to the value of 'liveReload'. Currently, only global and component stylesheets are supported."
|
|
72
71
|
},
|
|
73
72
|
"watch": {
|
|
74
73
|
"type": "boolean",
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import type { BuilderContext } from '@angular-devkit/architect';
|
|
9
9
|
import type { Plugin } from 'esbuild';
|
|
10
10
|
import type { Connect, DepOptimizationConfig, InlineConfig } from 'vite';
|
|
11
|
+
import type { ComponentStyleRecord } from '../../tools/vite/middlewares';
|
|
11
12
|
import { ServerSsrMode } from '../../tools/vite/plugins';
|
|
12
13
|
import { Result } from '../application/results';
|
|
13
14
|
import { type ApplicationBuilderInternalOptions, BuildOutputFileType, type ExternalResultMetadata, JavaScriptTransformer } from './internal';
|
|
@@ -32,6 +33,6 @@ export declare function serveWithVite(serverOptions: NormalizedDevServerOptions,
|
|
|
32
33
|
middleware?: Connect.NextHandleFunction[];
|
|
33
34
|
buildPlugins?: Plugin[];
|
|
34
35
|
}): AsyncIterableIterator<DevServerBuilderOutput>;
|
|
35
|
-
export declare function setupServer(serverOptions: NormalizedDevServerOptions, outputFiles: Map<string, OutputFileRecord>, assets: Map<string, string>, preserveSymlinks: boolean | undefined, externalMetadata: DevServerExternalResultMetadata, ssrMode: ServerSsrMode, prebundleTransformer: JavaScriptTransformer, target: string[], zoneless: boolean,
|
|
36
|
+
export declare function setupServer(serverOptions: NormalizedDevServerOptions, outputFiles: Map<string, OutputFileRecord>, assets: Map<string, string>, preserveSymlinks: boolean | undefined, externalMetadata: DevServerExternalResultMetadata, ssrMode: ServerSsrMode, prebundleTransformer: JavaScriptTransformer, target: string[], zoneless: boolean, componentStyles: Map<string, ComponentStyleRecord>, templateUpdates: Map<string, string>, prebundleLoaderExtensions: EsbuildLoaderOption | undefined, extensionMiddleware?: Connect.NextHandleFunction[], indexHtmlTransformer?: (content: string) => Promise<string>, thirdPartySourcemaps?: boolean): Promise<InlineConfig>;
|
|
36
37
|
type EsbuildLoaderOption = Exclude<DepOptimizationConfig['esbuildOptions'], undefined>['loader'];
|
|
37
38
|
export {};
|