@angular/build 20.2.2 → 21.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.
Files changed (43) hide show
  1. package/.browserslistrc +5 -5
  2. package/package.json +18 -18
  3. package/src/builders/application/chunk-optimizer.js +2 -1
  4. package/src/builders/dev-server/builder.js +2 -2
  5. package/src/builders/dev-server/vite/hmr.d.ts +25 -0
  6. package/src/builders/dev-server/vite/hmr.js +113 -0
  7. package/src/builders/dev-server/vite/index.d.ts +21 -0
  8. package/src/builders/dev-server/{vite-server.js → vite/index.js} +19 -360
  9. package/src/builders/dev-server/vite/server.d.ts +15 -0
  10. package/src/builders/dev-server/vite/server.js +229 -0
  11. package/src/builders/dev-server/vite/utils.d.ts +36 -0
  12. package/src/builders/dev-server/vite/utils.js +76 -0
  13. package/src/builders/unit-test/builder.d.ts +1 -1
  14. package/src/builders/unit-test/builder.js +187 -299
  15. package/src/builders/unit-test/options.d.ts +1 -0
  16. package/src/builders/unit-test/options.js +2 -1
  17. package/src/builders/unit-test/runners/api.d.ts +47 -0
  18. package/src/builders/unit-test/runners/api.js +9 -0
  19. package/src/builders/unit-test/runners/karma/executor.d.ts +17 -0
  20. package/src/builders/unit-test/runners/karma/executor.js +93 -0
  21. package/src/builders/unit-test/runners/karma/index.d.ts +13 -0
  22. package/src/builders/unit-test/runners/karma/index.js +26 -0
  23. package/src/builders/unit-test/runners/vitest/browser-provider.d.ts +11 -0
  24. package/src/builders/unit-test/runners/vitest/browser-provider.js +69 -0
  25. package/src/builders/unit-test/runners/vitest/build-options.d.ts +11 -0
  26. package/src/builders/unit-test/runners/vitest/build-options.js +87 -0
  27. package/src/builders/unit-test/runners/vitest/executor.d.ts +23 -0
  28. package/src/builders/unit-test/runners/vitest/executor.js +200 -0
  29. package/src/builders/unit-test/runners/vitest/index.d.ts +13 -0
  30. package/src/builders/unit-test/runners/vitest/index.js +30 -0
  31. package/src/builders/unit-test/schema.d.ts +4 -0
  32. package/src/builders/unit-test/schema.json +4 -0
  33. package/src/builders/unit-test/test-discovery.d.ts +8 -0
  34. package/src/builders/unit-test/test-discovery.js +14 -0
  35. package/src/private.d.ts +1 -1
  36. package/src/private.js +2 -2
  37. package/src/utils/environment-options.d.ts +43 -0
  38. package/src/utils/environment-options.js +84 -30
  39. package/src/utils/normalize-cache.js +1 -1
  40. package/src/utils/version.js +1 -1
  41. package/src/builders/dev-server/vite-server.d.ts +0 -42
  42. package/src/builders/unit-test/karma-bridge.d.ts +0 -10
  43. package/src/builders/unit-test/karma-bridge.js +0 -82
package/.browserslistrc CHANGED
@@ -1,7 +1,7 @@
1
- Chrome >= 107
2
- ChromeAndroid >= 107
3
- Edge >= 107
4
- Firefox >= 104
5
- FirefoxAndroid >= 104
1
+ Chrome >= 110
2
+ ChromeAndroid >= 110
3
+ Edge >= 110
4
+ Firefox >= 110
5
+ FirefoxAndroid >= 110
6
6
  Safari >= 16
7
7
  iOS >= 16
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular/build",
3
- "version": "20.2.2",
3
+ "version": "21.0.0-next.1",
4
4
  "description": "Official build system for Angular",
