@angular/build 20.0.0-next.9 → 20.0.0-rc.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular/build",
3
- "version": "20.0.0-next.9",
3
+ "version": "20.0.0-rc.0",
4
4
  "description": "Official build system for Angular",
5
5
  "keywords": [
6
6
  "Angular CLI",
@@ -23,34 +23,34 @@
23
23
  "builders": "builders.json",
24
24
  "dependencies": {
25
25
  "@ampproject/remapping": "2.3.0",
26
- "@angular-devkit/architect": "0.2000.0-next.9",
27
- "@babel/core": "7.26.10",
28
- "@babel/helper-annotate-as-pure": "7.25.9",
26
+ "@angular-devkit/architect": "0.2000.0-rc.0",
27
+ "@babel/core": "7.27.1",
28
+ "@babel/helper-annotate-as-pure": "7.27.1",
29
29
  "@babel/helper-split-export-declaration": "7.24.7",
30
30
  "@inquirer/confirm": "5.1.9",
31
31
  "@vitejs/plugin-basic-ssl": "2.0.0",
32
32
  "beasties": "0.3.3",
33
33
  "browserslist": "^4.23.0",
34
- "esbuild": "0.25.3",
34
+ "esbuild": "0.25.4",
35
35
  "https-proxy-agent": "7.0.6",
36
36
  "istanbul-lib-instrument": "6.0.3",
37
37
  "jsonc-parser": "3.3.1",
38
- "listr2": "8.3.2",
38
+ "listr2": "8.3.3",
39
39
  "magic-string": "0.30.17",
40
40
  "mrmime": "2.0.1",
41
41
  "parse5-html-rewriting-stream": "7.1.0",
42
42
  "picomatch": "4.0.2",
43
- "piscina": "4.9.2",
44
- "rollup": "4.40.1",
43
+ "piscina": "5.0.0",
44
+ "rollup": "4.40.2",
45
45
  "sass": "1.87.0",
46
46
  "semver": "7.7.1",
47
47
  "source-map-support": "0.5.21",
48
48
  "tinyglobby": "0.2.13",
49
- "vite": "6.3.4",
49
+ "vite": "6.3.5",
50
50
  "watchpack": "2.4.2"
51
51
  },
52
52
  "optionalDependencies": {
53
- "lmdb": "3.2.6"
53
+ "lmdb": "3.3.0"
54
54
  },
55
55
  "peerDependencies": {
56
56
  "@angular/core": "^20.0.0 || ^20.0.0-next.0",
@@ -60,7 +60,7 @@
60
60
  "@angular/platform-browser": "^20.0.0 || ^20.0.0-next.0",
61
61
  "@angular/platform-server": "^20.0.0 || ^20.0.0-next.0",
62
62
  "@angular/service-worker": "^20.0.0 || ^20.0.0-next.0",
63
- "@angular/ssr": "^20.0.0-next.9",
63
+ "@angular/ssr": "^20.0.0-rc.0",
64
64
  "karma": "^6.4.0",
65
65
  "less": "^4.2.0",
66
66
  "ng-packagr": "^20.0.0 || ^20.0.0-next.0",
@@ -114,7 +114,7 @@
114
114
  },
115
115
  "packageManager": "pnpm@9.15.6",
116
116
  "engines": {
117
- "node": "^20.11.1 || >=22.11.0",
117
+ "node": "^20.11.1 || ^22.11.0 || >=24.0.0",
118
118
  "npm": "^6.11.0 || ^7.5.6 || >=8.0.0",
119
119
  "yarn": ">= 1.13.0"
120
120
  },
@@ -229,8 +229,9 @@ async function executeBuild(options, context, rebuildState) {
229
229
  const result = await (0, execute_post_bundle_1.executePostBundleSteps)(metafile, options, executionResult.outputFiles, executionResult.assetFiles, initialFiles,
230
230
  // Set lang attribute to the defined source locale if present
231
231
  i18nOptions.hasDefinedSourceLocale ? i18nOptions.sourceLocale : undefined);
232
- executionResult.addErrors(result.errors);
233
- executionResult.addWarnings(result.warnings);
232
+ // Deduplicate and add errors and warnings
233
+ executionResult.addErrors([...new Set(result.errors)]);
234
+ executionResult.addWarnings([...new Set(result.warnings)]);
234
235
  executionResult.addPrerenderedRoutes(result.prerenderedRoutes);
235
236
  executionResult.outputFiles.push(...result.additionalOutputFiles);
236
237
  executionResult.assetFiles.push(...result.additionalAssets);
@@ -92,6 +92,21 @@ async function inlineI18n(metafile, options, executionResult, initialFiles) {
92
92
  if (!i18nOptions.flatOutput) {
93
93
  executionResult.assetFiles = updatedAssetFiles;
94
94
  }
95
+ // Inline any template updates if present
96
+ if (executionResult.templateUpdates?.size) {
97
+ // The development server only allows a single locale but issue a warning if used programmatically (experimental)
98
+ // with multiple locales and template HMR.
99
+ if (i18nOptions.inlineLocales.size > 1) {
100
+ inlineResult.warnings.push(`Component HMR updates can only be inlined with a single locale. The first locale will be used.`);
101
+ }
102
+ const firstLocale = [...i18nOptions.inlineLocales][0];
103
+ for (const [id, content] of executionResult.templateUpdates) {
104
+ const templateUpdateResult = await inliner.inlineTemplateUpdate(firstLocale, i18nOptions.locales[firstLocale].translation, content, id);
105
+ executionResult.templateUpdates.set(id, templateUpdateResult.code);
106
+ inlineResult.errors.push(...templateUpdateResult.errors);
107
+ inlineResult.warnings.push(...templateUpdateResult.warnings);
108
+ }
109
+ }
95
110
  return inlineResult;
96
111
  }
97
112
  /**
@@ -69,7 +69,7 @@ async function normalizeOptions(context, projectName, options, extensions) {
69
69
  if (options.forceI18nFlatOutput) {
70
70
  i18nOptions.flatOutput = true;
71
71
  }
72
- const entryPoints = normalizeEntryPoints(workspaceRoot, options.browser, options.entryPoints);
72
+ const entryPoints = normalizeEntryPoints(workspaceRoot, projectSourceRoot, options.browser, options.entryPoints);
73
73
  const tsconfig = node_path_1.default.join(workspaceRoot, options.tsConfig);
74
74
  const optimizationOptions = (0, utils_1.normalizeOptimization)(options.optimization);
75
75
  const sourcemapOptions = (0, utils_1.normalizeSourceMaps)(options.sourceMap ?? false);
@@ -355,23 +355,22 @@ async function getTailwindConfig(searchDirectories, workspaceRoot, context) {
355
355
  * @param entryPoints Set of entry points to use if provided.
356
356
  * @returns An object mapping entry point names to their file paths.
357
357
  */
358
- function normalizeEntryPoints(workspaceRoot, browser, entryPoints = new Set()) {
358
+ function normalizeEntryPoints(workspaceRoot, projectSourceRoot, browser, entryPoints) {
359
359
  if (browser === '') {
360
360
  throw new Error('`browser` option cannot be an empty string.');
361
361
  }
362
362
  // `browser` and `entryPoints` are mutually exclusive.
363
- if (browser && entryPoints.size > 0) {
363
+ if (browser && entryPoints) {
364
364
  throw new Error('Only one of `browser` or `entryPoints` may be provided.');
365
365
  }
366
- if (!browser && entryPoints.size === 0) {
367
- // Schema should normally reject this case, but programmatic usages of the builder might make this mistake.
368
- throw new Error('Either `browser` or at least one `entryPoints` value must be provided.');
369
- }
370
- // Schema types force `browser` to always be provided, but it may be omitted when the builder is invoked programmatically.
371
366
  if (browser) {
372
367
  // Use `browser` alone.
373
368
  return { 'main': node_path_1.default.join(workspaceRoot, browser) };
374
369
  }
370
+ else if (!entryPoints) {
371
+ // Default browser entry if no explicit entry points
372
+ return { 'main': node_path_1.default.join(projectSourceRoot, 'main.ts') };
373
+ }
375
374
  else if (entryPoints instanceof Map) {
376
375
  return Object.fromEntries(Array.from(entryPoints.entries(), ([name, entryPoint]) => {
377
376
  // Get the full file path to a relative entry point input. Leave bare specifiers alone so they are resolved as modules.
@@ -27,7 +27,7 @@ export type Schema = {
27
27
  * The full path for the browser entry point to the application, relative to the current
28
28
  * workspace.
29
29
  */
30
- browser: string;
30
+ browser?: string;
31
31
  /**
32
32
  * Budget thresholds to ensure parts of your application stay within boundaries which you
33
33
  * set.
@@ -616,7 +616,7 @@
616
616
  }
617
617
  },
618
618
  "additionalProperties": false,
619
- "required": ["browser", "tsConfig"],
619
+ "required": ["tsConfig"],
620
620
  "definitions": {
621
621
  "assetPattern": {
622
622
  "oneOf": [
@@ -88,7 +88,7 @@ class AngularAssetsMiddleware {
88
88
  }
89
89
  switch (file.origin) {
90
90
  case 'disk':
91
- this.serveFile(file.inputPath, undefined, res);
91
+ this.serveFile(file.inputPath, undefined, res, undefined, undefined, /* doNotCache */ true);
92
92
  break;
93
93
  case 'memory':
94
94
  // Include pathname to help with Content-Type headers.
@@ -89,8 +89,14 @@ async function* execute(options, context, extensions = {}) {
89
89
  loadContent: async () => {
90
90
  const contents = [
91
91
  // Initialize the Angular testing environment
92
- `import { getTestBed } from '@angular/core/testing';`,
92
+ `import { getTestBed, ɵgetCleanupHook as getCleanupHook } from '@angular/core/testing';`,
93
93
  `import { BrowserTestingModule, platformBrowserTesting } from '@angular/platform-browser/testing';`,
94
+ `import { beforeEach, afterEach } from 'vitest';`,
95
+ '',
96
+ // Same as https://github.com/angular/angular/blob/05a03d3f975771bb59c7eefd37c01fa127ee2229/packages/core/testing/src/test_hooks.ts#L21-L29
97
+ `beforeEach(getCleanupHook(false));`,
98
+ `afterEach(getCleanupHook(true));`,
99
+ '',
94
100
  `getTestBed().initTestEnvironment(BrowserTestingModule, platformBrowserTesting(), {`,
95
101
  ` errorOnUnknownElements: true,`,
96
102
  ` errorOnUnknownProperties: true,`,
@@ -144,6 +150,7 @@ async function* execute(options, context, extensions = {}) {
144
150
  environment: browser ? 'node' : 'jsdom',
145
151
  watch: normalizedOptions.watch,
146
152
  browser,
153
+ reporters: normalizedOptions.reporters ?? ['default'],
147
154
  coverage: {
148
155
  enabled: normalizedOptions.codeCoverage,
149
156
  exclude: normalizedOptions.codeCoverageExclude,
@@ -121,10 +121,7 @@ class AotCompilation extends angular_compilation_1.AngularCompilation {
121
121
  const updateId = encodeURIComponent(`${host.getCanonicalFileName(relativePath)}@${node.name?.text}`);
122
122
  const updateText = angularCompiler.emitHmrUpdateModule(node);
123
123
  // If compiler cannot generate an update for the component, prevent template updates.
124
- // Also prevent template updates if $localize is directly present which also currently
125
- // prevents a template update at runtime.
126
- // TODO: Support localized template update modules and remove this check.
127
- if (updateText === null || updateText.includes('$localize')) {
124
+ if (updateText === null) {
128
125
  // Build is needed if a template cannot be updated
129
126
  templateUpdates = undefined;
130
127
  break;
@@ -13,6 +13,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
13
13
  exports.BundlerContext = exports.BuildOutputFileType = void 0;
14
14
  const esbuild_1 = require("esbuild");
15
15
  const node_assert_1 = __importDefault(require("node:assert"));
16
+ const node_module_1 = require("node:module");
16
17
  const node_path_1 = require("node:path");
17
18
  const load_result_cache_1 = require("./load-result-cache");
18
19
  const utils_1 = require("./utils");
@@ -198,10 +199,11 @@ class BundlerContext {
198
199
  if (this.incremental) {
199
200
  // Add input files except virtual angular files which do not exist on disk
200
201
  for (const input of Object.keys(result.metafile.inputs)) {
201
- if (!isInternalAngularFile(input)) {
202
- // input file paths are always relative to the workspace root
203
- this.watchFiles.add((0, node_path_1.join)(this.workspaceRoot, input));
202
+ if (isInternalAngularFile(input) || isInternalBundlerFile(input)) {
203
+ continue;
204
204
  }
205
+ // Input file paths are always relative to the workspace root
206
+ this.watchFiles.add((0, node_path_1.join)(this.workspaceRoot, input));
205
207
  }
206
208
  }
207
209
  // Return if the build encountered any errors
@@ -380,3 +382,16 @@ exports.BundlerContext = BundlerContext;
380
382
  function isInternalAngularFile(file) {
381
383
  return file.startsWith('angular:');
382
384
  }
385
+ function isInternalBundlerFile(file) {
386
+ // Bundler virtual files such as "<define:???>" or "<runtime>"
387
+ if (file[0] === '<' && file.at(-1) === '>') {
388
+ return true;
389
+ }
390
+ const DISABLED_BUILTIN = '(disabled):';
391
+ // Disabled node builtins such as "/some/path/(disabled):fs"
392
+ const disabledIndex = file.indexOf(DISABLED_BUILTIN);
393
+ if (disabledIndex >= 0) {
394
+ return node_module_1.builtinModules.includes(file.slice(disabledIndex + DISABLED_BUILTIN.length));
395
+ }
396
+ return false;
397
+ }
@@ -8,7 +8,7 @@
8
8
  /**
9
9
  * The options passed to the inliner for each file request
10
10
  */
11
- interface InlineRequest {
11
+ interface InlineFileRequest {
12
12
  /**
13
13
  * The filename that should be processed. The data for the file is provided to the Worker
14
14
  * during Worker initialization.
@@ -23,14 +23,35 @@ interface InlineRequest {
23
23
  */
24
24
  translation?: Record<string, unknown>;
25
25
  }
26
+ /**
27
+ * The options passed to the inliner for each code request
28
+ */
29
+ interface InlineCodeRequest {
30
+ /**
31
+ * The code that should be processed.
32
+ */
33
+ code: string;
34
+ /**
35
+ * The filename to use in error and warning messages for the provided code.
36
+ */
37
+ filename: string;
38
+ /**
39
+ * The locale specifier that should be used during the inlining process of the file.
40
+ */
41
+ locale: string;
42
+ /**
43
+ * The translation messages for the locale that should be used during the inlining process of the file.
44
+ */
45
+ translation?: Record<string, unknown>;
46
+ }
26
47
  /**
27
48
  * Inlines the provided locale and translation into a JavaScript file that contains `$localize` usage.
28
49
  * This function is the main entry for the Worker's action that is called by the worker pool.
29
50
  *
30
51
  * @param request An InlineRequest object representing the options for inlining
31
- * @returns An array containing the inlined file and optional map content.
52
+ * @returns An object containing the inlined file and optional map content.
32
53
  */
33
- export default function inlineLocale(request: InlineRequest): Promise<{
54
+ export default function inlineFile(request: InlineFileRequest): Promise<{
34
55
  file: string;
35
56
  code: string;
36
57
  map: string | undefined;
@@ -39,4 +60,18 @@ export default function inlineLocale(request: InlineRequest): Promise<{
39
60
  message: string;
40
61
  }[];
41
62
  }>;
63
+ /**
64
+ * Inlines the provided locale and translation into JavaScript code that contains `$localize` usage.
65
+ * This function is a secondary entry primarily for use with component HMR update modules.
66
+ *
67
+ * @param request An InlineRequest object representing the options for inlining
68
+ * @returns An object containing the inlined code.
69
+ */
70
+ export declare function inlineCode(request: InlineCodeRequest): Promise<{
71
+ output: string;
72
+ messages: {
73
+ type: "warning" | "error";
74
+ message: string;
75
+ }[];
76
+ }>;
42
77
  export {};
@@ -10,7 +10,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
10
10
  return (mod && mod.__esModule) ? mod : { "default": mod };
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.default = inlineLocale;
13
+ exports.default = inlineFile;
14
+ exports.inlineCode = inlineCode;
14
15
  const remapping_1 = __importDefault(require("@ampproject/remapping"));
15
16
  const core_1 = require("@babel/core");
16
17
  const node_assert_1 = __importDefault(require("node:assert"));
@@ -25,9 +26,9 @@ const { files, missingTranslation, shouldOptimize } = (node_worker_threads_1.wor
25
26
  * This function is the main entry for the Worker's action that is called by the worker pool.
26
27
  *
27
28
  * @param request An InlineRequest object representing the options for inlining
28
- * @returns An array containing the inlined file and optional map content.
29
+ * @returns An object containing the inlined file and optional map content.
29
30
  */
30
- async function inlineLocale(request) {
31
+ async function inlineFile(request) {
31
32
  const data = files.get(request.filename);
32
33
  (0, node_assert_1.default)(data !== undefined, `Invalid inline request for file '${request.filename}'.`);
33
34
  const code = await data.text();
@@ -40,6 +41,20 @@ async function inlineLocale(request) {
40
41
  messages: result.diagnostics.messages,
41
42
  };
42
43
  }
44
+ /**
45
+ * Inlines the provided locale and translation into JavaScript code that contains `$localize` usage.
46
+ * This function is a secondary entry primarily for use with component HMR update modules.
47
+ *
48
+ * @param request An InlineRequest object representing the options for inlining
49
+ * @returns An object containing the inlined code.
50
+ */
51
+ async function inlineCode(request) {
52
+ const result = await transformWithBabel(request.code, undefined, request);
53
+ return {
54
+ output: result.code,
55
+ messages: result.diagnostics.messages,
56
+ };
57
+ }
43
58
  /**
44
59
  * Cached instance of the `@angular/localize/tools` module.
45
60
  * This is used to remove the need to repeatedly import the module per file translation.
@@ -38,6 +38,11 @@ export declare class I18nInliner {
38
38
  errors: string[];
39
39
  warnings: string[];
40
40
  }>;
41
+ inlineTemplateUpdate(locale: string, translation: Record<string, unknown> | undefined, templateCode: string, templateId: string): Promise<{
42
+ code: string;
43
+ errors: string[];
44
+ warnings: string[];
45
+ }>;
41
46
  /**
42
47
  * Stops all active transformation tasks and shuts down all workers.
43
48
  * @returns A void promise that resolves when closing is complete.
@@ -201,6 +201,32 @@ class I18nInliner {
201
201
  warnings,
202
202
  };
203
203
  }
204
+ async inlineTemplateUpdate(locale, translation, templateCode, templateId) {
205
+ const hasLocalize = templateCode.includes(LOCALIZE_KEYWORD);
206
+ if (!hasLocalize) {
207
+ return {
208
+ code: templateCode,
209
+ errors: [],
210
+ warnings: [],
211
+ };
212
+ }
213
+ const { output, messages } = await this.#workerPool.run({ code: templateCode, filename: templateId, locale, translation }, { name: 'inlineCode' });
214
+ const errors = [];
215
+ const warnings = [];
216
+ for (const message of messages) {
217
+ if (message.type === 'error') {
218
+ errors.push(message.message);
219
+ }
220
+ else {
221
+ warnings.push(message.message);
222
+ }
223
+ }
224
+ return {
225
+ code: output,
226
+ errors,
227
+ warnings,
228
+ };
229
+ }
204
230
  /**
205
231
  * Stops all active transformation tasks and shuts down all workers.
206
232
  * @returns A void promise that resolves when closing is complete.
@@ -315,7 +315,7 @@ function transformSupportedBrowsersToTargets(supportedBrowsers) {
315
315
  }
316
316
  return transformed;
317
317
  }
318
- const SUPPORTED_NODE_VERSIONS = '^20.11.1 || >=22.11.0';
318
+ const SUPPORTED_NODE_VERSIONS = '^20.11.1 || ^22.11.0 || >=24.0.0';
319
319
  /**
320
320
  * Transform supported Node.js versions to esbuild target.
321
321
  * @see https://esbuild.github.io/api/#target
@@ -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 = '20.0.0-next.9';
13
+ const VERSION = '20.0.0-rc.0';
14
14
  function hasCacheMetadata(value) {
15
15
  return (!!value &&
16
16
  typeof value === 'object' &&
@@ -17,7 +17,7 @@ class WorkerPool extends piscina_1.Piscina {
17
17
  idleTimeout: 1000,
18
18
  // Web containers do not support transferable objects with receiveOnMessagePort which
19
19
  // is used when the Atomics based wait loop is enable.
20
- useAtomics: !process.versions.webcontainer,
20
+ atomics: process.versions.webcontainer ? 'disabled' : 'sync',
21
21
  recordTiming: false,
22
22
  ...options,
23
23
  };