@angular/build 19.0.0-next.7 → 19.0.0-next.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +9 -9
- package/src/builders/application/execute-build.js +19 -2
- package/src/builders/application/execute-post-bundle.d.ts +2 -2
- package/src/builders/application/execute-post-bundle.js +30 -11
- package/src/builders/application/i18n.d.ts +2 -2
- package/src/builders/application/i18n.js +4 -5
- package/src/builders/application/index.js +8 -5
- package/src/builders/application/options.d.ts +18 -1
- package/src/builders/application/options.js +30 -2
- package/src/builders/application/schema.d.ts +15 -0
- package/src/builders/application/schema.js +11 -1
- package/src/builders/application/schema.json +5 -0
- package/src/builders/application/setup-bundling.js +6 -3
- package/src/builders/dev-server/vite-server.d.ts +2 -1
- package/src/builders/dev-server/vite-server.js +64 -47
- package/src/builders/extract-i18n/application-extraction.js +3 -3
- package/src/tools/angular/angular-host.d.ts +2 -1
- package/src/tools/angular/angular-host.js +20 -1
- package/src/tools/angular/compilation/angular-compilation.d.ts +1 -0
- package/src/tools/angular/compilation/aot-compilation.d.ts +1 -0
- package/src/tools/angular/compilation/aot-compilation.js +9 -1
- package/src/tools/angular/compilation/parallel-compilation.d.ts +1 -0
- package/src/tools/angular/compilation/parallel-worker.d.ts +1 -0
- package/src/tools/angular/compilation/parallel-worker.js +2 -1
- package/src/tools/esbuild/angular/compiler-plugin.d.ts +1 -0
- package/src/tools/esbuild/angular/compiler-plugin.js +42 -3
- package/src/tools/esbuild/angular/component-stylesheets.d.ts +8 -3
- package/src/tools/esbuild/angular/component-stylesheets.js +46 -11
- package/src/tools/esbuild/application-code-bundle.d.ts +1 -0
- package/src/tools/esbuild/application-code-bundle.js +109 -2
- package/src/tools/esbuild/budget-stats.js +1 -1
- package/src/tools/esbuild/bundler-context.d.ts +4 -3
- package/src/tools/esbuild/bundler-context.js +8 -4
- package/src/tools/esbuild/bundler-execution-result.d.ts +5 -2
- package/src/tools/esbuild/bundler-execution-result.js +7 -3
- package/src/tools/esbuild/cache.d.ts +5 -0
- package/src/tools/esbuild/cache.js +7 -0
- package/src/tools/esbuild/compiler-plugin-options.js +2 -1
- package/src/tools/esbuild/i18n-inliner.js +2 -1
- package/src/tools/esbuild/utils.js +7 -3
- package/src/tools/vite/middlewares/assets-middleware.js +2 -5
- package/src/tools/vite/middlewares/html-fallback-middleware.js +22 -6
- package/src/tools/vite/middlewares/index.d.ts +1 -1
- package/src/tools/vite/middlewares/index.js +3 -2
- package/src/tools/vite/middlewares/ssr-middleware.d.ts +2 -1
- package/src/tools/vite/middlewares/ssr-middleware.js +61 -15
- package/src/tools/vite/plugins/angular-memory-plugin.d.ts +16 -0
- package/src/tools/vite/{angular-memory-plugin.js → plugins/angular-memory-plugin.js} +19 -41
- package/src/tools/vite/{i18n-locale-plugin.d.ts → plugins/i18n-locale-plugin.d.ts} +0 -4
- package/src/tools/vite/{i18n-locale-plugin.js → plugins/i18n-locale-plugin.js} +2 -3
- package/src/tools/vite/plugins/index.d.ts +12 -0
- package/src/tools/vite/plugins/index.js +21 -0
- package/src/tools/vite/plugins/setup-middlewares-plugin.d.ts +41 -0
- package/src/tools/vite/plugins/setup-middlewares-plugin.js +62 -0
- package/src/tools/vite/plugins/ssr-transform-plugin.d.ts +9 -0
- package/src/tools/vite/plugins/ssr-transform-plugin.js +38 -0
- package/src/utils/environment-options.d.ts +2 -0
- package/src/utils/environment-options.js +5 -1
- package/src/utils/index-file/valid-self-closing-tags.js +1 -0
- package/src/utils/normalize-cache.js +1 -1
- package/src/utils/server-rendering/manifest.d.ts +8 -2
- package/src/utils/server-rendering/manifest.js +61 -12
- package/src/utils/server-rendering/models.d.ts +27 -0
- package/src/utils/server-rendering/models.js +22 -0
- package/src/utils/server-rendering/prerender.d.ts +6 -10
- package/src/utils/server-rendering/prerender.js +100 -63
- package/src/utils/server-rendering/routes-extractor-worker.d.ts +5 -10
- package/src/utils/server-rendering/routes-extractor-worker.js +3 -4
- package/src/tools/vite/angular-memory-plugin.d.ts +0 -22
- /package/src/tools/vite/{id-prefix-plugin.d.ts → plugins/id-prefix-plugin.d.ts} +0 -0
- /package/src/tools/vite/{id-prefix-plugin.js → plugins/id-prefix-plugin.js} +0 -0
|
@@ -6,10 +6,6 @@
|
|
|
6
6
|
* found in the LICENSE file at https://angular.dev/license
|
|
7
7
|
*/
|
|
8
8
|
import type { Plugin } from 'vite';
|
|
9
|
-
/**
|
|
10
|
-
* The base module location used to search for locale specific data.
|
|
11
|
-
*/
|
|
12
|
-
export declare const LOCALE_DATA_BASE_MODULE = "@angular/common/locales/global";
|
|
13
9
|
/**
|
|
14
10
|
* Creates a Vite plugin that resolves Angular locale data files from `@angular/common`.
|
|
15
11
|
*
|
|
@@ -7,12 +7,11 @@
|
|
|
7
7
|
* found in the LICENSE file at https://angular.dev/license
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.LOCALE_DATA_BASE_MODULE = void 0;
|
|
11
10
|
exports.createAngularLocaleDataPlugin = createAngularLocaleDataPlugin;
|
|
12
11
|
/**
|
|
13
12
|
* The base module location used to search for locale specific data.
|
|
14
13
|
*/
|
|
15
|
-
|
|
14
|
+
const LOCALE_DATA_BASE_MODULE = '@angular/common/locales/global';
|
|
16
15
|
/**
|
|
17
16
|
* Creates a Vite plugin that resolves Angular locale data files from `@angular/common`.
|
|
18
17
|
*
|
|
@@ -32,7 +31,7 @@ function createAngularLocaleDataPlugin() {
|
|
|
32
31
|
let partialLocale = originalLocale.replace(/-x(-[a-zA-Z0-9]{1,8})+$/, '');
|
|
33
32
|
let exact = true;
|
|
34
33
|
while (partialLocale) {
|
|
35
|
-
const potentialPath = `${
|
|
34
|
+
const potentialPath = `${LOCALE_DATA_BASE_MODULE}/${partialLocale}`;
|
|
36
35
|
const result = await this.resolve(potentialPath);
|
|
37
36
|
if (result) {
|
|
38
37
|
if (!exact) {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.dev/license
|
|
7
|
+
*/
|
|
8
|
+
export { createAngularMemoryPlugin } from './angular-memory-plugin';
|
|
9
|
+
export { createAngularLocaleDataPlugin } from './i18n-locale-plugin';
|
|
10
|
+
export { createRemoveIdPrefixPlugin } from './id-prefix-plugin';
|
|
11
|
+
export { createAngularSetupMiddlewaresPlugin, ServerSsrMode } from './setup-middlewares-plugin';
|
|
12
|
+
export { createAngularSsrTransformPlugin } from './ssr-transform-plugin';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
5
|
+
*
|
|
6
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
+
* found in the LICENSE file at https://angular.dev/license
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.createAngularSsrTransformPlugin = exports.ServerSsrMode = exports.createAngularSetupMiddlewaresPlugin = exports.createRemoveIdPrefixPlugin = exports.createAngularLocaleDataPlugin = exports.createAngularMemoryPlugin = void 0;
|
|
11
|
+
var angular_memory_plugin_1 = require("./angular-memory-plugin");
|
|
12
|
+
Object.defineProperty(exports, "createAngularMemoryPlugin", { enumerable: true, get: function () { return angular_memory_plugin_1.createAngularMemoryPlugin; } });
|
|
13
|
+
var i18n_locale_plugin_1 = require("./i18n-locale-plugin");
|
|
14
|
+
Object.defineProperty(exports, "createAngularLocaleDataPlugin", { enumerable: true, get: function () { return i18n_locale_plugin_1.createAngularLocaleDataPlugin; } });
|
|
15
|
+
var id_prefix_plugin_1 = require("./id-prefix-plugin");
|
|
16
|
+
Object.defineProperty(exports, "createRemoveIdPrefixPlugin", { enumerable: true, get: function () { return id_prefix_plugin_1.createRemoveIdPrefixPlugin; } });
|
|
17
|
+
var setup_middlewares_plugin_1 = require("./setup-middlewares-plugin");
|
|
18
|
+
Object.defineProperty(exports, "createAngularSetupMiddlewaresPlugin", { enumerable: true, get: function () { return setup_middlewares_plugin_1.createAngularSetupMiddlewaresPlugin; } });
|
|
19
|
+
Object.defineProperty(exports, "ServerSsrMode", { enumerable: true, get: function () { return setup_middlewares_plugin_1.ServerSsrMode; } });
|
|
20
|
+
var ssr_transform_plugin_1 = require("./ssr-transform-plugin");
|
|
21
|
+
Object.defineProperty(exports, "createAngularSsrTransformPlugin", { enumerable: true, get: function () { return ssr_transform_plugin_1.createAngularSsrTransformPlugin; } });
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.dev/license
|
|
7
|
+
*/
|
|
8
|
+
import type { Connect, Plugin } from 'vite';
|
|
9
|
+
import { AngularMemoryOutputFiles } from '../utils';
|
|
10
|
+
export declare enum ServerSsrMode {
|
|
11
|
+
/**
|
|
12
|
+
* No SSR
|
|
13
|
+
*/
|
|
14
|
+
NoSsr = 0,
|
|
15
|
+
/**
|
|
16
|
+
* Internal server-side rendering (SSR) is handled through the built-in middleware.
|
|
17
|
+
*
|
|
18
|
+
* In this mode, the SSR process is managed internally by the dev-server's middleware.
|
|
19
|
+
* The server automatically renders pages on the server without requiring external
|
|
20
|
+
* middleware or additional configuration from the developer.
|
|
21
|
+
*/
|
|
22
|
+
InternalSsrMiddleware = 1,
|
|
23
|
+
/**
|
|
24
|
+
* External server-side rendering (SSR) is handled by a custom middleware defined in server.ts.
|
|
25
|
+
*
|
|
26
|
+
* This mode allows developers to define custom SSR behavior by providing a middleware in the
|
|
27
|
+
* `server.ts` file. It gives more flexibility for handling SSR, such as integrating with other
|
|
28
|
+
* frameworks or customizing the rendering pipeline.
|
|
29
|
+
*/
|
|
30
|
+
ExternalSsrMiddleware = 2
|
|
31
|
+
}
|
|
32
|
+
interface AngularSetupMiddlewaresPluginOptions {
|
|
33
|
+
outputFiles: AngularMemoryOutputFiles;
|
|
34
|
+
assets: Map<string, string>;
|
|
35
|
+
extensionMiddleware?: Connect.NextHandleFunction[];
|
|
36
|
+
indexHtmlTransformer?: (content: string) => Promise<string>;
|
|
37
|
+
usedComponentStyles: Map<string, string[]>;
|
|
38
|
+
ssrMode: ServerSsrMode;
|
|
39
|
+
}
|
|
40
|
+
export declare function createAngularSetupMiddlewaresPlugin(options: AngularSetupMiddlewaresPluginOptions): Plugin;
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
5
|
+
*
|
|
6
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
+
* found in the LICENSE file at https://angular.dev/license
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.ServerSsrMode = void 0;
|
|
11
|
+
exports.createAngularSetupMiddlewaresPlugin = createAngularSetupMiddlewaresPlugin;
|
|
12
|
+
const middlewares_1 = require("../middlewares");
|
|
13
|
+
var ServerSsrMode;
|
|
14
|
+
(function (ServerSsrMode) {
|
|
15
|
+
/**
|
|
16
|
+
* No SSR
|
|
17
|
+
*/
|
|
18
|
+
ServerSsrMode[ServerSsrMode["NoSsr"] = 0] = "NoSsr";
|
|
19
|
+
/**
|
|
20
|
+
* Internal server-side rendering (SSR) is handled through the built-in middleware.
|
|
21
|
+
*
|
|
22
|
+
* In this mode, the SSR process is managed internally by the dev-server's middleware.
|
|
23
|
+
* The server automatically renders pages on the server without requiring external
|
|
24
|
+
* middleware or additional configuration from the developer.
|
|
25
|
+
*/
|
|
26
|
+
ServerSsrMode[ServerSsrMode["InternalSsrMiddleware"] = 1] = "InternalSsrMiddleware";
|
|
27
|
+
/**
|
|
28
|
+
* External server-side rendering (SSR) is handled by a custom middleware defined in server.ts.
|
|
29
|
+
*
|
|
30
|
+
* This mode allows developers to define custom SSR behavior by providing a middleware in the
|
|
31
|
+
* `server.ts` file. It gives more flexibility for handling SSR, such as integrating with other
|
|
32
|
+
* frameworks or customizing the rendering pipeline.
|
|
33
|
+
*/
|
|
34
|
+
ServerSsrMode[ServerSsrMode["ExternalSsrMiddleware"] = 2] = "ExternalSsrMiddleware";
|
|
35
|
+
})(ServerSsrMode || (exports.ServerSsrMode = ServerSsrMode = {}));
|
|
36
|
+
function createAngularSetupMiddlewaresPlugin(options) {
|
|
37
|
+
return {
|
|
38
|
+
name: 'vite:angular-setup-middlewares',
|
|
39
|
+
enforce: 'pre',
|
|
40
|
+
configureServer(server) {
|
|
41
|
+
const { indexHtmlTransformer, outputFiles, extensionMiddleware, assets, usedComponentStyles, ssrMode, } = options;
|
|
42
|
+
// Headers, assets and resources get handled first
|
|
43
|
+
server.middlewares.use((0, middlewares_1.createAngularHeadersMiddleware)(server));
|
|
44
|
+
server.middlewares.use((0, middlewares_1.createAngularAssetsMiddleware)(server, assets, outputFiles, usedComponentStyles));
|
|
45
|
+
extensionMiddleware?.forEach((middleware) => server.middlewares.use(middleware));
|
|
46
|
+
// Returning a function, installs middleware after the main transform middleware but
|
|
47
|
+
// before the built-in HTML middleware
|
|
48
|
+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
49
|
+
return async () => {
|
|
50
|
+
if (ssrMode === ServerSsrMode.ExternalSsrMiddleware) {
|
|
51
|
+
server.middlewares.use(await (0, middlewares_1.createAngularSsrExternalMiddleware)(server, indexHtmlTransformer));
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (ssrMode === ServerSsrMode.InternalSsrMiddleware) {
|
|
55
|
+
server.middlewares.use((0, middlewares_1.createAngularSsrInternalMiddleware)(server, indexHtmlTransformer));
|
|
56
|
+
}
|
|
57
|
+
server.middlewares.use(middlewares_1.angularHtmlFallbackMiddleware);
|
|
58
|
+
server.middlewares.use((0, middlewares_1.createAngularIndexHtmlMiddleware)(server, outputFiles, indexHtmlTransformer));
|
|
59
|
+
};
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.dev/license
|
|
7
|
+
*/
|
|
8
|
+
import type { Plugin } from 'vite';
|
|
9
|
+
export declare function createAngularSsrTransformPlugin(workspaceRoot: string): Promise<Plugin>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
5
|
+
*
|
|
6
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
+
* found in the LICENSE file at https://angular.dev/license
|
|
8
|
+
*/
|
|
9
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.createAngularSsrTransformPlugin = createAngularSsrTransformPlugin;
|
|
14
|
+
const remapping_1 = __importDefault(require("@ampproject/remapping"));
|
|
15
|
+
const load_esm_1 = require("../../../utils/load-esm");
|
|
16
|
+
async function createAngularSsrTransformPlugin(workspaceRoot) {
|
|
17
|
+
const { normalizePath } = await (0, load_esm_1.loadEsmModule)('vite');
|
|
18
|
+
return {
|
|
19
|
+
name: 'vite:angular-ssr-transform',
|
|
20
|
+
enforce: 'pre',
|
|
21
|
+
async configureServer(server) {
|
|
22
|
+
const originalssrTransform = server.ssrTransform;
|
|
23
|
+
server.ssrTransform = async (code, map, url, originalCode) => {
|
|
24
|
+
const result = await originalssrTransform(code, null, url, originalCode);
|
|
25
|
+
if (!result || !result.map || !map) {
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
const remappedMap = (0, remapping_1.default)([result.map, map], () => null);
|
|
29
|
+
// Set the sourcemap root to the workspace root. This is needed since we set a virtual path as root.
|
|
30
|
+
remappedMap.sourceRoot = normalizePath(workspaceRoot) + '/';
|
|
31
|
+
return {
|
|
32
|
+
...result,
|
|
33
|
+
map: remappedMap,
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
}
|
|
@@ -15,3 +15,5 @@ export declare const shouldWatchRoot: boolean;
|
|
|
15
15
|
export declare const useTypeChecking: boolean;
|
|
16
16
|
export declare const useJSONBuildLogs: boolean;
|
|
17
17
|
export declare const shouldOptimizeChunks: boolean;
|
|
18
|
+
export declare const useComponentStyleHmr: boolean;
|
|
19
|
+
export declare const usePartialSsrBuild: boolean;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* found in the LICENSE file at https://angular.dev/license
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.shouldOptimizeChunks = exports.useJSONBuildLogs = exports.useTypeChecking = exports.shouldWatchRoot = exports.debugPerformance = exports.useParallelTs = exports.maxWorkers = exports.allowMinify = exports.shouldBeautify = exports.allowMangle = void 0;
|
|
10
|
+
exports.usePartialSsrBuild = exports.useComponentStyleHmr = exports.shouldOptimizeChunks = exports.useJSONBuildLogs = exports.useTypeChecking = exports.shouldWatchRoot = exports.debugPerformance = exports.useParallelTs = exports.maxWorkers = exports.allowMinify = exports.shouldBeautify = exports.allowMangle = void 0;
|
|
11
11
|
const node_os_1 = require("node:os");
|
|
12
12
|
function isDisabled(variable) {
|
|
13
13
|
return variable === '0' || variable.toLowerCase() === 'false';
|
|
@@ -82,3 +82,7 @@ const buildLogsJsonVariable = process.env['NG_BUILD_LOGS_JSON'];
|
|
|
82
82
|
exports.useJSONBuildLogs = isPresent(buildLogsJsonVariable) && isEnabled(buildLogsJsonVariable);
|
|
83
83
|
const optimizeChunksVariable = process.env['NG_BUILD_OPTIMIZE_CHUNKS'];
|
|
84
84
|
exports.shouldOptimizeChunks = isPresent(optimizeChunksVariable) && isEnabled(optimizeChunksVariable);
|
|
85
|
+
const hmrComponentStylesVariable = process.env['NG_HMR_CSTYLES'];
|
|
86
|
+
exports.useComponentStyleHmr = isPresent(hmrComponentStylesVariable) && isEnabled(hmrComponentStylesVariable);
|
|
87
|
+
const partialSsrBuildVariable = process.env['NG_BUILD_PARTIAL_SSR'];
|
|
88
|
+
exports.usePartialSsrBuild = isPresent(partialSsrBuildVariable) && isEnabled(partialSsrBuildVariable);
|
|
@@ -10,7 +10,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
10
10
|
exports.normalizeCacheOptions = normalizeCacheOptions;
|
|
11
11
|
const node_path_1 = require("node:path");
|
|
12
12
|
/** Version placeholder is replaced during the build process with actual package version */
|
|
13
|
-
const VERSION = '19.0.0-next.
|
|
13
|
+
const VERSION = '19.0.0-next.8';
|
|
14
14
|
function hasCacheMetadata(value) {
|
|
15
15
|
return (!!value &&
|
|
16
16
|
typeof value === 'object' &&
|
|
@@ -7,7 +7,9 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { NormalizedApplicationBuildOptions } from '../../builders/application/options';
|
|
9
9
|
import type { BuildOutputFile } from '../../tools/esbuild/bundler-context';
|
|
10
|
+
import { PrerenderedRoutesRecord } from '../../tools/esbuild/bundler-execution-result';
|
|
10
11
|
export declare const SERVER_APP_MANIFEST_FILENAME = "angular-app-manifest.mjs";
|
|
12
|
+
export declare const SERVER_APP_ENGINE_MANIFEST_FILENAME = "angular-app-engine-manifest.mjs";
|
|
11
13
|
/**
|
|
12
14
|
* Generates the server manifest for the App Engine environment.
|
|
13
15
|
*
|
|
@@ -19,9 +21,10 @@ export declare const SERVER_APP_MANIFEST_FILENAME = "angular-app-manifest.mjs";
|
|
|
19
21
|
* includes settings for inlining locales and determining the output structure.
|
|
20
22
|
* @param baseHref - The base HREF for the application. This is used to set the base URL
|
|
21
23
|
* for all relative URLs in the application.
|
|
24
|
+
* @param perenderedRoutes - A record mapping static paths to their associated data.
|
|
22
25
|
* @returns A string representing the content of the SSR server manifest for App Engine.
|
|
23
26
|
*/
|
|
24
|
-
export declare function generateAngularServerAppEngineManifest(i18nOptions: NormalizedApplicationBuildOptions['i18nOptions'], baseHref: string | undefined): string;
|
|
27
|
+
export declare function generateAngularServerAppEngineManifest(i18nOptions: NormalizedApplicationBuildOptions['i18nOptions'], baseHref: string | undefined, perenderedRoutes?: PrerenderedRoutesRecord | undefined): string;
|
|
25
28
|
/**
|
|
26
29
|
* Generates the server manifest for the standard Node.js environment.
|
|
27
30
|
*
|
|
@@ -38,7 +41,10 @@ export declare function generateAngularServerAppEngineManifest(i18nOptions: Norm
|
|
|
38
41
|
* in the server-side rendered pages.
|
|
39
42
|
* @param routes - An optional array of route definitions for the application, used for
|
|
40
43
|
* server-side rendering and routing.
|
|
44
|
+
* @param locale - An optional string representing the locale or language code to be used for
|
|
45
|
+
* the application, helping with localization and rendering content specific to the locale.
|
|
46
|
+
*
|
|
41
47
|
* @returns A string representing the content of the SSR server manifest for the Node.js
|
|
42
48
|
* environment.
|
|
43
49
|
*/
|
|
44
|
-
export declare function generateAngularServerAppManifest(additionalHtmlOutputFiles: Map<string, BuildOutputFile>, outputFiles: BuildOutputFile[], inlineCriticalCss: boolean, routes: readonly unknown[] | undefined): string;
|
|
50
|
+
export declare function generateAngularServerAppManifest(additionalHtmlOutputFiles: Map<string, BuildOutputFile>, outputFiles: BuildOutputFile[], inlineCriticalCss: boolean, routes: readonly unknown[] | undefined, locale: string | undefined): string;
|
|
@@ -7,12 +7,40 @@
|
|
|
7
7
|
* found in the LICENSE file at https://angular.dev/license
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.SERVER_APP_MANIFEST_FILENAME = void 0;
|
|
10
|
+
exports.SERVER_APP_ENGINE_MANIFEST_FILENAME = exports.SERVER_APP_MANIFEST_FILENAME = void 0;
|
|
11
11
|
exports.generateAngularServerAppEngineManifest = generateAngularServerAppEngineManifest;
|
|
12
12
|
exports.generateAngularServerAppManifest = generateAngularServerAppManifest;
|
|
13
13
|
const options_1 = require("../../builders/application/options");
|
|
14
14
|
exports.SERVER_APP_MANIFEST_FILENAME = 'angular-app-manifest.mjs';
|
|
15
|
+
exports.SERVER_APP_ENGINE_MANIFEST_FILENAME = 'angular-app-engine-manifest.mjs';
|
|
15
16
|
const MAIN_SERVER_OUTPUT_FILENAME = 'main.server.mjs';
|
|
17
|
+
/**
|
|
18
|
+
* A mapping of unsafe characters to their escaped Unicode equivalents.
|
|
19
|
+
*/
|
|
20
|
+
const UNSAFE_CHAR_MAP = {
|
|
21
|
+
'<': '\\u003C',
|
|
22
|
+
'>': '\\u003E',
|
|
23
|
+
'/': '\\u002F',
|
|
24
|
+
'\\': '\\\\',
|
|
25
|
+
'\b': '\\b',
|
|
26
|
+
'\f': '\\f',
|
|
27
|
+
'\n': '\\n',
|
|
28
|
+
'\r': '\\r',
|
|
29
|
+
'\t': '\\t',
|
|
30
|
+
'\0': '\\0',
|
|
31
|
+
'\u2028': '\\u2028',
|
|
32
|
+
'\u2029': '\\u2029',
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Escapes unsafe characters in a given string by replacing them with
|
|
36
|
+
* their Unicode escape sequences.
|
|
37
|
+
*
|
|
38
|
+
* @param str - The string to be escaped.
|
|
39
|
+
* @returns The escaped string where unsafe characters are replaced.
|
|
40
|
+
*/
|
|
41
|
+
function escapeUnsafeChars(str) {
|
|
42
|
+
return str.replace(/[<>\b\f\n\r\t\0\u2028\u2029]/g, (c) => UNSAFE_CHAR_MAP[c]);
|
|
43
|
+
}
|
|
16
44
|
/**
|
|
17
45
|
* Generates the server manifest for the App Engine environment.
|
|
18
46
|
*
|
|
@@ -24,26 +52,43 @@ const MAIN_SERVER_OUTPUT_FILENAME = 'main.server.mjs';
|
|
|
24
52
|
* includes settings for inlining locales and determining the output structure.
|
|
25
53
|
* @param baseHref - The base HREF for the application. This is used to set the base URL
|
|
26
54
|
* for all relative URLs in the application.
|
|
55
|
+
* @param perenderedRoutes - A record mapping static paths to their associated data.
|
|
27
56
|
* @returns A string representing the content of the SSR server manifest for App Engine.
|
|
28
57
|
*/
|
|
29
|
-
function generateAngularServerAppEngineManifest(i18nOptions, baseHref) {
|
|
58
|
+
function generateAngularServerAppEngineManifest(i18nOptions, baseHref, perenderedRoutes = {}) {
|
|
30
59
|
const entryPointsContent = [];
|
|
31
60
|
if (i18nOptions.shouldInline) {
|
|
32
61
|
for (const locale of i18nOptions.inlineLocales) {
|
|
33
62
|
const importPath = './' + (i18nOptions.flatOutput ? '' : locale + '/') + MAIN_SERVER_OUTPUT_FILENAME;
|
|
34
|
-
|
|
35
|
-
|
|
63
|
+
let localeWithBaseHref = (0, options_1.getLocaleBaseHref)('', i18nOptions, locale) || '/';
|
|
64
|
+
// Remove leading and trailing slashes.
|
|
65
|
+
const start = localeWithBaseHref[0] === '/' ? 1 : 0;
|
|
66
|
+
const end = localeWithBaseHref[localeWithBaseHref.length - 1] === '/' ? -1 : undefined;
|
|
67
|
+
localeWithBaseHref = localeWithBaseHref.slice(start, end);
|
|
68
|
+
entryPointsContent.push(`['${localeWithBaseHref}', () => import('${importPath}')]`);
|
|
36
69
|
}
|
|
37
70
|
}
|
|
38
71
|
else {
|
|
39
|
-
entryPointsContent.push(`['
|
|
72
|
+
entryPointsContent.push(`['', () => import('./${MAIN_SERVER_OUTPUT_FILENAME}')]`);
|
|
73
|
+
}
|
|
74
|
+
const staticHeaders = [];
|
|
75
|
+
for (const [path, { headers }] of Object.entries(perenderedRoutes)) {
|
|
76
|
+
if (!headers) {
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
const headersValues = [];
|
|
80
|
+
for (const [name, value] of Object.entries(headers)) {
|
|
81
|
+
headersValues.push(`['${name}', '${encodeURIComponent(value)}']`);
|
|
82
|
+
}
|
|
83
|
+
staticHeaders.push(`['${path}', [${headersValues.join(', ')}]]`);
|
|
40
84
|
}
|
|
41
85
|
const manifestContent = `
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
86
|
+
export default {
|
|
87
|
+
basePath: '${baseHref ?? '/'}',
|
|
88
|
+
entryPoints: new Map([${entryPointsContent.join(', \n')}]),
|
|
89
|
+
staticPathsHeaders: new Map([${staticHeaders.join(', \n')}]),
|
|
90
|
+
};
|
|
91
|
+
`;
|
|
47
92
|
return manifestContent;
|
|
48
93
|
}
|
|
49
94
|
/**
|
|
@@ -62,16 +107,19 @@ function generateAngularServerAppEngineManifest(i18nOptions, baseHref) {
|
|
|
62
107
|
* in the server-side rendered pages.
|
|
63
108
|
* @param routes - An optional array of route definitions for the application, used for
|
|
64
109
|
* server-side rendering and routing.
|
|
110
|
+
* @param locale - An optional string representing the locale or language code to be used for
|
|
111
|
+
* the application, helping with localization and rendering content specific to the locale.
|
|
112
|
+
*
|
|
65
113
|
* @returns A string representing the content of the SSR server manifest for the Node.js
|
|
66
114
|
* environment.
|
|
67
115
|
*/
|
|
68
|
-
function generateAngularServerAppManifest(additionalHtmlOutputFiles, outputFiles, inlineCriticalCss, routes) {
|
|
116
|
+
function generateAngularServerAppManifest(additionalHtmlOutputFiles, outputFiles, inlineCriticalCss, routes, locale) {
|
|
69
117
|
const serverAssetsContent = [];
|
|
70
118
|
for (const file of [...additionalHtmlOutputFiles.values(), ...outputFiles]) {
|
|
71
119
|
if (file.path === options_1.INDEX_HTML_SERVER ||
|
|
72
120
|
file.path === options_1.INDEX_HTML_CSR ||
|
|
73
121
|
(inlineCriticalCss && file.path.endsWith('.css'))) {
|
|
74
|
-
serverAssetsContent.push(`['${file.path}', async () => ${JSON.stringify(file.text)}]`);
|
|
122
|
+
serverAssetsContent.push(`['${file.path}', async () => ${escapeUnsafeChars(JSON.stringify(file.text))}]`);
|
|
75
123
|
}
|
|
76
124
|
}
|
|
77
125
|
const manifestContent = `
|
|
@@ -80,6 +128,7 @@ export default {
|
|
|
80
128
|
inlineCriticalCss: ${inlineCriticalCss},
|
|
81
129
|
routes: ${JSON.stringify(routes, undefined, 2)},
|
|
82
130
|
assets: new Map([${serverAssetsContent.join(', \n')}]),
|
|
131
|
+
locale: ${locale !== undefined ? `'${locale}'` : undefined},
|
|
83
132
|
};
|
|
84
133
|
`;
|
|
85
134
|
return manifestContent;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.dev/license
|
|
7
|
+
*/
|
|
8
|
+
import type { RenderMode, ɵextractRoutesAndCreateRouteTree } from '@angular/ssr';
|
|
9
|
+
import { ESMInMemoryFileLoaderWorkerData } from './esm-in-memory-loader/loader-hooks';
|
|
10
|
+
type Writeable<T extends readonly unknown[]> = T extends readonly (infer U)[] ? U[] : never;
|
|
11
|
+
export interface RoutesExtractorWorkerData extends ESMInMemoryFileLoaderWorkerData {
|
|
12
|
+
assetFiles: Record</** Destination */ string, /** Source */ string>;
|
|
13
|
+
}
|
|
14
|
+
export type SerializableRouteTreeNode = ReturnType<Awaited<ReturnType<typeof ɵextractRoutesAndCreateRouteTree>>['routeTree']['toObject']>;
|
|
15
|
+
export type WritableSerializableRouteTreeNode = Writeable<SerializableRouteTreeNode>;
|
|
16
|
+
export interface RoutersExtractorWorkerResult {
|
|
17
|
+
serializedRouteTree: SerializableRouteTreeNode;
|
|
18
|
+
errors: string[];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Local copy of `RenderMode` exported from `@angular/ssr`.
|
|
22
|
+
* This constant is needed to handle interop between CommonJS (CJS) and ES Modules (ESM) formats.
|
|
23
|
+
*
|
|
24
|
+
* It maps `RenderMode` enum values to their corresponding numeric identifiers.
|
|
25
|
+
*/
|
|
26
|
+
export declare const RouteRenderMode: Record<keyof typeof RenderMode, RenderMode>;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
5
|
+
*
|
|
6
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
+
* found in the LICENSE file at https://angular.dev/license
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.RouteRenderMode = void 0;
|
|
11
|
+
/**
|
|
12
|
+
* Local copy of `RenderMode` exported from `@angular/ssr`.
|
|
13
|
+
* This constant is needed to handle interop between CommonJS (CJS) and ES Modules (ESM) formats.
|
|
14
|
+
*
|
|
15
|
+
* It maps `RenderMode` enum values to their corresponding numeric identifiers.
|
|
16
|
+
*/
|
|
17
|
+
exports.RouteRenderMode = {
|
|
18
|
+
AppShell: 0,
|
|
19
|
+
Server: 1,
|
|
20
|
+
Client: 2,
|
|
21
|
+
Prerender: 3,
|
|
22
|
+
};
|
|
@@ -5,16 +5,13 @@
|
|
|
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 { NormalizedApplicationBuildOptions } from '../../builders/application/options';
|
|
9
|
+
import { OutputMode } from '../../builders/application/schema';
|
|
8
10
|
import { BuildOutputFile } from '../../tools/esbuild/bundler-context';
|
|
9
11
|
import { BuildOutputAsset } from '../../tools/esbuild/bundler-execution-result';
|
|
10
|
-
import
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
discoverRoutes?: boolean;
|
|
14
|
-
}
|
|
15
|
-
interface AppShellOptions {
|
|
16
|
-
route?: string;
|
|
17
|
-
}
|
|
12
|
+
import { SerializableRouteTreeNode } from './models';
|
|
13
|
+
type PrerenderOptions = NormalizedApplicationBuildOptions['prerenderOptions'];
|
|
14
|
+
type AppShellOptions = NormalizedApplicationBuildOptions['appShellOptions'];
|
|
18
15
|
/**
|
|
19
16
|
* Represents the output of a prerendering process.
|
|
20
17
|
*
|
|
@@ -33,11 +30,10 @@ type PrerenderOutput = Record<string, {
|
|
|
33
30
|
content: string;
|
|
34
31
|
appShellRoute: boolean;
|
|
35
32
|
}>;
|
|
36
|
-
export declare function prerenderPages(workspaceRoot: string, baseHref: string, appShellOptions: AppShellOptions | undefined, prerenderOptions: PrerenderOptions | undefined, outputFiles: Readonly<BuildOutputFile[]>, assets: Readonly<BuildOutputAsset[]>, sourcemap?: boolean, maxThreads?: number
|
|
33
|
+
export declare function prerenderPages(workspaceRoot: string, baseHref: string, appShellOptions: AppShellOptions | undefined, prerenderOptions: PrerenderOptions | undefined, outputFiles: Readonly<BuildOutputFile[]>, assets: Readonly<BuildOutputAsset[]>, outputMode: OutputMode | undefined, sourcemap?: boolean, maxThreads?: number): Promise<{
|
|
37
34
|
output: PrerenderOutput;
|
|
38
35
|
warnings: string[];
|
|
39
36
|
errors: string[];
|
|
40
|
-
prerenderedRoutes: Set<string>;
|
|
41
37
|
serializableRouteTreeNode: SerializableRouteTreeNode;
|
|
42
38
|
}>;
|
|
43
39
|
export {};
|