@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
|
@@ -5,6 +5,7 @@
|
|
|
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 { NormalizedApplicationBuildOptions } from '../../builders/application/options';
|
|
9
10
|
import { type BuildOutputFile } from '../../tools/esbuild/bundler-context';
|
|
10
11
|
export declare const SERVER_APP_MANIFEST_FILENAME = "angular-app-manifest.mjs";
|
|
@@ -42,12 +43,15 @@ export declare function generateAngularServerAppEngineManifest(i18nOptions: Norm
|
|
|
42
43
|
* the application, helping with localization and rendering content specific to the locale.
|
|
43
44
|
* @param baseHref - The base HREF for the application. This is used to set the base URL
|
|
44
45
|
* for all relative URLs in the application.
|
|
46
|
+
* @param initialFiles - A list of initial files that preload tags have already been added for.
|
|
47
|
+
* @param metafile - An esbuild metafile object.
|
|
48
|
+
* @param publicPath - The configured public path.
|
|
45
49
|
*
|
|
46
50
|
* @returns An object containing:
|
|
47
51
|
* - `manifestContent`: A string of the SSR manifest content.
|
|
48
52
|
* - `serverAssetsChunks`: An array of build output files containing the generated assets for the server.
|
|
49
53
|
*/
|
|
50
|
-
export declare function generateAngularServerAppManifest(additionalHtmlOutputFiles: Map<string, BuildOutputFile>, outputFiles: BuildOutputFile[], inlineCriticalCss: boolean, routes: readonly unknown[] | undefined, locale: string | undefined, baseHref: string): {
|
|
54
|
+
export declare function generateAngularServerAppManifest(additionalHtmlOutputFiles: Map<string, BuildOutputFile>, outputFiles: BuildOutputFile[], inlineCriticalCss: boolean, routes: readonly unknown[] | undefined, locale: string | undefined, baseHref: string, initialFiles: Set<string>, metafile: Metafile, publicPath: string | undefined): {
|
|
51
55
|
manifestContent: string;
|
|
52
56
|
serverAssetsChunks: BuildOutputFile[];
|
|
53
57
|
};
|
|
@@ -11,9 +11,9 @@ exports.SERVER_APP_ENGINE_MANIFEST_FILENAME = exports.SERVER_APP_MANIFEST_FILENA
|
|
|
11
11
|
exports.generateAngularServerAppEngineManifest = generateAngularServerAppEngineManifest;
|
|
12
12
|
exports.generateAngularServerAppManifest = generateAngularServerAppManifest;
|
|
13
13
|
const node_path_1 = require("node:path");
|
|
14
|
-
const options_1 = require("../../builders/application/options");
|
|
15
14
|
const bundler_context_1 = require("../../tools/esbuild/bundler-context");
|
|
16
15
|
const utils_1 = require("../../tools/esbuild/utils");
|
|
16
|
+
const environment_options_1 = require("../environment-options");
|
|
17
17
|
exports.SERVER_APP_MANIFEST_FILENAME = 'angular-app-manifest.mjs';
|
|
18
18
|
exports.SERVER_APP_ENGINE_MANIFEST_FILENAME = 'angular-app-engine-manifest.mjs';
|
|
19
19
|
const MAIN_SERVER_OUTPUT_FILENAME = 'main.server.mjs';
|
|
@@ -49,23 +49,28 @@ function escapeUnsafeChars(str) {
|
|
|
49
49
|
*/
|
|
50
50
|
function generateAngularServerAppEngineManifest(i18nOptions, baseHref) {
|
|
51
51
|
const entryPoints = {};
|
|
52
|
-
|
|
52
|
+
const supportedLocales = {};
|
|
53
|
+
if (i18nOptions.shouldInline && !i18nOptions.flatOutput) {
|
|
53
54
|
for (const locale of i18nOptions.inlineLocales) {
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const end = localeWithBaseHref[localeWithBaseHref.length - 1] === '/' ? -1 : undefined;
|
|
59
|
-
localeWithBaseHref = localeWithBaseHref.slice(start, end);
|
|
60
|
-
entryPoints[localeWithBaseHref] = `() => import('${importPath}')`;
|
|
55
|
+
const { subPath } = i18nOptions.locales[locale];
|
|
56
|
+
const importPath = `${subPath ? `${subPath}/` : ''}${MAIN_SERVER_OUTPUT_FILENAME}`;
|
|
57
|
+
entryPoints[subPath] = `() => import('./${importPath}')`;
|
|
58
|
+
supportedLocales[locale] = subPath;
|
|
61
59
|
}
|
|
62
60
|
}
|
|
63
61
|
else {
|
|
64
62
|
entryPoints[''] = `() => import('./${MAIN_SERVER_OUTPUT_FILENAME}')`;
|
|
63
|
+
supportedLocales[i18nOptions.sourceLocale] = '';
|
|
64
|
+
}
|
|
65
|
+
// Remove trailing slash but retain leading slash.
|
|
66
|
+
let basePath = baseHref || '/';
|
|
67
|
+
if (basePath.length > 1 && basePath[basePath.length - 1] === '/') {
|
|
68
|
+
basePath = basePath.slice(0, -1);
|
|
65
69
|
}
|
|
66
70
|
const manifestContent = `
|
|
67
71
|
export default {
|
|
68
|
-
basePath: '${
|
|
72
|
+
basePath: '${basePath}',
|
|
73
|
+
supportedLocales: ${JSON.stringify(supportedLocales, undefined, 2)},
|
|
69
74
|
entryPoints: {
|
|
70
75
|
${Object.entries(entryPoints)
|
|
71
76
|
.map(([key, value]) => `'${key}': ${value}`)
|
|
@@ -95,12 +100,15 @@ export default {
|
|
|
95
100
|
* the application, helping with localization and rendering content specific to the locale.
|
|
96
101
|
* @param baseHref - The base HREF for the application. This is used to set the base URL
|
|
97
102
|
* for all relative URLs in the application.
|
|
103
|
+
* @param initialFiles - A list of initial files that preload tags have already been added for.
|
|
104
|
+
* @param metafile - An esbuild metafile object.
|
|
105
|
+
* @param publicPath - The configured public path.
|
|
98
106
|
*
|
|
99
107
|
* @returns An object containing:
|
|
100
108
|
* - `manifestContent`: A string of the SSR manifest content.
|
|
101
109
|
* - `serverAssetsChunks`: An array of build output files containing the generated assets for the server.
|
|
102
110
|
*/
|
|
103
|
-
function generateAngularServerAppManifest(additionalHtmlOutputFiles, outputFiles, inlineCriticalCss, routes, locale, baseHref) {
|
|
111
|
+
function generateAngularServerAppManifest(additionalHtmlOutputFiles, outputFiles, inlineCriticalCss, routes, locale, baseHref, initialFiles, metafile, publicPath) {
|
|
104
112
|
const serverAssetsChunks = [];
|
|
105
113
|
const serverAssets = {};
|
|
106
114
|
for (const file of [...additionalHtmlOutputFiles.values(), ...outputFiles]) {
|
|
@@ -112,6 +120,11 @@ function generateAngularServerAppManifest(additionalHtmlOutputFiles, outputFiles
|
|
|
112
120
|
`{size: ${file.size}, hash: '${file.hash}', text: () => import('./${jsChunkFilePath}').then(m => m.default)}`;
|
|
113
121
|
}
|
|
114
122
|
}
|
|
123
|
+
// When routes have been extracted, mappings are no longer needed, as preloads will be included in the metadata.
|
|
124
|
+
// When shouldOptimizeChunks is enabled the metadata is no longer correct and thus we cannot generate the mappings.
|
|
125
|
+
const entryPointToBrowserMapping = routes?.length || environment_options_1.shouldOptimizeChunks
|
|
126
|
+
? undefined
|
|
127
|
+
: generateLazyLoadedFilesMappings(metafile, initialFiles, publicPath);
|
|
115
128
|
const manifestContent = `
|
|
116
129
|
export default {
|
|
117
130
|
bootstrap: () => import('./main.server.mjs').then(m => m.default),
|
|
@@ -119,6 +132,7 @@ export default {
|
|
|
119
132
|
baseHref: '${baseHref}',
|
|
120
133
|
locale: ${JSON.stringify(locale)},
|
|
121
134
|
routes: ${JSON.stringify(routes, undefined, 2)},
|
|
135
|
+
entryPointToBrowserMapping: ${JSON.stringify(entryPointToBrowserMapping, undefined, 2)},
|
|
122
136
|
assets: {
|
|
123
137
|
${Object.entries(serverAssets)
|
|
124
138
|
.map(([key, value]) => `'${key}': ${value}`)
|
|
@@ -128,3 +142,38 @@ export default {
|
|
|
128
142
|
`;
|
|
129
143
|
return { manifestContent, serverAssetsChunks };
|
|
130
144
|
}
|
|
145
|
+
/**
|
|
146
|
+
* Maps entry points to their corresponding browser bundles for lazy loading.
|
|
147
|
+
*
|
|
148
|
+
* This function processes a metafile's outputs to generate a mapping between browser-side entry points
|
|
149
|
+
* and the associated JavaScript files that should be loaded in the browser. It includes the entry-point's
|
|
150
|
+
* own path and any valid imports while excluding initial files or external resources.
|
|
151
|
+
*/
|
|
152
|
+
function generateLazyLoadedFilesMappings(metafile, initialFiles, publicPath = '') {
|
|
153
|
+
const entryPointToBundles = {};
|
|
154
|
+
for (const [fileName, { entryPoint, exports, imports }] of Object.entries(metafile.outputs)) {
|
|
155
|
+
// Skip files that don't have an entryPoint, no exports, or are not .js
|
|
156
|
+
if (!entryPoint || exports?.length < 1 || !fileName.endsWith('.js')) {
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
const importedPaths = [
|
|
160
|
+
{
|
|
161
|
+
path: `${publicPath}${fileName}`,
|
|
162
|
+
dynamicImport: false,
|
|
163
|
+
},
|
|
164
|
+
];
|
|
165
|
+
for (const { kind, external, path } of imports) {
|
|
166
|
+
if (external ||
|
|
167
|
+
initialFiles.has(path) ||
|
|
168
|
+
(kind !== 'dynamic-import' && kind !== 'import-statement')) {
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
importedPaths.push({
|
|
172
|
+
path: `${publicPath}${path}`,
|
|
173
|
+
dynamicImport: kind === 'dynamic-import',
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
entryPointToBundles[entryPoint] = importedPaths;
|
|
177
|
+
}
|
|
178
|
+
return entryPointToBundles;
|
|
179
|
+
}
|
|
@@ -122,7 +122,7 @@ async function renderPages(baseHref, sourcemap, serializableRouteTreeNode, maxTh
|
|
|
122
122
|
const renderingPromises = [];
|
|
123
123
|
const appShellRouteWithLeadingSlash = appShellRoute && addLeadingSlash(appShellRoute);
|
|
124
124
|
const baseHrefWithLeadingSlash = addLeadingSlash(baseHref);
|
|
125
|
-
for (const { route, redirectTo
|
|
125
|
+
for (const { route, redirectTo } of serializableRouteTreeNode) {
|
|
126
126
|
// Remove the base href from the file output path.
|
|
127
127
|
const routeWithoutBaseHref = addTrailingSlash(route).startsWith(baseHrefWithLeadingSlash)
|
|
128
128
|
? addLeadingSlash(route.slice(baseHrefWithLeadingSlash.length))
|
|
@@ -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.augmentAppWithServiceWorker = augmentAppWithServiceWorker;
|
|
34
44
|
exports.augmentAppWithServiceWorkerEsbuild = augmentAppWithServiceWorkerEsbuild;
|