@angular/build 19.0.5 → 19.1.0-next.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 +19 -19
- package/src/builders/application/build-action.js +17 -7
- package/src/builders/application/execute-build.js +2 -2
- 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.js +22 -26
- package/src/builders/extract-i18n/builder.js +17 -7
- package/src/builders/extract-i18n/options.js +1 -1
- package/src/tools/angular/compilation/angular-compilation.js +17 -7
- package/src/tools/angular/compilation/aot-compilation.d.ts +2 -0
- package/src/tools/angular/compilation/aot-compilation.js +22 -37
- package/src/tools/angular/compilation/factory.d.ts +2 -1
- package/src/tools/angular/compilation/factory.js +22 -11
- package/src/tools/angular/compilation/hmr-candidates.d.ts +22 -0
- package/src/tools/angular/compilation/hmr-candidates.js +238 -0
- package/src/tools/angular/compilation/jit-compilation.d.ts +2 -0
- package/src/tools/angular/compilation/jit-compilation.js +11 -1
- 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/babel/plugins/pure-toplevel-functions.js +17 -7
- package/src/tools/esbuild/angular/compiler-plugin.d.ts +1 -0
- package/src/tools/esbuild/angular/compiler-plugin.js +18 -8
- package/src/tools/esbuild/angular/source-file-cache.d.ts +1 -1
- package/src/tools/esbuild/angular/source-file-cache.js +17 -7
- package/src/tools/esbuild/compiler-plugin-options.js +1 -0
- package/src/tools/esbuild/global-scripts.js +17 -7
- package/src/tools/esbuild/javascript-transformer-worker.js +17 -7
- package/src/tools/esbuild/stylesheets/less-language.js +17 -7
- package/src/tools/esbuild/stylesheets/sass-language.js +17 -7
- package/src/tools/esbuild/stylesheets/stylesheet-plugin-factory.js +17 -7
- package/src/tools/vite/plugins/ssr-transform-plugin.js +11 -15
- package/src/utils/check-port.js +17 -7
- 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 +17 -7
- package/src/utils/index-file/inline-fonts.js +17 -7
- package/src/utils/load-proxy-config.js +17 -7
- package/src/utils/load-translations.js +17 -7
- package/src/utils/normalize-asset-patterns.js +17 -7
- package/src/utils/normalize-cache.js +1 -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/src/utils/service-worker.js +17 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular/build",
|
|
3
|
-
"version": "19.0.
|
|
3
|
+
"version": "19.1.0-next.1",
|
|
4
4
|
"description": "Official build system for Angular",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Angular CLI",
|
|
@@ -23,45 +23,45 @@
|
|
|
23
23
|
"builders": "builders.json",
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@ampproject/remapping": "2.3.0",
|
|
26
|
-
"@angular-devkit/architect": "0.
|
|
26
|
+
"@angular-devkit/architect": "0.1901.0-next.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",
|
|
30
30
|
"@babel/plugin-syntax-import-attributes": "7.26.0",
|
|
31
|
-
"@inquirer/confirm": "5.0
|
|
32
|
-
"@vitejs/plugin-basic-ssl": "1.
|
|
33
|
-
"beasties": "0.
|
|
31
|
+
"@inquirer/confirm": "5.1.0",
|
|
32
|
+
"@vitejs/plugin-basic-ssl": "1.2.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
|
-
"piscina": "4.
|
|
45
|
-
"rollup": "4.
|
|
46
|
-
"sass": "1.
|
|
44
|
+
"piscina": "4.8.0",
|
|
45
|
+
"rollup": "4.28.1",
|
|
46
|
+
"sass": "1.82.0",
|
|
47
47
|
"semver": "7.6.3",
|
|
48
|
-
"vite": "
|
|
48
|
+
"vite": "6.0.3",
|
|
49
49
|
"watchpack": "2.4.2"
|
|
50
50
|
},
|
|
51
51
|
"optionalDependencies": {
|
|
52
|
-
"lmdb": "3.
|
|
52
|
+
"lmdb": "3.2.0"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"@angular/compiler": "^19.0.0",
|
|
56
|
-
"@angular/compiler-cli": "^19.0.0",
|
|
57
|
-
"@angular/localize": "^19.0.0",
|
|
58
|
-
"@angular/platform-server": "^19.0.0",
|
|
59
|
-
"@angular/service-worker": "^19.0.0",
|
|
60
|
-
"@angular/ssr": "^19.0.
|
|
55
|
+
"@angular/compiler": "^19.0.0 || ^19.1.0-next.0",
|
|
56
|
+
"@angular/compiler-cli": "^19.0.0 || ^19.1.0-next.0",
|
|
57
|
+
"@angular/localize": "^19.0.0 || ^19.1.0-next.0",
|
|
58
|
+
"@angular/platform-server": "^19.0.0 || ^19.1.0-next.0",
|
|
59
|
+
"@angular/service-worker": "^19.0.0 || ^19.1.0-next.0",
|
|
60
|
+
"@angular/ssr": "^19.1.0-next.1",
|
|
61
61
|
"less": "^4.2.0",
|
|
62
62
|
"postcss": "^8.4.0",
|
|
63
63
|
"tailwindcss": "^2.0.0 || ^3.0.0",
|
|
64
|
-
"typescript": ">=5.5 <5.
|
|
64
|
+
"typescript": ">=5.5 <5.8"
|
|
65
65
|
},
|
|
66
66
|
"peerDependenciesMeta": {
|
|
67
67
|
"@angular/localize": {
|
|
@@ -22,13 +22,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
22
22
|
}) : function(o, v) {
|
|
23
23
|
o["default"] = v;
|
|
24
24
|
});
|
|
25
|
-
var __importStar = (this && this.__importStar) || function (
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
};
|
|
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
|
+
})();
|
|
32
42
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
33
43
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
34
44
|
};
|
|
@@ -161,13 +161,13 @@ async function executeBuild(options, context, rebuildState) {
|
|
|
161
161
|
}
|
|
162
162
|
// Perform i18n translation inlining if enabled
|
|
163
163
|
if (i18nOptions.shouldInline) {
|
|
164
|
-
const result = await (0, i18n_1.inlineI18n)(options, executionResult, initialFiles);
|
|
164
|
+
const result = await (0, i18n_1.inlineI18n)(metafile, options, executionResult, initialFiles);
|
|
165
165
|
executionResult.addErrors(result.errors);
|
|
166
166
|
executionResult.addWarnings(result.warnings);
|
|
167
167
|
executionResult.addPrerenderedRoutes(result.prerenderedRoutes);
|
|
168
168
|
}
|
|
169
169
|
else {
|
|
170
|
-
const result = await (0, execute_post_bundle_1.executePostBundleSteps)(options, executionResult.outputFiles, executionResult.assetFiles, initialFiles,
|
|
170
|
+
const result = await (0, execute_post_bundle_1.executePostBundleSteps)(metafile, options, executionResult.outputFiles, executionResult.assetFiles, initialFiles,
|
|
171
171
|
// Set lang attribute to the defined source locale if present
|
|
172
172
|
i18nOptions.hasDefinedSourceLocale ? i18nOptions.sourceLocale : undefined);
|
|
173
173
|
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
|
}
|
|
@@ -22,13 +22,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
22
22
|
}) : function(o, v) {
|
|
23
23
|
o["default"] = v;
|
|
24
24
|
});
|
|
25
|
-
var __importStar = (this && this.__importStar) || function (
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
};
|
|
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
|
+
})();
|
|
32
42
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
33
43
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
34
44
|
};
|
|
@@ -203,17 +213,10 @@ async function* serveWithVite(serverOptions, builderName, builderAction, context
|
|
|
203
213
|
continue;
|
|
204
214
|
}
|
|
205
215
|
// To avoid disconnecting the array objects from the option, these arrays need to be mutated instead of replaced.
|
|
206
|
-
let requiresServerRestart = false;
|
|
207
216
|
if (result.detail?.['externalMetadata']) {
|
|
208
217
|
const { implicitBrowser, implicitServer, explicit } = result.detail['externalMetadata'];
|
|
209
218
|
const implicitServerFiltered = implicitServer.filter((m) => !(0, node_module_1.isBuiltin)(m) && !isAbsoluteUrl(m));
|
|
210
219
|
const implicitBrowserFiltered = implicitBrowser.filter((m) => !isAbsoluteUrl(m));
|
|
211
|
-
if (browserOptions.ssr && serverOptions.prebundle !== false) {
|
|
212
|
-
const previousImplicitServer = new Set(externalMetadata.implicitServer);
|
|
213
|
-
// Restart the server to force SSR dep re-optimization when a dependency has been added.
|
|
214
|
-
// This is a workaround for: https://github.com/vitejs/vite/issues/14896
|
|
215
|
-
requiresServerRestart = implicitServerFiltered.some((dep) => !previousImplicitServer.has(dep));
|
|
216
|
-
}
|
|
217
220
|
// Empty Arrays to avoid growing unlimited with every re-build.
|
|
218
221
|
externalMetadata.explicitBrowser.length = 0;
|
|
219
222
|
externalMetadata.explicitServer.length = 0;
|
|
@@ -235,14 +238,7 @@ async function* serveWithVite(serverOptions, builderName, builderAction, context
|
|
|
235
238
|
server.config.server.fs.allow = [
|
|
236
239
|
...new Set([...server.config.server.fs.allow, ...assetFiles.values()]),
|
|
237
240
|
];
|
|
238
|
-
|
|
239
|
-
// Restart the server to force SSR dep re-optimization when a dependency has been added.
|
|
240
|
-
// This is a workaround for: https://github.com/vitejs/vite/issues/14896
|
|
241
|
-
await server.restart();
|
|
242
|
-
}
|
|
243
|
-
else {
|
|
244
|
-
await handleUpdate(normalizePath, generatedFiles, server, serverOptions, context.logger, componentStyles);
|
|
245
|
-
}
|
|
241
|
+
await handleUpdate(normalizePath, generatedFiles, server, serverOptions, context.logger, componentStyles);
|
|
246
242
|
}
|
|
247
243
|
else {
|
|
248
244
|
const projectName = context.target?.project;
|
|
@@ -337,6 +333,10 @@ async function handleUpdate(normalizePath, generatedFiles, server, serverOptions
|
|
|
337
333
|
if (!updatedFiles.length) {
|
|
338
334
|
return;
|
|
339
335
|
}
|
|
336
|
+
if (destroyAngularServerAppCalled) {
|
|
337
|
+
// Trigger module evaluation before reload to initiate dependency optimization.
|
|
338
|
+
await server.ssrLoadModule('/main.server.mjs');
|
|
339
|
+
}
|
|
340
340
|
if (serverOptions.hmr) {
|
|
341
341
|
if (updatedFiles.every((f) => f.endsWith('.css'))) {
|
|
342
342
|
let requiresReload = false;
|
|
@@ -517,10 +517,6 @@ async function setupServer(serverOptions, outputFiles, assets, preserveSymlinks,
|
|
|
517
517
|
// the Vite client-side code for browser reloading. These would be available by default but when
|
|
518
518
|
// the `allow` option is explicitly configured, they must be included manually.
|
|
519
519
|
allow: [cacheDir, (0, node_path_1.join)(serverOptions.workspaceRoot, 'node_modules'), ...assets.values()],
|
|
520
|
-
// Temporary disable cached FS checks.
|
|
521
|
-
// This is because we configure `config.base` to a virtual directory which causes `getRealPath` to fail.
|
|
522
|
-
// See: https://github.com/vitejs/vite/blob/b2873ac3936de25ca8784327cb9ef16bd4881805/packages/vite/src/node/fsUtils.ts#L45-L67
|
|
523
|
-
cachedChecks: false,
|
|
524
520
|
},
|
|
525
521
|
// This is needed when `externalDependencies` is used to prevent Vite load errors.
|
|
526
522
|
// NOTE: If Vite adds direct support for externals, this can be removed.
|
|
@@ -22,13 +22,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
22
22
|
}) : function(o, v) {
|
|
23
23
|
o["default"] = v;
|
|
24
24
|
});
|
|
25
|
-
var __importStar = (this && this.__importStar) || function (
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
};
|
|
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
|
+
})();
|
|
32
42
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
33
43
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
34
44
|
};
|
|
@@ -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) {
|
|
@@ -22,13 +22,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
22
22
|
}) : function(o, v) {
|
|
23
23
|
o["default"] = v;
|
|
24
24
|
});
|
|
25
|
-
var __importStar = (this && this.__importStar) || function (
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
};
|
|
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
|
+
})();
|
|
32
42
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
43
|
exports.AngularCompilation = exports.DiagnosticModes = void 0;
|
|
34
44
|
const load_esm_1 = require("../../../utils/load-esm");
|
|
@@ -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;
|
|
@@ -17,8 +17,16 @@ const typescript_1 = __importDefault(require("typescript"));
|
|
|
17
17
|
const profiling_1 = require("../../esbuild/profiling");
|
|
18
18
|
const angular_host_1 = require("../angular-host");
|
|
19
19
|
const jit_bootstrap_transformer_1 = require("../transformers/jit-bootstrap-transformer");
|
|
20
|
+
const lazy_routes_transformer_1 = require("../transformers/lazy-routes-transformer");
|
|
20
21
|
const web_worker_transformer_1 = require("../transformers/web-worker-transformer");
|
|
21
22
|
const angular_compilation_1 = require("./angular-compilation");
|
|
23
|
+
const hmr_candidates_1 = require("./hmr-candidates");
|
|
24
|
+
/**
|
|
25
|
+
* The modified files count limit for performing component HMR analysis.
|
|
26
|
+
* Performing content analysis for a large amount of files can result in longer rebuild times
|
|
27
|
+
* than a full rebuild would entail.
|
|
28
|
+
*/
|
|
29
|
+
const HMR_MODIFIED_FILE_LIMIT = 32;
|
|
22
30
|
class AngularCompilationState {
|
|
23
31
|
angularProgram;
|
|
24
32
|
compilerHost;
|
|
@@ -41,7 +49,12 @@ class AngularCompilationState {
|
|
|
41
49
|
}
|
|
42
50
|
}
|
|
43
51
|
class AotCompilation extends angular_compilation_1.AngularCompilation {
|
|
52
|
+
browserOnlyBuild;
|
|
44
53
|
#state;
|
|
54
|
+
constructor(browserOnlyBuild) {
|
|
55
|
+
super();
|
|
56
|
+
this.browserOnlyBuild = browserOnlyBuild;
|
|
57
|
+
}
|
|
45
58
|
async initialize(tsconfig, hostOptions, compilerOptionsTransformer) {
|
|
46
59
|
// Dynamically load the Angular compiler CLI package
|
|
47
60
|
const { NgtscProgram, OptimizeFor } = await angular_compilation_1.AngularCompilation.loadCompilerCli();
|
|
@@ -55,7 +68,9 @@ class AotCompilation extends angular_compilation_1.AngularCompilation {
|
|
|
55
68
|
const packageJsonCache = this.#state?.compilerHost
|
|
56
69
|
.getModuleResolutionCache?.()
|
|
57
70
|
?.getPackageJsonInfoCache();
|
|
58
|
-
const useHmr = compilerOptions['_enableHmr']
|
|
71
|
+
const useHmr = compilerOptions['_enableHmr'] &&
|
|
72
|
+
hostOptions.modifiedFiles &&
|
|
73
|
+
hostOptions.modifiedFiles.size <= HMR_MODIFIED_FILE_LIMIT;
|
|
59
74
|
let staleSourceFiles;
|
|
60
75
|
let clearPackageJsonCache = false;
|
|
61
76
|
if (hostOptions.modifiedFiles && this.#state) {
|
|
@@ -91,8 +106,8 @@ class AotCompilation extends angular_compilation_1.AngularCompilation {
|
|
|
91
106
|
const typeScriptProgram = typescript_1.default.createEmitAndSemanticDiagnosticsBuilderProgram(angularTypeScriptProgram, host, oldProgram, configurationDiagnostics);
|
|
92
107
|
await (0, profiling_1.profileAsync)('NG_ANALYZE_PROGRAM', () => angularCompiler.analyzeAsync());
|
|
93
108
|
let templateUpdates;
|
|
94
|
-
if (
|
|
95
|
-
const componentNodes = collectHmrCandidates(hostOptions.modifiedFiles, angularProgram, staleSourceFiles);
|
|
109
|
+
if (useHmr && hostOptions.modifiedFiles && this.#state) {
|
|
110
|
+
const componentNodes = (0, hmr_candidates_1.collectHmrCandidates)(hostOptions.modifiedFiles, angularProgram, staleSourceFiles);
|
|
96
111
|
for (const node of componentNodes) {
|
|
97
112
|
if (!typescript_1.default.isClassDeclaration(node)) {
|
|
98
113
|
continue;
|
|
@@ -214,8 +229,10 @@ class AotCompilation extends angular_compilation_1.AngularCompilation {
|
|
|
214
229
|
};
|
|
215
230
|
const transformers = angularCompiler.prepareEmit().transformers;
|
|
216
231
|
transformers.before ??= [];
|
|
217
|
-
transformers.before.push((0, jit_bootstrap_transformer_1.replaceBootstrap)(() => typeScriptProgram.getProgram().getTypeChecker()));
|
|
218
|
-
|
|
232
|
+
transformers.before.push((0, jit_bootstrap_transformer_1.replaceBootstrap)(() => typeScriptProgram.getProgram().getTypeChecker()), webWorkerTransform);
|
|
233
|
+
if (!this.browserOnlyBuild) {
|
|
234
|
+
transformers.before.push((0, lazy_routes_transformer_1.lazyRoutesTransformer)(compilerOptions, compilerHost));
|
|
235
|
+
}
|
|
219
236
|
// Emit is handled in write file callback when using TypeScript
|
|
220
237
|
if (useTypeScriptTranspilation) {
|
|
221
238
|
// TypeScript will loop until there are no more affected files in the program
|
|
@@ -317,35 +334,3 @@ function findAffectedFiles(builder, { ignoreForDiagnostics }, includeTTC) {
|
|
|
317
334
|
}
|
|
318
335
|
return affectedFiles;
|
|
319
336
|
}
|
|
320
|
-
function collectHmrCandidates(modifiedFiles, { compiler }, staleSourceFiles) {
|
|
321
|
-
const candidates = new Set();
|
|
322
|
-
for (const file of modifiedFiles) {
|
|
323
|
-
const templateFileNodes = compiler.getComponentsWithTemplateFile(file);
|
|
324
|
-
if (templateFileNodes.size) {
|
|
325
|
-
templateFileNodes.forEach((node) => candidates.add(node));
|
|
326
|
-
continue;
|
|
327
|
-
}
|
|
328
|
-
const styleFileNodes = compiler.getComponentsWithStyleFile(file);
|
|
329
|
-
if (styleFileNodes.size) {
|
|
330
|
-
styleFileNodes.forEach((node) => candidates.add(node));
|
|
331
|
-
continue;
|
|
332
|
-
}
|
|
333
|
-
const staleSource = staleSourceFiles?.get(file);
|
|
334
|
-
if (staleSource === undefined) {
|
|
335
|
-
// Unknown file requires a rebuild so clear out the candidates and stop collecting
|
|
336
|
-
candidates.clear();
|
|
337
|
-
break;
|
|
338
|
-
}
|
|
339
|
-
const updatedSource = compiler.getCurrentProgram().getSourceFile(file);
|
|
340
|
-
if (updatedSource === undefined) {
|
|
341
|
-
// No longer existing program file requires a rebuild so clear out the candidates and stop collecting
|
|
342
|
-
candidates.clear();
|
|
343
|
-
break;
|
|
344
|
-
}
|
|
345
|
-
// Compare the stale and updated file for changes
|
|
346
|
-
// TODO: Implement -- for now assume a rebuild is needed
|
|
347
|
-
candidates.clear();
|
|
348
|
-
break;
|
|
349
|
-
}
|
|
350
|
-
return candidates;
|
|
351
|
-
}
|
|
@@ -11,6 +11,7 @@ import type { AngularCompilation } from './angular-compilation';
|
|
|
11
11
|
* compilation either for AOT or JIT mode. By default a parallel compilation is created
|
|
12
12
|
* that uses a Node.js worker thread.
|
|
13
13
|
* @param jit True, for Angular JIT compilation; False, for Angular AOT compilation.
|
|
14
|
+
* @param browserOnlyBuild True, for browser only builds; False, for browser and server builds.
|
|
14
15
|
* @returns An instance of an Angular compilation object.
|
|
15
16
|
*/
|
|
16
|
-
export declare function createAngularCompilation(jit: boolean): Promise<AngularCompilation>;
|
|
17
|
+
export declare function createAngularCompilation(jit: boolean, browserOnlyBuild: boolean): Promise<AngularCompilation>;
|