@angular/build 18.2.0 → 19.0.0-next.0
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 +11 -7
- package/src/tools/esbuild/application-code-bundle.js +1 -5
- package/src/utils/normalize-cache.js +1 -1
- package/src/utils/server-rendering/main-bundle-exports.d.ts +2 -2
- package/src/utils/server-rendering/routes-extractor-worker.js +8 -8
- package/src/utils/routes-extractor/extractor.d.ts +0 -15
- package/src/utils/routes-extractor/extractor.js +0 -97
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular/build",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "19.0.0-next.0",
|
|
4
4
|
"description": "Official build system for Angular",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Angular CLI",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"builders": "builders.json",
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@ampproject/remapping": "2.3.0",
|
|
26
|
-
"@angular-devkit/architect": "0.
|
|
26
|
+
"@angular-devkit/architect": "0.1900.0-next.0",
|
|
27
27
|
"@babel/core": "7.25.2",
|
|
28
28
|
"@babel/helper-annotate-as-pure": "7.24.7",
|
|
29
29
|
"@babel/helper-split-export-declaration": "7.24.7",
|
|
@@ -46,13 +46,14 @@
|
|
|
46
46
|
"sass": "1.77.8",
|
|
47
47
|
"semver": "7.6.3",
|
|
48
48
|
"vite": "5.4.0",
|
|
49
|
-
"watchpack": "2.4.
|
|
49
|
+
"watchpack": "2.4.2"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"@angular/compiler-cli": "^
|
|
53
|
-
"@angular/localize": "^
|
|
54
|
-
"@angular/platform-server": "^
|
|
55
|
-
"@angular/service-worker": "^
|
|
52
|
+
"@angular/compiler-cli": "^19.0.0-next.0",
|
|
53
|
+
"@angular/localize": "^19.0.0-next.0",
|
|
54
|
+
"@angular/platform-server": "^19.0.0-next.0",
|
|
55
|
+
"@angular/service-worker": "^19.0.0-next.0",
|
|
56
|
+
"@angular/ssr": "^19.0.0-next.0",
|
|
56
57
|
"less": "^4.2.0",
|
|
57
58
|
"postcss": "^8.4.0",
|
|
58
59
|
"tailwindcss": "^2.0.0 || ^3.0.0",
|
|
@@ -68,6 +69,9 @@
|
|
|
68
69
|
"@angular/service-worker": {
|
|
69
70
|
"optional": true
|
|
70
71
|
},
|
|
72
|
+
"@angular/ssr": {
|
|
73
|
+
"optional": true
|
|
74
|
+
},
|
|
71
75
|
"less": {
|
|
72
76
|
"optional": true
|
|
73
77
|
},
|
|
@@ -16,7 +16,6 @@ exports.createServerCodeBundleOptions = createServerCodeBundleOptions;
|
|
|
16
16
|
exports.createServerPolyfillBundleOptions = createServerPolyfillBundleOptions;
|
|
17
17
|
const node_assert_1 = __importDefault(require("node:assert"));
|
|
18
18
|
const node_crypto_1 = require("node:crypto");
|
|
19
|
-
const promises_1 = require("node:fs/promises");
|
|
20
19
|
const node_path_1 = require("node:path");
|
|
21
20
|
const environment_options_1 = require("../../utils/environment-options");
|
|
22
21
|
const compiler_plugin_1 = require("./angular/compiler-plugin");
|
|
@@ -177,10 +176,7 @@ function createServerCodeBundleOptions(options, target, sourceFileCache) {
|
|
|
177
176
|
contents.push(`export { ɵresetCompiledComponents } from '@angular/core';`);
|
|
178
177
|
}
|
|
179
178
|
if (prerenderOptions?.discoverRoutes) {
|
|
180
|
-
|
|
181
|
-
const routesExtractorCode = await (0, promises_1.readFile)((0, node_path_1.join)(__dirname, '../../utils/routes-extractor/extractor.js'), 'utf-8');
|
|
182
|
-
// Remove source map URL comments from the code if a sourcemap is present as this will not match the file.
|
|
183
|
-
contents.push(routesExtractorCode.replace(/^\/\/# sourceMappingURL=[^\r\n]*/gm, ''));
|
|
179
|
+
contents.push(`export { ɵgetRoutesFromAngularRouterConfig } from '@angular/ssr';`);
|
|
184
180
|
}
|
|
185
181
|
return {
|
|
186
182
|
contents: contents.join('\n'),
|
|
@@ -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 = '
|
|
13
|
+
const VERSION = '19.0.0-next.0';
|
|
14
14
|
function hasCacheMetadata(value) {
|
|
15
15
|
return (!!value &&
|
|
16
16
|
typeof value === 'object' &&
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import type { ApplicationRef, Type, ɵConsole } from '@angular/core';
|
|
9
9
|
import type { renderApplication, renderModule, ɵSERVER_CONTEXT } from '@angular/platform-server';
|
|
10
|
-
import type {
|
|
10
|
+
import type { ɵgetRoutesFromAngularRouterConfig } from '@angular/ssr';
|
|
11
11
|
export interface MainServerBundleExports {
|
|
12
12
|
/** Standalone application bootstrapping function. */
|
|
13
13
|
default: (() => Promise<ApplicationRef>) | Type<unknown>;
|
|
@@ -20,7 +20,7 @@ export interface RenderUtilsServerBundleExports {
|
|
|
20
20
|
/** Method to render a standalone application. */
|
|
21
21
|
renderApplication: typeof renderApplication;
|
|
22
22
|
/** Method to extract routes from the router config. */
|
|
23
|
-
|
|
23
|
+
ɵgetRoutesFromAngularRouterConfig: typeof ɵgetRoutesFromAngularRouterConfig;
|
|
24
24
|
ɵresetCompiledComponents?: () => void;
|
|
25
25
|
/** Angular Console token/class. */
|
|
26
26
|
ɵConsole: typeof ɵConsole;
|
|
@@ -16,22 +16,22 @@ const load_esm_from_memory_1 = require("./load-esm-from-memory");
|
|
|
16
16
|
const { document, verbose } = node_worker_threads_1.workerData;
|
|
17
17
|
/** Renders an application based on a provided options. */
|
|
18
18
|
async function extractRoutes() {
|
|
19
|
-
const {
|
|
19
|
+
const { ɵgetRoutesFromAngularRouterConfig: getRoutesFromAngularRouterConfig } = await (0, load_esm_from_memory_1.loadEsmModuleFromMemory)('./render-utils.server.mjs');
|
|
20
20
|
const { default: bootstrapAppFnOrModule } = await (0, load_esm_from_memory_1.loadEsmModuleFromMemory)('./main.server.mjs');
|
|
21
21
|
const skippedRedirects = [];
|
|
22
22
|
const skippedOthers = [];
|
|
23
23
|
const routes = [];
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
continue;
|
|
28
|
-
}
|
|
29
|
-
if (redirect) {
|
|
24
|
+
const { routes: extractRoutes } = await getRoutesFromAngularRouterConfig(bootstrapAppFnOrModule, document, new URL('http://localhost'));
|
|
25
|
+
for (const { route, redirectTo } of extractRoutes) {
|
|
26
|
+
if (redirectTo !== undefined) {
|
|
30
27
|
skippedRedirects.push(route);
|
|
31
28
|
}
|
|
32
|
-
else {
|
|
29
|
+
else if (/[:*]/.test(route)) {
|
|
33
30
|
skippedOthers.push(route);
|
|
34
31
|
}
|
|
32
|
+
else {
|
|
33
|
+
routes.push(route);
|
|
34
|
+
}
|
|
35
35
|
}
|
|
36
36
|
if (!verbose) {
|
|
37
37
|
return { routes };
|
|
@@ -1,15 +0,0 @@
|
|
|
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 { ApplicationRef, Type } from '@angular/core';
|
|
9
|
-
interface RouterResult {
|
|
10
|
-
route: string;
|
|
11
|
-
success: boolean;
|
|
12
|
-
redirect: boolean;
|
|
13
|
-
}
|
|
14
|
-
export declare function extractRoutes(bootstrapAppFnOrModule: (() => Promise<ApplicationRef>) | Type<unknown>, document: string): AsyncIterableIterator<RouterResult>;
|
|
15
|
-
export {};
|
|
@@ -1,97 +0,0 @@
|
|
|
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 { ApplicationRef, Compiler, createPlatformFactory, platformCore, ɵwhenStable as whenStable, ɵConsole, } from '@angular/core';
|
|
9
|
-
import { INITIAL_CONFIG, ɵINTERNAL_SERVER_PLATFORM_PROVIDERS as INTERNAL_SERVER_PLATFORM_PROVIDERS, } from '@angular/platform-server';
|
|
10
|
-
import { Router, ɵloadChildren as loadChildrenHelper } from '@angular/router';
|
|
11
|
-
async function* getRoutesFromRouterConfig(routes, compiler, parentInjector, parentRoute = '') {
|
|
12
|
-
for (const route of routes) {
|
|
13
|
-
const { path, redirectTo, loadChildren, children } = route;
|
|
14
|
-
if (path === undefined) {
|
|
15
|
-
continue;
|
|
16
|
-
}
|
|
17
|
-
const currentRoutePath = buildRoutePath(parentRoute, path);
|
|
18
|
-
if (redirectTo !== undefined) {
|
|
19
|
-
// TODO: handle `redirectTo`.
|
|
20
|
-
yield { route: currentRoutePath, success: false, redirect: true };
|
|
21
|
-
continue;
|
|
22
|
-
}
|
|
23
|
-
if (/[:*]/.test(path)) {
|
|
24
|
-
// TODO: handle parameterized routes population.
|
|
25
|
-
yield { route: currentRoutePath, success: false, redirect: false };
|
|
26
|
-
continue;
|
|
27
|
-
}
|
|
28
|
-
yield { route: currentRoutePath, success: true, redirect: false };
|
|
29
|
-
if (children?.length) {
|
|
30
|
-
yield* getRoutesFromRouterConfig(children, compiler, parentInjector, currentRoutePath);
|
|
31
|
-
}
|
|
32
|
-
if (loadChildren) {
|
|
33
|
-
const loadedChildRoutes = await loadChildrenHelper(route, compiler, parentInjector).toPromise();
|
|
34
|
-
if (loadedChildRoutes) {
|
|
35
|
-
const { routes: childRoutes, injector = parentInjector } = loadedChildRoutes;
|
|
36
|
-
yield* getRoutesFromRouterConfig(childRoutes, compiler, injector, currentRoutePath);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
export async function* extractRoutes(bootstrapAppFnOrModule, document) {
|
|
42
|
-
const platformRef = createPlatformFactory(platformCore, 'server', [
|
|
43
|
-
{
|
|
44
|
-
provide: INITIAL_CONFIG,
|
|
45
|
-
useValue: { document, url: '' },
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
provide: ɵConsole,
|
|
49
|
-
/** An Angular Console Provider that does not print a set of predefined logs. */
|
|
50
|
-
useFactory: () => {
|
|
51
|
-
class Console extends ɵConsole {
|
|
52
|
-
ignoredLogs = new Set(['Angular is running in development mode.']);
|
|
53
|
-
log(message) {
|
|
54
|
-
if (!this.ignoredLogs.has(message)) {
|
|
55
|
-
super.log(message);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
return new Console();
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
...INTERNAL_SERVER_PLATFORM_PROVIDERS,
|
|
63
|
-
])();
|
|
64
|
-
try {
|
|
65
|
-
let applicationRef;
|
|
66
|
-
if (isBootstrapFn(bootstrapAppFnOrModule)) {
|
|
67
|
-
applicationRef = await bootstrapAppFnOrModule();
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
const moduleRef = await platformRef.bootstrapModule(bootstrapAppFnOrModule);
|
|
71
|
-
applicationRef = moduleRef.injector.get(ApplicationRef);
|
|
72
|
-
}
|
|
73
|
-
// Wait until the application is stable.
|
|
74
|
-
await whenStable(applicationRef);
|
|
75
|
-
const injector = applicationRef.injector;
|
|
76
|
-
const router = injector.get(Router);
|
|
77
|
-
if (router.config.length === 0) {
|
|
78
|
-
// In case there are no routes available
|
|
79
|
-
yield { route: '', success: true, redirect: false };
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
const compiler = injector.get(Compiler);
|
|
83
|
-
// Extract all the routes from the config.
|
|
84
|
-
yield* getRoutesFromRouterConfig(router.config, compiler, injector);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
finally {
|
|
88
|
-
platformRef.destroy();
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
function isBootstrapFn(value) {
|
|
92
|
-
// We can differentiate between a module and a bootstrap function by reading compiler-generated `ɵmod` static property:
|
|
93
|
-
return typeof value === 'function' && !('ɵmod' in value);
|
|
94
|
-
}
|
|
95
|
-
function buildRoutePath(...routeParts) {
|
|
96
|
-
return routeParts.filter(Boolean).join('/');
|
|
97
|
-
}
|