5
5
  "keywords": [
6
6
  "Angular CLI",
@@ -23,11 +23,11 @@
23
23
  "builders": "builders.json",
24
24
  "dependencies": {
25
25
  "@ampproject/remapping": "2.3.0",
26
- "@angular-devkit/architect": "0.2002.2",
26
+ "@angular-devkit/architect": "0.2100.0-next.1",
27
27
  "@babel/core": "7.28.3",
28
28
  "@babel/helper-annotate-as-pure": "7.27.3",
29
29
  "@babel/helper-split-export-declaration": "7.24.7",
30
- "@inquirer/confirm": "5.1.14",
30
+ "@inquirer/confirm": "5.1.16",
31
31
  "@vitejs/plugin-basic-ssl": "2.1.0",
32
32
  "beasties": "0.3.5",
33
33
  "browserslist": "^4.23.0",
@@ -35,35 +35,35 @@
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": "9.0.1",
39
- "magic-string": "0.30.17",
38
+ "listr2": "9.0.2",
39
+ "magic-string": "0.30.18",
40
40
  "mrmime": "2.0.1",
41
41
  "parse5-html-rewriting-stream": "8.0.0",
42
42
  "picomatch": "4.0.3",
43
43
  "piscina": "5.1.3",
44
- "rolldown": "1.0.0-beta.32",
45
- "sass": "1.90.0",
44
+ "rolldown": "1.0.0-beta.34",
45
+ "sass": "1.91.0",
46
46
  "semver": "7.7.2",
47
47
  "source-map-support": "0.5.21",
48
48
  "tinyglobby": "0.2.14",
49
- "vite": "7.1.2",
49
+ "vite": "7.1.3",
50
50
  "watchpack": "2.4.4"
51
51
  },
52
52
  "optionalDependencies": {
53
53
  "lmdb": "3.4.2"
54
54
  },
55
55
  "peerDependencies": {
56
- "@angular/core": "^20.0.0",
57
- "@angular/compiler": "^20.0.0",
58
- "@angular/compiler-cli": "^20.0.0",
59
- "@angular/localize": "^20.0.0",
60
- "@angular/platform-browser": "^20.0.0",
61
- "@angular/platform-server": "^20.0.0",
62
- "@angular/service-worker": "^20.0.0",
63
- "@angular/ssr": "^20.2.2",
56
+ "@angular/core": "^21.0.0-next.0",
57
+ "@angular/compiler": "^21.0.0-next.0",
58
+ "@angular/compiler-cli": "^21.0.0-next.0",
59
+ "@angular/localize": "^21.0.0-next.0",
60
+ "@angular/platform-browser": "^21.0.0-next.0",
61
+ "@angular/platform-server": "^21.0.0-next.0",
62
+ "@angular/service-worker": "^21.0.0-next.0",
63
+ "@angular/ssr": "^21.0.0-next.1",
64
64
  "karma": "^6.4.0",
65
65
  "less": "^4.2.0",
66
- "ng-packagr": "^20.0.0",
66
+ "ng-packagr": "^21.0.0-next.0",
67
67
  "postcss": "^8.4.0",
68
68
  "tailwindcss": "^2.0.0 || ^3.0.0 || ^4.0.0",
69
69
  "tslib": "^2.3.0",
@@ -112,7 +112,7 @@
112
112
  "type": "git",
113
113
  "url": "https://github.com/angular/angular-cli.git"
114
114
  },
115
- "packageManager": "pnpm@10.15.1",
115
+ "packageManager": "pnpm@10.15.0",
116
116
  "engines": {
117
117
  "node": "^20.19.0 || ^22.12.0 || >=24.0.0",
118
118
  "npm": "^6.11.0 || ^7.5.6 || >=8.0.0",
@@ -198,7 +198,8 @@ async function optimizeChunks(original, sourcemap) {
198
198
  ],
199
199
  });
200
200
  const result = await bundle.generate({
201
- minify: { mangle: false, compress: false, removeWhitespace: true },
201
+ minify: { mangle: false, compress: false },
202
+ advancedChunks: { minSize: 8192 },
202
203
  sourcemap,
203
204
  chunkFileNames: (chunkInfo) => `${chunkInfo.name.replace(/-[a-zA-Z0-9]{8}$/, '')}-[hash].js`,
204
205
  });
