@angular/build 18.2.1 → 19.0.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 +16 -12
- package/src/tools/angular/compilation/jit-compilation.js +2 -1
- package/src/tools/esbuild/angular/compiler-plugin.js +3 -1
- package/src/tools/esbuild/application-code-bundle.js +1 -30
- 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.1",
|
|
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.1",
|
|
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",
|
|
@@ -32,27 +32,28 @@
|
|
|
32
32
|
"@vitejs/plugin-basic-ssl": "1.1.0",
|
|
33
33
|
"browserslist": "^4.23.0",
|
|
34
34
|
"critters": "0.0.24",
|
|
35
|
-
"esbuild": "0.23.
|
|
35
|
+
"esbuild": "0.23.1",
|
|
36
36
|
"fast-glob": "3.3.2",
|
|
37
37
|
"https-proxy-agent": "7.0.5",
|
|
38
38
|
"listr2": "8.2.4",
|
|
39
|
-
"lmdb": "3.0.
|
|
39
|
+
"lmdb": "3.0.14",
|
|
40
40
|
"magic-string": "0.30.11",
|
|
41
41
|
"mrmime": "2.0.0",
|
|
42
42
|
"parse5-html-rewriting-stream": "7.0.0",
|
|
43
43
|
"picomatch": "4.0.2",
|
|
44
44
|
"piscina": "4.6.1",
|
|
45
|
-
"rollup": "4.
|
|
46
|
-
"sass": "1.77.
|
|
45
|
+
"rollup": "4.21.0",
|
|
46
|
+
"sass": "1.77.8",
|
|
47
47
|
"semver": "7.6.3",
|
|
48
|
-
"vite": "5.4.
|
|
49
|
-
"watchpack": "2.4.
|
|
48
|
+
"vite": "5.4.2",
|
|
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.1",
|
|
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
|
},
|
|
@@ -13,6 +13,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
13
13
|
exports.JitCompilation = void 0;
|
|
14
14
|
const node_assert_1 = __importDefault(require("node:assert"));
|
|
15
15
|
const typescript_1 = __importDefault(require("typescript"));
|
|
16
|
+
const load_esm_1 = require("../../../utils/load-esm");
|
|
16
17
|
const profiling_1 = require("../../esbuild/profiling");
|
|
17
18
|
const angular_host_1 = require("../angular-host");
|
|
18
19
|
const jit_resource_transformer_1 = require("../transformers/jit-resource-transformer");
|
|
@@ -36,7 +37,7 @@ class JitCompilation extends angular_compilation_1.AngularCompilation {
|
|
|
36
37
|
#state;
|
|
37
38
|
async initialize(tsconfig, hostOptions, compilerOptionsTransformer) {
|
|
38
39
|
// Dynamically load the Angular compiler CLI package
|
|
39
|
-
const { constructorParametersDownlevelTransform } = await
|
|
40
|
+
const { constructorParametersDownlevelTransform } = await (0, load_esm_1.loadEsmModule)('@angular/compiler-cli/private/tooling');
|
|
40
41
|
// Load the compiler configuration and transform as needed
|
|
41
42
|
const { options: originalCompilerOptions, rootNames, errors: configurationDiagnostics, } = await this.loadConfiguration(tsconfig);
|
|
42
43
|
const compilerOptions = compilerOptionsTransformer?.(originalCompilerOptions) ?? originalCompilerOptions;
|
|
@@ -145,7 +145,9 @@ function createCompilerPlugin(pluginOptions, styleOptions) {
|
|
|
145
145
|
stylesheetResult = await stylesheetBundler.bundleFile(stylesheetFile);
|
|
146
146
|
}
|
|
147
147
|
else {
|
|
148
|
-
stylesheetResult = await stylesheetBundler.bundleInline(data, containingFile,
|
|
148
|
+
stylesheetResult = await stylesheetBundler.bundleInline(data, containingFile,
|
|
149
|
+
// Inline stylesheets from a template style element are always CSS
|
|
150
|
+
containingFile.endsWith('.html') ? 'css' : styleOptions.inlineStyleLanguage);
|
|
149
151
|
}
|
|
150
152
|
const { contents, outputFiles, metafile, referencedFiles, errors, warnings } = stylesheetResult;
|
|
151
153
|
if (errors) {
|
|
@@ -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'),
|
|
@@ -326,12 +322,10 @@ function getEsBuildCommonPolyfillsOptions(options, namespace, tryToResolvePolyfi
|
|
|
326
322
|
namespace,
|
|
327
323
|
cache: sourceFileCache?.loadResultCache,
|
|
328
324
|
loadContent: async (_, build) => {
|
|
329
|
-
let hasLocalizePolyfill = false;
|
|
330
325
|
let polyfillPaths = polyfills;
|
|
331
326
|
let warnings;
|
|
332
327
|
if (tryToResolvePolyfillsAsRelative) {
|
|
333
328
|
polyfillPaths = await Promise.all(polyfills.map(async (path) => {
|
|
334
|
-
hasLocalizePolyfill ||= path.startsWith('@angular/localize');
|
|
335
329
|
if (path.startsWith('zone.js') || !(0, node_path_1.extname)(path)) {
|
|
336
330
|
return path;
|
|
337
331
|
}
|
|
@@ -343,29 +337,6 @@ function getEsBuildCommonPolyfillsOptions(options, namespace, tryToResolvePolyfi
|
|
|
343
337
|
return result.path ? potentialPathRelative : path;
|
|
344
338
|
}));
|
|
345
339
|
}
|
|
346
|
-
else {
|
|
347
|
-
hasLocalizePolyfill = polyfills.some((p) => p.startsWith('@angular/localize'));
|
|
348
|
-
}
|
|
349
|
-
// Add localize polyfill if needed.
|
|
350
|
-
// TODO: remove in version 19 or later.
|
|
351
|
-
if (!i18nOptions.shouldInline && !hasLocalizePolyfill) {
|
|
352
|
-
const result = await build.resolve('@angular/localize', {
|
|
353
|
-
kind: 'import-statement',
|
|
354
|
-
resolveDir: workspaceRoot,
|
|
355
|
-
});
|
|
356
|
-
if (result.path) {
|
|
357
|
-
polyfillPaths.push('@angular/localize/init');
|
|
358
|
-
(warnings ??= []).push({
|
|
359
|
-
text: 'Polyfill for "@angular/localize/init" was added automatically.',
|
|
360
|
-
notes: [
|
|
361
|
-
{
|
|
362
|
-
text: 'In the future, this functionality will be removed. ' +
|
|
363
|
-
'Please add this polyfill in the "polyfills" section of your "angular.json" instead.',
|
|
364
|
-
},
|
|
365
|
-
],
|
|
366
|
-
});
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
340
|
// Generate module contents with an import statement per defined polyfill
|
|
370
341
|
let contents = polyfillPaths
|
|
371
342
|
.map((file) => `import '${file.replace(/\\/g, '/')}';`)
|
|
@@ -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.1';
|
|
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
|
-
}
|