@angular/build 19.1.0-next.0 → 19.1.0-next.2
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 +13 -11
- package/src/builders/application/execute-build.js +37 -4
- package/src/builders/application/execute-post-bundle.d.ts +3 -1
- package/src/builders/application/execute-post-bundle.js +6 -4
- package/src/builders/application/i18n.d.ts +3 -1
- package/src/builders/application/i18n.js +15 -13
- package/src/builders/application/options.js +7 -5
- package/src/builders/dev-server/vite-server.d.ts +2 -2
- package/src/builders/dev-server/vite-server.js +31 -47
- package/src/builders/extract-i18n/options.js +1 -1
- package/src/tools/angular/angular-host.d.ts +1 -1
- package/src/tools/angular/angular-host.js +4 -4
- package/src/tools/angular/compilation/aot-compilation.d.ts +2 -0
- package/src/tools/angular/compilation/aot-compilation.js +30 -9
- package/src/tools/angular/compilation/factory.d.ts +2 -1
- package/src/tools/angular/compilation/factory.js +5 -4
- package/src/tools/angular/compilation/jit-compilation.d.ts +2 -0
- package/src/tools/angular/compilation/jit-compilation.js +12 -2
- package/src/tools/angular/compilation/parallel-compilation.d.ts +3 -2
- package/src/tools/angular/compilation/parallel-compilation.js +4 -1
- package/src/tools/angular/compilation/parallel-worker.d.ts +1 -0
- package/src/tools/angular/compilation/parallel-worker.js +3 -1
- package/src/tools/angular/transformers/lazy-routes-transformer.d.ts +39 -0
- package/src/tools/angular/transformers/lazy-routes-transformer.js +163 -0
- package/src/tools/esbuild/angular/compiler-plugin.d.ts +1 -0
- package/src/tools/esbuild/angular/compiler-plugin.js +1 -1
- package/src/tools/esbuild/application-code-bundle.js +26 -20
- package/src/tools/esbuild/compiler-plugin-options.js +1 -0
- package/src/tools/vite/plugins/angular-memory-plugin.d.ts +1 -0
- package/src/tools/vite/plugins/angular-memory-plugin.js +25 -2
- package/src/tools/vite/utils.d.ts +14 -0
- package/src/tools/vite/utils.js +37 -0
- package/src/utils/environment-options.js +1 -1
- package/src/utils/i18n-options.d.ts +4 -1
- package/src/utils/i18n-options.js +50 -7
- package/src/utils/index-file/auto-csp.js +5 -5
- package/src/utils/normalize-cache.js +1 -1
- package/src/utils/server-rendering/esm-in-memory-loader/loader-hooks.js +9 -1
- package/src/utils/server-rendering/manifest.d.ts +5 -1
- package/src/utils/server-rendering/manifest.js +60 -11
- package/src/utils/server-rendering/prerender.js +1 -1
- package/tsconfig-build.json +6 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular/build",
|
|
3
|
-
"version": "19.1.0-next.
|
|
3
|
+
"version": "19.1.0-next.2",
|
|
4
4
|
"description": "Official build system for Angular",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Angular CLI",
|
|
@@ -23,29 +23,29 @@
|
|
|
23
23
|
"builders": "builders.json",
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@ampproject/remapping": "2.3.0",
|
|
26
|
-
"@angular-devkit/architect": "0.1901.0-next.
|
|
26
|
+
"@angular-devkit/architect": "0.1901.0-next.2",
|
|
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",
|
|
30
30
|
"@babel/plugin-syntax-import-attributes": "7.26.0",
|
|
31
|
-
"@inquirer/confirm": "5.0
|
|
31
|
+
"@inquirer/confirm": "5.1.0",
|
|
32
32
|
"@vitejs/plugin-basic-ssl": "1.2.0",
|
|
33
|
-
"beasties": "0.
|
|
33
|
+
"beasties": "0.2.0",
|
|
34
34
|
"browserslist": "^4.23.0",
|
|
35
35
|
"esbuild": "0.24.0",
|
|
36
36
|
"fast-glob": "3.3.2",
|
|
37
|
-
"https-proxy-agent": "7.0.
|
|
37
|
+
"https-proxy-agent": "7.0.6",
|
|
38
38
|
"istanbul-lib-instrument": "6.0.3",
|
|
39
39
|
"listr2": "8.2.5",
|
|
40
|
-
"magic-string": "0.30.
|
|
40
|
+
"magic-string": "0.30.15",
|
|
41
41
|
"mrmime": "2.0.0",
|
|
42
42
|
"parse5-html-rewriting-stream": "7.0.0",
|
|
43
43
|
"picomatch": "4.0.2",
|
|
44
44
|
"piscina": "4.8.0",
|
|
45
|
-
"rollup": "4.28.
|
|
46
|
-
"sass": "1.
|
|
45
|
+
"rollup": "4.28.1",
|
|
46
|
+
"sass": "1.83.0",
|
|
47
47
|
"semver": "7.6.3",
|
|
48
|
-
"vite": "6.0.
|
|
48
|
+
"vite": "6.0.3",
|
|
49
49
|
"watchpack": "2.4.2"
|
|
50
50
|
},
|
|
51
51
|
"optionalDependencies": {
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"@angular/localize": "^19.0.0 || ^19.1.0-next.0",
|
|
58
58
|
"@angular/platform-server": "^19.0.0 || ^19.1.0-next.0",
|
|
59
59
|
"@angular/service-worker": "^19.0.0 || ^19.1.0-next.0",
|
|
60
|
-
"@angular/ssr": "^19.1.0-next.
|
|
60
|
+
"@angular/ssr": "^19.1.0-next.2",
|
|
61
61
|
"less": "^4.2.0",
|
|
62
62
|
"postcss": "^8.4.0",
|
|
63
63
|
"tailwindcss": "^2.0.0 || ^3.0.0",
|
|
@@ -86,7 +86,6 @@
|
|
|
86
86
|
"optional": true
|
|
87
87
|
}
|
|
88
88
|
},
|
|
89
|
-
"packageManager": "yarn@4.5.0",
|
|
90
89
|
"repository": {
|
|
91
90
|
"type": "git",
|
|
92
91
|
"url": "https://github.com/angular/angular-cli.git"
|
|
@@ -109,5 +108,8 @@
|
|
|
109
108
|
"puppeteer": {
|
|
110
109
|
"built": true
|
|
111
110
|
}
|
|
111
|
+
},
|
|
112
|
+
"pnpm": {
|
|
113
|
+
"onlyBuiltDependencies": []
|
|
112
114
|
}
|
|
113
115
|
}
|
|
@@ -6,6 +6,39 @@
|
|
|
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 __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 () {
|
|
26
|
+
var ownKeys = function(o) {
|
|
27
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
28
|
+
var ar = [];
|
|
29
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
30
|
+
return ar;
|
|
31
|
+
};
|
|
32
|
+
return ownKeys(o);
|
|
33
|
+
};
|
|
34
|
+
return function (mod) {
|
|
35
|
+
if (mod && mod.__esModule) return mod;
|
|
36
|
+
var result = {};
|
|
37
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
38
|
+
__setModuleDefault(result, mod);
|
|
39
|
+
return result;
|
|
40
|
+
};
|
|
41
|
+
})();
|
|
9
42
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
43
|
exports.executeBuild = executeBuild;
|
|
11
44
|
const source_file_cache_1 = require("../../tools/esbuild/angular/source-file-cache");
|
|
@@ -21,7 +54,6 @@ const environment_options_1 = require("../../utils/environment-options");
|
|
|
21
54
|
const resolve_assets_1 = require("../../utils/resolve-assets");
|
|
22
55
|
const manifest_1 = require("../../utils/server-rendering/manifest");
|
|
23
56
|
const supported_browsers_1 = require("../../utils/supported-browsers");
|
|
24
|
-
const chunk_optimizer_1 = require("./chunk-optimizer");
|
|
25
57
|
const execute_post_bundle_1 = require("./execute-post-bundle");
|
|
26
58
|
const i18n_1 = require("./i18n");
|
|
27
59
|
const setup_bundling_1 = require("./setup-bundling");
|
|
@@ -85,7 +117,8 @@ async function executeBuild(options, context, rebuildState) {
|
|
|
85
117
|
bundlingResult = bundler_context_1.BundlerContext.mergeResults([bundlingResult, ...componentResults]);
|
|
86
118
|
}
|
|
87
119
|
if (options.optimizationOptions.scripts && environment_options_1.shouldOptimizeChunks) {
|
|
88
|
-
|
|
120
|
+
const { optimizeChunks } = await Promise.resolve().then(() => __importStar(require('./chunk-optimizer')));
|
|
121
|
+
bundlingResult = await (0, profiling_1.profileAsync)('OPTIMIZE_CHUNKS', () => optimizeChunks(bundlingResult, options.sourcemapOptions.scripts ? !options.sourcemapOptions.hidden || 'hidden' : false));
|
|
89
122
|
}
|
|
90
123
|
const executionResult = new bundler_execution_result_1.ExecutionResult(bundlerContexts, componentStyleBundler, codeBundleCache, templateUpdates);
|
|
91
124
|
executionResult.addWarnings(bundlingResult.warnings);
|
|
@@ -161,13 +194,13 @@ async function executeBuild(options, context, rebuildState) {
|
|
|
161
194
|
}
|
|
162
195
|
// Perform i18n translation inlining if enabled
|
|
163
196
|
if (i18nOptions.shouldInline) {
|
|
164
|
-
const result = await (0, i18n_1.inlineI18n)(options, executionResult, initialFiles);
|
|
197
|
+
const result = await (0, i18n_1.inlineI18n)(metafile, options, executionResult, initialFiles);
|
|
165
198
|
executionResult.addErrors(result.errors);
|
|
166
199
|
executionResult.addWarnings(result.warnings);
|
|
167
200
|
executionResult.addPrerenderedRoutes(result.prerenderedRoutes);
|
|
168
201
|
}
|
|
169
202
|
else {
|
|
170
|
-
const result = await (0, execute_post_bundle_1.executePostBundleSteps)(options, executionResult.outputFiles, executionResult.assetFiles, initialFiles,
|
|
203
|
+
const result = await (0, execute_post_bundle_1.executePostBundleSteps)(metafile, options, executionResult.outputFiles, executionResult.assetFiles, initialFiles,
|
|
171
204
|
// Set lang attribute to the defined source locale if present
|
|
172
205
|
i18nOptions.hasDefinedSourceLocale ? i18nOptions.sourceLocale : undefined);
|
|
173
206
|
executionResult.addErrors(result.errors);
|
|
@@ -5,18 +5,20 @@
|
|
|
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.dev/license
|
|
7
7
|
*/
|
|
8
|
+
import type { Metafile } from 'esbuild';
|
|
8
9
|
import { BuildOutputFile, InitialFileRecord } from '../../tools/esbuild/bundler-context';
|
|
9
10
|
import { BuildOutputAsset, PrerenderedRoutesRecord } from '../../tools/esbuild/bundler-execution-result';
|
|
10
11
|
import { NormalizedApplicationBuildOptions } from './options';
|
|
11
12
|
/**
|
|
12
13
|
* Run additional builds steps including SSG, AppShell, Index HTML file and Service worker generation.
|
|
14
|
+
* @param metafile An esbuild metafile object.
|
|
13
15
|
* @param options The normalized application builder options used to create the build.
|
|
14
16
|
* @param outputFiles The output files of an executed build.
|
|
15
17
|
* @param assetFiles The assets of an executed build.
|
|
16
18
|
* @param initialFiles A map containing initial file information for the executed build.
|
|
17
19
|
* @param locale A language locale to insert in the index.html.
|
|
18
20
|
*/
|
|
19
|
-
export declare function executePostBundleSteps(options: NormalizedApplicationBuildOptions, outputFiles: BuildOutputFile[], assetFiles: BuildOutputAsset[], initialFiles: Map<string, InitialFileRecord>, locale: string | undefined): Promise<{
|
|
21
|
+
export declare function executePostBundleSteps(metafile: Metafile, options: NormalizedApplicationBuildOptions, outputFiles: BuildOutputFile[], assetFiles: BuildOutputAsset[], initialFiles: Map<string, InitialFileRecord>, locale: string | undefined): Promise<{
|
|
20
22
|
errors: string[];
|
|
21
23
|
warnings: string[];
|
|
22
24
|
additionalOutputFiles: BuildOutputFile[];
|
|
@@ -24,6 +24,7 @@ const options_1 = require("./options");
|
|
|
24
24
|
const schema_1 = require("./schema");
|
|
25
25
|
/**
|
|
26
26
|
* Run additional builds steps including SSG, AppShell, Index HTML file and Service worker generation.
|
|
27
|
+
* @param metafile An esbuild metafile object.
|
|
27
28
|
* @param options The normalized application builder options used to create the build.
|
|
28
29
|
* @param outputFiles The output files of an executed build.
|
|
29
30
|
* @param assetFiles The assets of an executed build.
|
|
@@ -31,13 +32,13 @@ const schema_1 = require("./schema");
|
|
|
31
32
|
* @param locale A language locale to insert in the index.html.
|
|
32
33
|
*/
|
|
33
34
|
// eslint-disable-next-line max-lines-per-function
|
|
34
|
-
async function executePostBundleSteps(options, outputFiles, assetFiles, initialFiles, locale) {
|
|
35
|
+
async function executePostBundleSteps(metafile, options, outputFiles, assetFiles, initialFiles, locale) {
|
|
35
36
|
const additionalAssets = [];
|
|
36
37
|
const additionalOutputFiles = [];
|
|
37
38
|
const allErrors = [];
|
|
38
39
|
const allWarnings = [];
|
|
39
40
|
const prerenderedRoutes = {};
|
|
40
|
-
const { baseHref = '/', serviceWorker, i18nOptions, indexHtmlOptions, optimizationOptions, sourcemapOptions, outputMode, serverEntryPoint, prerenderOptions, appShellOptions, workspaceRoot, partialSSRBuild, } = options;
|
|
41
|
+
const { baseHref = '/', serviceWorker, i18nOptions, indexHtmlOptions, optimizationOptions, sourcemapOptions, outputMode, serverEntryPoint, prerenderOptions, appShellOptions, publicPath, workspaceRoot, partialSSRBuild, } = options;
|
|
41
42
|
// Index HTML content without CSS inlining to be used for server rendering (AppShell, SSG and SSR).
|
|
42
43
|
// NOTE: Critical CSS inlining is deliberately omitted here, as it will be handled during server rendering.
|
|
43
44
|
// Additionally, when using prerendering or AppShell, the index HTML file may be regenerated.
|
|
@@ -55,8 +56,9 @@ async function executePostBundleSteps(options, outputFiles, assetFiles, initialF
|
|
|
55
56
|
}
|
|
56
57
|
}
|
|
57
58
|
// Create server manifest
|
|
59
|
+
const initialFilesPaths = new Set(initialFiles.keys());
|
|
58
60
|
if (serverEntryPoint) {
|
|
59
|
-
const { manifestContent, serverAssetsChunks } = (0, manifest_1.generateAngularServerAppManifest)(additionalHtmlOutputFiles, outputFiles, optimizationOptions.styles.inlineCritical ?? false, undefined, locale, baseHref);
|
|
61
|
+
const { manifestContent, serverAssetsChunks } = (0, manifest_1.generateAngularServerAppManifest)(additionalHtmlOutputFiles, outputFiles, optimizationOptions.styles.inlineCritical ?? false, undefined, locale, baseHref, initialFilesPaths, metafile, publicPath);
|
|
60
62
|
additionalOutputFiles.push(...serverAssetsChunks, (0, utils_1.createOutputFile)(manifest_1.SERVER_APP_MANIFEST_FILENAME, manifestContent, bundler_context_1.BuildOutputFileType.ServerApplication));
|
|
61
63
|
}
|
|
62
64
|
// Pre-render (SSG) and App-shell
|
|
@@ -95,7 +97,7 @@ async function executePostBundleSteps(options, outputFiles, assetFiles, initialF
|
|
|
95
97
|
// Regenerate the manifest to append route tree. This is only needed if SSR is enabled.
|
|
96
98
|
const manifest = additionalOutputFiles.find((f) => f.path === manifest_1.SERVER_APP_MANIFEST_FILENAME);
|
|
97
99
|
(0, node_assert_1.default)(manifest, `${manifest_1.SERVER_APP_MANIFEST_FILENAME} was not found in output files.`);
|
|
98
|
-
const { manifestContent, serverAssetsChunks } = (0, manifest_1.generateAngularServerAppManifest)(additionalHtmlOutputFiles, outputFiles, optimizationOptions.styles.inlineCritical ?? false, serializableRouteTreeNodeForManifest, locale, baseHref);
|
|
100
|
+
const { manifestContent, serverAssetsChunks } = (0, manifest_1.generateAngularServerAppManifest)(additionalHtmlOutputFiles, outputFiles, optimizationOptions.styles.inlineCritical ?? false, serializableRouteTreeNodeForManifest, locale, baseHref, initialFilesPaths, metafile, publicPath);
|
|
99
101
|
for (const chunk of serverAssetsChunks) {
|
|
100
102
|
const idx = additionalOutputFiles.findIndex(({ path }) => path === chunk.path);
|
|
101
103
|
if (idx === -1) {
|
|
@@ -6,17 +6,19 @@
|
|
|
6
6
|
* found in the LICENSE file at https://angular.dev/license
|
|
7
7
|
*/
|
|
8
8
|
import { BuilderContext } from '@angular-devkit/architect';
|
|
9
|
+
import type { Metafile } from 'esbuild';
|
|
9
10
|
import { InitialFileRecord } from '../../tools/esbuild/bundler-context';
|
|
10
11
|
import { ExecutionResult, PrerenderedRoutesRecord } from '../../tools/esbuild/bundler-execution-result';
|
|
11
12
|
import { NormalizedApplicationBuildOptions } from './options';
|
|
12
13
|
/**
|
|
13
14
|
* Inlines all active locales as specified by the application build options into all
|
|
14
15
|
* application JavaScript files created during the build.
|
|
16
|
+
* @param metafile An esbuild metafile object.
|
|
15
17
|
* @param options The normalized application builder options used to create the build.
|
|
16
18
|
* @param executionResult The result of an executed build.
|
|
17
19
|
* @param initialFiles A map containing initial file information for the executed build.
|
|
18
20
|
*/
|
|
19
|
-
export declare function inlineI18n(options: NormalizedApplicationBuildOptions, executionResult: ExecutionResult, initialFiles: Map<string, InitialFileRecord>): Promise<{
|
|
21
|
+
export declare function inlineI18n(metafile: Metafile, options: NormalizedApplicationBuildOptions, executionResult: ExecutionResult, initialFiles: Map<string, InitialFileRecord>): Promise<{
|
|
20
22
|
errors: string[];
|
|
21
23
|
warnings: string[];
|
|
22
24
|
prerenderedRoutes: PrerenderedRoutesRecord;
|
|
@@ -20,16 +20,18 @@ const options_1 = require("./options");
|
|
|
20
20
|
/**
|
|
21
21
|
* Inlines all active locales as specified by the application build options into all
|
|
22
22
|
* application JavaScript files created during the build.
|
|
23
|
+
* @param metafile An esbuild metafile object.
|
|
23
24
|
* @param options The normalized application builder options used to create the build.
|
|
24
25
|
* @param executionResult The result of an executed build.
|
|
25
26
|
* @param initialFiles A map containing initial file information for the executed build.
|
|
26
27
|
*/
|
|
27
|
-
async function inlineI18n(options, executionResult, initialFiles) {
|
|
28
|
+
async function inlineI18n(metafile, options, executionResult, initialFiles) {
|
|
29
|
+
const { i18nOptions, optimizationOptions, baseHref } = options;
|
|
28
30
|
// Create the multi-threaded inliner with common options and the files generated from the build.
|
|
29
31
|
const inliner = new i18n_inliner_1.I18nInliner({
|
|
30
|
-
missingTranslation:
|
|
32
|
+
missingTranslation: i18nOptions.missingTranslationBehavior ?? 'warning',
|
|
31
33
|
outputFiles: executionResult.outputFiles,
|
|
32
|
-
shouldOptimize:
|
|
34
|
+
shouldOptimize: optimizationOptions.scripts,
|
|
33
35
|
}, environment_options_1.maxWorkers);
|
|
34
36
|
const inlineResult = {
|
|
35
37
|
errors: [],
|
|
@@ -40,29 +42,29 @@ async function inlineI18n(options, executionResult, initialFiles) {
|
|
|
40
42
|
const updatedOutputFiles = [];
|
|
41
43
|
const updatedAssetFiles = [];
|
|
42
44
|
try {
|
|
43
|
-
for (const locale of
|
|
45
|
+
for (const locale of i18nOptions.inlineLocales) {
|
|
44
46
|
// A locale specific set of files is returned from the inliner.
|
|
45
|
-
const localeInlineResult = await inliner.inlineForLocale(locale,
|
|
47
|
+
const localeInlineResult = await inliner.inlineForLocale(locale, i18nOptions.locales[locale].translation);
|
|
46
48
|
const localeOutputFiles = localeInlineResult.outputFiles;
|
|
47
49
|
inlineResult.errors.push(...localeInlineResult.errors);
|
|
48
50
|
inlineResult.warnings.push(...localeInlineResult.warnings);
|
|
49
|
-
const
|
|
50
|
-
const { errors, warnings, additionalAssets, additionalOutputFiles, prerenderedRoutes: generatedRoutes, } = await (0, execute_post_bundle_1.executePostBundleSteps)({
|
|
51
|
+
const { errors, warnings, additionalAssets, additionalOutputFiles, prerenderedRoutes: generatedRoutes, } = await (0, execute_post_bundle_1.executePostBundleSteps)(metafile, {
|
|
51
52
|
...options,
|
|
52
|
-
baseHref,
|
|
53
|
+
baseHref: (0, options_1.getLocaleBaseHref)(baseHref, i18nOptions, locale) ?? baseHref,
|
|
53
54
|
}, localeOutputFiles, executionResult.assetFiles, initialFiles, locale);
|
|
54
55
|
localeOutputFiles.push(...additionalOutputFiles);
|
|
55
56
|
inlineResult.errors.push(...errors);
|
|
56
57
|
inlineResult.warnings.push(...warnings);
|
|
57
|
-
// Update directory with locale base
|
|
58
|
-
|
|
58
|
+
// Update directory with locale base or subPath
|
|
59
|
+
const subPath = i18nOptions.locales[locale].subPath;
|
|
60
|
+
if (i18nOptions.flatOutput !== true) {
|
|
59
61
|
localeOutputFiles.forEach((file) => {
|
|
60
|
-
file.path = (0, node_path_1.join)(
|
|
62
|
+
file.path = (0, node_path_1.join)(subPath, file.path);
|
|
61
63
|
});
|
|
62
64
|
for (const assetFile of [...executionResult.assetFiles, ...additionalAssets]) {
|
|
63
65
|
updatedAssetFiles.push({
|
|
64
66
|
source: assetFile.source,
|
|
65
|
-
destination: (0, node_path_1.join)(
|
|
67
|
+
destination: (0, node_path_1.join)(subPath, assetFile.destination),
|
|
66
68
|
});
|
|
67
69
|
}
|
|
68
70
|
}
|
|
@@ -84,7 +86,7 @@ async function inlineI18n(options, executionResult, initialFiles) {
|
|
|
84
86
|
...updatedOutputFiles,
|
|
85
87
|
];
|
|
86
88
|
// Assets are only changed if not using the flat output option
|
|
87
|
-
if (
|
|
89
|
+
if (!i18nOptions.flatOutput) {
|
|
88
90
|
executionResult.assetFiles = updatedAssetFiles;
|
|
89
91
|
}
|
|
90
92
|
return inlineResult;
|
|
@@ -63,7 +63,7 @@ async function normalizeOptions(context, projectName, options, extensions) {
|
|
|
63
63
|
// Gather persistent caching option and provide a project specific cache location
|
|
64
64
|
const cacheOptions = (0, normalize_cache_1.normalizeCacheOptions)(projectMetadata, workspaceRoot);
|
|
65
65
|
cacheOptions.path = node_path_1.default.join(cacheOptions.path, projectName);
|
|
66
|
-
const i18nOptions = (0, i18n_options_1.createI18nOptions)(projectMetadata, options.localize);
|
|
66
|
+
const i18nOptions = (0, i18n_options_1.createI18nOptions)(projectMetadata, options.localize, context.logger);
|
|
67
67
|
i18nOptions.duplicateTranslationBehavior = options.i18nDuplicateTranslation;
|
|
68
68
|
i18nOptions.missingTranslationBehavior = options.i18nMissingTranslation;
|
|
69
69
|
if (options.forceI18nFlatOutput) {
|
|
@@ -427,12 +427,14 @@ function normalizeGlobalEntries(rawEntries, defaultName) {
|
|
|
427
427
|
}
|
|
428
428
|
return [...bundles.values()];
|
|
429
429
|
}
|
|
430
|
-
function getLocaleBaseHref(baseHref, i18n, locale) {
|
|
430
|
+
function getLocaleBaseHref(baseHref = '', i18n, locale) {
|
|
431
431
|
if (i18n.flatOutput) {
|
|
432
432
|
return undefined;
|
|
433
433
|
}
|
|
434
|
-
|
|
435
|
-
|
|
434
|
+
const localeData = i18n.locales[locale];
|
|
435
|
+
if (!localeData) {
|
|
436
|
+
return undefined;
|
|
436
437
|
}
|
|
437
|
-
|
|
438
|
+
const baseHrefSuffix = localeData.baseHref ?? localeData.subPath + '/';
|
|
439
|
+
return baseHrefSuffix !== '' ? (0, url_1.urlJoin)(baseHref, baseHrefSuffix) : undefined;
|
|
438
440
|
}
|
|
@@ -7,9 +7,10 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import type { BuilderContext } from '@angular-devkit/architect';
|
|
9
9
|
import type { Plugin } from 'esbuild';
|
|
10
|
-
import type { Connect,
|
|
10
|
+
import type { Connect, InlineConfig } from 'vite';
|
|
11
11
|
import type { ComponentStyleRecord } from '../../tools/vite/middlewares';
|
|
12
12
|
import { ServerSsrMode } from '../../tools/vite/plugins';
|
|
13
|
+
import { EsbuildLoaderOption } from '../../tools/vite/utils';
|
|
13
14
|
import { Result } from '../application/results';
|
|
14
15
|
import { type ApplicationBuilderInternalOptions, BuildOutputFileType, type ExternalResultMetadata, JavaScriptTransformer } from './internal';
|
|
15
16
|
import type { NormalizedDevServerOptions } from './options';
|
|
@@ -34,5 +35,4 @@ export declare function serveWithVite(serverOptions: NormalizedDevServerOptions,
|
|
|
34
35
|
buildPlugins?: Plugin[];
|
|
35
36
|
}): AsyncIterableIterator<DevServerBuilderOutput>;
|
|
36
37
|
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>;
|
|
37
|
-
type EsbuildLoaderOption = Exclude<DepOptimizationConfig['esbuildOptions'], undefined>['loader'];
|
|
38
38
|
export {};
|
|
@@ -50,7 +50,8 @@ const promises_1 = require("node:fs/promises");
|
|
|
50
50
|
const node_module_1 = require("node:module");
|
|
51
51
|
const node_path_1 = require("node:path");
|
|
52
52
|
const plugins_1 = require("../../tools/vite/plugins");
|
|
53
|
-
const utils_1 = require("../../utils");
|
|
53
|
+
const utils_1 = require("../../tools/vite/utils");
|
|
54
|
+
const utils_2 = require("../../utils");
|
|
54
55
|
const environment_options_1 = require("../../utils/environment-options");
|
|
55
56
|
const load_esm_1 = require("../../utils/load-esm");
|
|
56
57
|
const results_1 = require("../application/results");
|
|
@@ -97,19 +98,18 @@ async function* serveWithVite(serverOptions, builderName, builderAction, context
|
|
|
97
98
|
// When localization is enabled with a single locale, force a flat path to maintain behavior with the existing Webpack-based dev server.
|
|
98
99
|
browserOptions.forceI18nFlatOutput = true;
|
|
99
100
|
}
|
|
100
|
-
const { vendor: thirdPartySourcemaps, scripts: scriptsSourcemaps } = (0,
|
|
101
|
+
const { vendor: thirdPartySourcemaps, scripts: scriptsSourcemaps } = (0, utils_2.normalizeSourceMaps)(browserOptions.sourceMap ?? false);
|
|
101
102
|
if (scriptsSourcemaps && browserOptions.server) {
|
|
102
103
|
// https://nodejs.org/api/process.html#processsetsourcemapsenabledval
|
|
103
104
|
process.setSourceMapsEnabled(true);
|
|
104
105
|
}
|
|
105
|
-
// Enable to support component style hot reloading (`NG_HMR_CSTYLES=0` can be used to disable selectively)
|
|
106
|
+
// Enable to support link-based component style hot reloading (`NG_HMR_CSTYLES=0` can be used to disable selectively)
|
|
106
107
|
browserOptions.externalRuntimeStyles =
|
|
107
108
|
serverOptions.liveReload && serverOptions.hmr && environment_options_1.useComponentStyleHmr;
|
|
108
|
-
// Enable to support component template hot replacement (`NG_HMR_TEMPLATE=
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
109
|
+
// Enable to support component template hot replacement (`NG_HMR_TEMPLATE=0` can be used to disable selectively)
|
|
110
|
+
// This will also replace file-based/inline styles as code if external runtime styles are not enabled.
|
|
111
|
+
browserOptions.templateUpdates =
|
|
112
|
+
serverOptions.liveReload && serverOptions.hmr && environment_options_1.useComponentTemplateHmr;
|
|
113
113
|
// Setup the prebundling transformer that will be shared across Vite prebundling requests
|
|
114
114
|
const prebundleTransformer = new internal_1.JavaScriptTransformer(
|
|
115
115
|
// Always enable JIT linking to support applications built with and without AOT.
|
|
@@ -184,6 +184,10 @@ async function* serveWithVite(serverOptions, builderName, builderAction, context
|
|
|
184
184
|
assetFiles.set('/' + normalizePath(outputPath), normalizePath(file.inputPath));
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
|
+
// Invalidate SSR module graph to ensure that only new rebuild is used and not stale component updates
|
|
188
|
+
if (server && browserOptions.ssr && templateUpdates.size > 0) {
|
|
189
|
+
server.moduleGraph.invalidateAll();
|
|
190
|
+
}
|
|
187
191
|
// Clear stale template updates on code rebuilds
|
|
188
192
|
templateUpdates.clear();
|
|
189
193
|
// Analyze result files for changes
|
|
@@ -196,6 +200,13 @@ async function* serveWithVite(serverOptions, builderName, builderAction, context
|
|
|
196
200
|
case results_1.ResultKind.ComponentUpdate:
|
|
197
201
|
(0, node_assert_1.default)(serverOptions.hmr, 'Component updates are only supported with HMR enabled.');
|
|
198
202
|
(0, node_assert_1.default)(server, 'Builder must provide an initial full build before component update results.');
|
|
203
|
+
// Invalidate SSR module graph to ensure that new component updates are used
|
|
204
|
+
// TODO: Use fine-grained invalidation of only the component update modules
|
|
205
|
+
if (browserOptions.ssr) {
|
|
206
|
+
server.moduleGraph.invalidateAll();
|
|
207
|
+
const { ɵresetCompiledComponents } = (await server.ssrLoadModule('/main.server.mjs'));
|
|
208
|
+
ɵresetCompiledComponents();
|
|
209
|
+
}
|
|
199
210
|
for (const componentUpdate of result.updates) {
|
|
200
211
|
if (componentUpdate.type === 'template') {
|
|
201
212
|
templateUpdates.set(componentUpdate.id, componentUpdate.content);
|
|
@@ -459,7 +470,7 @@ function analyzeResultFiles(normalizePath, htmlIndexPath, resultFiles, generated
|
|
|
459
470
|
}
|
|
460
471
|
}
|
|
461
472
|
async function setupServer(serverOptions, outputFiles, assets, preserveSymlinks, externalMetadata, ssrMode, prebundleTransformer, target, zoneless, componentStyles, templateUpdates, prebundleLoaderExtensions, extensionMiddleware, indexHtmlTransformer, thirdPartySourcemaps = false) {
|
|
462
|
-
const proxy = await (0,
|
|
473
|
+
const proxy = await (0, utils_2.loadProxyConfiguration)(serverOptions.workspaceRoot, serverOptions.proxyConfig);
|
|
463
474
|
// dynamically import Vite for ESM compatibility
|
|
464
475
|
const { normalizePath } = await (0, load_esm_1.loadEsmModule)('vite');
|
|
465
476
|
// Path will not exist on disk and only used to provide separate path for Vite requests
|
|
@@ -503,7 +514,14 @@ async function setupServer(serverOptions, outputFiles, assets, preserveSymlinks,
|
|
|
503
514
|
headers: serverOptions.headers,
|
|
504
515
|
// Disable the websocket if live reload is disabled (false/undefined are the only valid values)
|
|
505
516
|
ws: serverOptions.liveReload === false && serverOptions.hmr === false ? false : undefined,
|
|
506
|
-
|
|
517
|
+
// When server-side rendering (SSR) is enabled togather with SSL and Express is being used,
|
|
518
|
+
// we must configure Vite to use HTTP/1.1.
|
|
519
|
+
// This is necessary because Express does not support HTTP/2.
|
|
520
|
+
// We achieve this by defining an empty proxy.
|
|
521
|
+
// See: https://github.com/vitejs/vite/blob/c4b532cc900bf988073583511f57bd581755d5e3/packages/vite/src/node/http.ts#L106
|
|
522
|
+
proxy: serverOptions.ssl && ssrMode === plugins_1.ServerSsrMode.ExternalSsrMiddleware
|
|
523
|
+
? (proxy ?? {})
|
|
524
|
+
: proxy,
|
|
507
525
|
cors: {
|
|
508
526
|
// Allow preflight requests to be proxied.
|
|
509
527
|
preflightContinue: true,
|
|
@@ -526,7 +544,7 @@ async function setupServer(serverOptions, outputFiles, assets, preserveSymlinks,
|
|
|
526
544
|
noExternal: /.*/,
|
|
527
545
|
// Exclude any Node.js built in module and provided dependencies (currently build defined externals)
|
|
528
546
|
external: externalMetadata.explicitServer,
|
|
529
|
-
optimizeDeps: getDepOptimizationConfig({
|
|
547
|
+
optimizeDeps: (0, utils_1.getDepOptimizationConfig)({
|
|
530
548
|
// Only enable with caching since it causes prebundle dependencies to be cached
|
|
531
549
|
disabled: serverOptions.prebundle === false,
|
|
532
550
|
// Exclude any explicitly defined dependencies (currently build defined externals and node.js built-ins)
|
|
@@ -557,12 +575,13 @@ async function setupServer(serverOptions, outputFiles, assets, preserveSymlinks,
|
|
|
557
575
|
await (0, plugins_1.createAngularMemoryPlugin)({
|
|
558
576
|
virtualProjectRoot,
|
|
559
577
|
outputFiles,
|
|
578
|
+
templateUpdates,
|
|
560
579
|
external: externalMetadata.explicitBrowser,
|
|
561
580
|
skipViteClient: serverOptions.liveReload === false && serverOptions.hmr === false,
|
|
562
581
|
}),
|
|
563
582
|
],
|
|
564
583
|
// Browser only optimizeDeps. (This does not run for SSR dependencies).
|
|
565
|
-
optimizeDeps: getDepOptimizationConfig({
|
|
584
|
+
optimizeDeps: (0, utils_1.getDepOptimizationConfig)({
|
|
566
585
|
// Only enable with caching since it causes prebundle dependencies to be cached
|
|
567
586
|
disabled: serverOptions.prebundle === false,
|
|
568
587
|
// Exclude any explicitly defined dependencies (currently build defined externals)
|
|
@@ -595,41 +614,6 @@ async function setupServer(serverOptions, outputFiles, assets, preserveSymlinks,
|
|
|
595
614
|
}
|
|
596
615
|
return configuration;
|
|
597
616
|
}
|
|
598
|
-
function getDepOptimizationConfig({ disabled, exclude, include, target, zoneless, prebundleTransformer, ssr, loader, thirdPartySourcemaps, }) {
|
|
599
|
-
const plugins = [
|
|
600
|
-
{
|
|
601
|
-
name: `angular-vite-optimize-deps${ssr ? '-ssr' : ''}${thirdPartySourcemaps ? '-vendor-sourcemap' : ''}`,
|
|
602
|
-
setup(build) {
|
|
603
|
-
build.onLoad({ filter: /\.[cm]?js$/ }, async (args) => {
|
|
604
|
-
return {
|
|
605
|
-
contents: await prebundleTransformer.transformFile(args.path),
|
|
606
|
-
loader: 'js',
|
|
607
|
-
};
|
|
608
|
-
});
|
|
609
|
-
},
|
|
610
|
-
},
|
|
611
|
-
];
|
|
612
|
-
return {
|
|
613
|
-
// Exclude any explicitly defined dependencies (currently build defined externals)
|
|
614
|
-
exclude,
|
|
615
|
-
// NB: to disable the deps optimizer, set optimizeDeps.noDiscovery to true and optimizeDeps.include as undefined.
|
|
616
|
-
// Include all implict dependencies from the external packages internal option
|
|
617
|
-
include: disabled ? undefined : include,
|
|
618
|
-
noDiscovery: disabled,
|
|
619
|
-
// Add an esbuild plugin to run the Angular linker on dependencies
|
|
620
|
-
esbuildOptions: {
|
|
621
|
-
// Set esbuild supported targets.
|
|
622
|
-
target,
|
|
623
|
-
supported: (0, internal_1.getFeatureSupport)(target, zoneless),
|
|
624
|
-
plugins,
|
|
625
|
-
loader,
|
|
626
|
-
define: {
|
|
627
|
-
'ngServerMode': `${ssr}`,
|
|
628
|
-
},
|
|
629
|
-
resolveExtensions: ['.mjs', '.js', '.cjs'],
|
|
630
|
-
},
|
|
631
|
-
};
|
|
632
|
-
}
|
|
633
617
|
/**
|
|
634
618
|
* Checks if the given value is an absolute URL.
|
|
635
619
|
*
|
|
@@ -33,7 +33,7 @@ async function normalizeOptions(context, projectName, options) {
|
|
|
33
33
|
// Target specifier defaults to the current project's build target with no specified configuration
|
|
34
34
|
const buildTargetSpecifier = options.buildTarget ?? ':';
|
|
35
35
|
const buildTarget = (0, architect_1.targetFromTargetString)(buildTargetSpecifier, projectName, 'build');
|
|
36
|
-
const i18nOptions = (0, i18n_options_1.createI18nOptions)(projectMetadata);
|
|
36
|
+
const i18nOptions = (0, i18n_options_1.createI18nOptions)(projectMetadata, /** inline */ false, context.logger);
|
|
37
37
|
// Normalize xliff format extensions
|
|
38
38
|
let format = options.format;
|
|
39
39
|
switch (format) {
|
|
@@ -24,4 +24,4 @@ export interface AngularHostOptions {
|
|
|
24
24
|
* @param program The TypeScript Program instance to patch.
|
|
25
25
|
*/
|
|
26
26
|
export declare function ensureSourceFileVersions(program: ts.Program): void;
|
|
27
|
-
export declare function createAngularCompilerHost(typescript: typeof ts, compilerOptions: AngularCompilerOptions, hostOptions: AngularHostOptions): AngularCompilerHost;
|
|
27
|
+
export declare function createAngularCompilerHost(typescript: typeof ts, compilerOptions: AngularCompilerOptions, hostOptions: AngularHostOptions, packageJsonCache: ts.PackageJsonInfoCache | undefined): AngularCompilerHost;
|
|
@@ -91,7 +91,7 @@ function augmentHostWithReplacements(typescript, host, replacements, moduleResol
|
|
|
91
91
|
};
|
|
92
92
|
augmentResolveModuleNames(typescript, host, tryReplace, moduleResolutionCache);
|
|
93
93
|
}
|
|
94
|
-
function createAngularCompilerHost(typescript, compilerOptions, hostOptions) {
|
|
94
|
+
function createAngularCompilerHost(typescript, compilerOptions, hostOptions, packageJsonCache) {
|
|
95
95
|
// Create TypeScript compiler host
|
|
96
96
|
const host = typescript.createIncrementalCompilerHost(compilerOptions);
|
|
97
97
|
// Set the parsing mode to the same as TS 5.3+ default for tsc. This provides a parse
|
|
@@ -135,11 +135,11 @@ function createAngularCompilerHost(typescript, compilerOptions, hostOptions) {
|
|
|
135
135
|
host.getModifiedResourceFiles = function () {
|
|
136
136
|
return hostOptions.modifiedFiles;
|
|
137
137
|
};
|
|
138
|
+
// Provide a resolution cache to ensure package.json lookups are cached
|
|
139
|
+
const resolutionCache = typescript.createModuleResolutionCache(host.getCurrentDirectory(), host.getCanonicalFileName.bind(host), compilerOptions, packageJsonCache);
|
|
140
|
+
host.getModuleResolutionCache = () => resolutionCache;
|
|
138
141
|
// Augment TypeScript Host for file replacements option
|
|
139
142
|
if (hostOptions.fileReplacements) {
|
|
140
|
-
// Provide a resolution cache since overriding resolution prevents automatic creation
|
|
141
|
-
const resolutionCache = typescript.createModuleResolutionCache(host.getCurrentDirectory(), host.getCanonicalFileName.bind(host), compilerOptions);
|
|
142
|
-
host.getModuleResolutionCache = () => resolutionCache;
|
|
143
143
|
augmentHostWithReplacements(typescript, host, hostOptions.fileReplacements, resolutionCache);
|
|
144
144
|
}
|
|
145
145
|
// Augment TypeScript Host with source file caching if provided
|
|
@@ -11,6 +11,8 @@ import { AngularHostOptions } from '../angular-host';
|
|
|
11
11
|
import { AngularCompilation, DiagnosticModes, EmitFileResult } from './angular-compilation';
|
|
12
12
|
export declare class AotCompilation extends AngularCompilation {
|
|
13
13
|
#private;
|
|
14
|
+
private readonly browserOnlyBuild;
|
|
15
|
+
constructor(browserOnlyBuild: boolean);
|
|
14
16
|
initialize(tsconfig: string, hostOptions: AngularHostOptions, compilerOptionsTransformer?: (compilerOptions: ng.CompilerOptions) => ng.CompilerOptions): Promise<{
|
|
15
17
|
affectedFiles: ReadonlySet<ts.SourceFile>;
|
|
16
18
|
compilerOptions: ng.CompilerOptions;
|