@@ -11,7 +11,7 @@ exports.execute = execute;
11
11
  const check_port_1 = require("../../utils/check-port");
12
12
  const internal_1 = require("./internal");
13
13
  const options_1 = require("./options");
14
- const vite_server_1 = require("./vite-server");
14
+ const vite_1 = require("./vite");
15
15
  /**
16
16
  * A Builder that executes a development server based on the provided browser target option.
17
17
  *
@@ -33,7 +33,7 @@ async function* execute(options, context, extensions) {
33
33
  return;
34
34
  }
35
35
  const { builderName, normalizedOptions } = await initialize(options, projectName, context);
36
- yield* (0, vite_server_1.serveWithVite)(normalizedOptions, builderName, (options, context, plugins) => (0, internal_1.buildApplicationInternal)(options, context, { codePlugins: plugins }), context, { indexHtml: extensions?.indexHtmlTransformer }, extensions);
36
+ yield* (0, vite_1.serveWithVite)(normalizedOptions, builderName, (options, context, plugins) => (0, internal_1.buildApplicationInternal)(options, context, { codePlugins: plugins }), context, { indexHtml: extensions?.indexHtmlTransformer }, extensions);
37
37
  }
38
38
  async function initialize(initialOptions, projectName, context) {
39
39
  // Purge old build disk cache.
@@ -0,0 +1,25 @@
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 { BuilderContext } from '@angular-devkit/architect';
9
+ import type { ViteDevServer } from 'vite';
10
+ import type { ComponentStyleRecord } from '../../../tools/vite/middlewares';
11
+ import type { NormalizedDevServerOptions } from '../options';
12
+ import type { OutputAssetRecord, OutputFileRecord } from './utils';
13
+ /**
14
+ * Invalidates any updated asset or generated files and resets their `updated` state.
15
+ * This function also clears the server application cache when necessary.
16
+ *
17
+ * @returns A list of files that were updated and invalidated.
18
+ */
19
+ export declare function invalidateUpdatedFiles(normalizePath: (id: string) => string, generatedFiles: Map<string, OutputFileRecord>, assetFiles: Map<string, OutputAssetRecord>, server: ViteDevServer): Promise<string[]>;
20
+ /**
21
+ * Handles updates for the client by sending HMR or full page reload commands
22
+ * based on the updated files. It also ensures proper tracking of component styles and determines if
23
+ * a full reload is needed.
24
+ */
25
+ export declare function handleUpdate(server: ViteDevServer, serverOptions: NormalizedDevServerOptions, logger: BuilderContext['logger'], componentStyles: Map<string, ComponentStyleRecord>, updatedFiles: string[]): void;
@@ -0,0 +1,113 @@
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.invalidateUpdatedFiles = invalidateUpdatedFiles;
11
+ exports.handleUpdate = handleUpdate;
12
+ const node_path_1 = require("node:path");
13
+ const internal_1 = require("../internal");
14
+ /**
15
+ * Invalidates any updated asset or generated files and resets their `updated` state.
16
+ * This function also clears the server application cache when necessary.
17
+ *
18
+ * @returns A list of files that were updated and invalidated.
19
+ */
20
+ async function invalidateUpdatedFiles(normalizePath, generatedFiles, assetFiles, server) {
21
+ const updatedFiles = [];
22
+ // Invalidate any updated asset
23
+ for (const [file, record] of assetFiles) {
24
+ if (!record.updated) {
25
+ continue;
26
+ }
27
+ record.updated = false;
28
+ updatedFiles.push(file);
29
+ }
30
+ // Invalidate any updated files
31
+ let serverApplicationChanged = false;
32
+ for (const [file, record] of generatedFiles) {
33
+ if (!record.updated) {
34
+ continue;
35
+ }
36
+ record.updated = false;
37
+ updatedFiles.push(file);
38
+ serverApplicationChanged ||= record.type === internal_1.BuildOutputFileType.ServerApplication;
39
+ const updatedModules = server.moduleGraph.getModulesByFile(normalizePath((0, node_path_1.join)(server.config.root, file)));
40
+ updatedModules?.forEach((m) => server.moduleGraph.invalidateModule(m));
41
+ }
42
+ if (serverApplicationChanged) {
43
+ // Clear the server app cache and
44
+ // trigger module evaluation before reload to initiate dependency optimization.
45
+ const { ɵdestroyAngularServerApp } = (await server.ssrLoadModule('/main.server.mjs'));
46
+ ɵdestroyAngularServerApp();
47
+ }
48
+ return updatedFiles;
49
+ }
50
+ /**
51
+ * Handles updates for the client by sending HMR or full page reload commands
52
+ * based on the updated files. It also ensures proper tracking of component styles and determines if
53
+ * a full reload is needed.
54
+ */
55
+ function handleUpdate(server, serverOptions, logger, componentStyles, updatedFiles) {
56
+ if (!updatedFiles.length) {
57
+ return;
58
+ }
59
+ if (serverOptions.hmr) {
60
+ if (updatedFiles.every((f) => f.endsWith('.css'))) {
61
+ let requiresReload = false;
62
+ const timestamp = Date.now();
63
+ const updates = updatedFiles.flatMap((filePath) => {
64
+ // For component styles, an HMR update must be sent for each one with the corresponding
65
+ // component identifier search parameter (`ngcomp`). The Vite client code will not keep
66
+ // the existing search parameters when it performs an update and each one must be
67
+ // specified explicitly. Typically, there is only one each though as specific style files
68
+ // are not typically reused across components.
69
+ const record = componentStyles.get(filePath);
70
+ if (record) {
71
+ if (record.reload) {
72
+ // Shadow DOM components currently require a full reload.
73
+ // Vite's CSS hot replacement does not support shadow root searching.
74
+ requiresReload = true;
75
+ return [];
76
+ }
77
+ return Array.from(record.used ?? []).map((id) => {
78
+ return {
79
+ type: 'css-update',
80
+ timestamp,
81
+ path: `${filePath}?ngcomp` + (typeof id === 'string' ? `=${id}` : ''),
82
+ acceptedPath: filePath,
83
+ };
84
+ });
85
+ }
86
+ return {
87
+ type: 'css-update',
88
+ timestamp,
89
+ path: filePath,
90
+ acceptedPath: filePath,
91
+ };
92
+ });
93
+ if (!requiresReload) {
94
+ server.ws.send({
95
+ type: 'update',
96
+ updates,
97
+ });
98
+ logger.info('Stylesheet update sent to client(s).');
99
+ return;
100
+ }
101
+ }
102
+ }
103
+ // Send reload command to clients
104
+ if (serverOptions.liveReload) {
105
+ // Clear used component tracking on full reload
106
+ componentStyles.forEach((record) => record.used?.clear());
107
+ server.ws.send({
108
+ type: 'full-reload',
109
+ path: '*',
110
+ });
111
+ logger.info('Page reload sent to client(s).');
112
+ }
113
+ }
@@ -0,0 +1,21 @@
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 { BuilderContext } from '@angular-devkit/architect';
9
+ import type { Plugin } from 'esbuild';
10
+ import type { Connect } from 'vite';
11
+ import { Result } from '../../application/results';
12
+ import { type ApplicationBuilderInternalOptions } from '../internal';
13
+ import type { NormalizedDevServerOptions } from '../options';
14
+ import type { DevServerBuilderOutput } from '../output';
15
+ export type BuilderAction = (options: ApplicationBuilderInternalOptions, context: BuilderContext, plugins?: Plugin[]) => AsyncIterable<Result>;
16
+ export declare function serveWithVite(serverOptions: NormalizedDevServerOptions, builderName: string, builderAction: BuilderAction, context: BuilderContext, transformers?: {
17
+ indexHtml?: (content: string) => Promise<string>;
18
+ }, extensions?: {
19
+ middleware?: Connect.NextHandleFunction[];
20
+ buildPlugins?: Plugin[];
21
+ }): AsyncIterableIterator<DevServerBuilderOutput>;