@angular/build 20.0.0-rc.3 → 20.0.0-rc.4

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-rc.3",
3
+ "version": "20.0.0-rc.4",
4
4
  "description": "Official build system for Angular",
5
5
  "keywords": [
6
6
  "Angular CLI",
@@ -23,15 +23,15 @@
23
23
  "builders": "builders.json",
24
24
  "dependencies": {
25
25
  "@ampproject/remapping": "2.3.0",
26
- "@angular-devkit/architect": "0.2000.0-rc.3",
26
+ "@angular-devkit/architect": "0.2000.0-rc.4",
27
27
  "@babel/core": "7.27.1",
28
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.10",
31
31
  "@vitejs/plugin-basic-ssl": "2.0.0",
32
- "beasties": "0.3.3",
32
+ "beasties": "0.3.4",
33
33
  "browserslist": "^4.23.0",
34
- "esbuild": "0.25.4",
34
+ "esbuild": "0.25.5",
35
35
  "https-proxy-agent": "7.0.6",
36
36
  "istanbul-lib-instrument": "6.0.3",
37
37
  "jsonc-parser": "3.3.1",
@@ -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-rc.3",
63
+ "@angular/ssr": "^20.0.0-rc.4",
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,13 +114,12 @@ async function* serveWithVite(serverOptions, builderName, builderAction, context
114
114
  // https://nodejs.org/api/process.html#processsetsourcemapsenabledval
115
115
  process.setSourceMapsEnabled(true);
116
116
  }
117
+ const componentsHmrCanBeUsed = browserOptions.aot && serverOptions.liveReload && serverOptions.hmr;
117
118
  // Enable to support link-based component style hot reloading (`NG_HMR_CSTYLES=1` can be used to enable)
118
- browserOptions.externalRuntimeStyles =
119
- serverOptions.liveReload && serverOptions.hmr && environment_options_1.useComponentStyleHmr;
119
+ browserOptions.externalRuntimeStyles = componentsHmrCanBeUsed && environment_options_1.useComponentStyleHmr;
120
120
  // Enable to support component template hot replacement (`NG_HMR_TEMPLATE=0` can be used to disable selectively)
121
121
  // This will also replace file-based/inline styles as code if external runtime styles are not enabled.
122
- browserOptions.templateUpdates =
123
- serverOptions.liveReload && serverOptions.hmr && environment_options_1.useComponentTemplateHmr;
122
+ browserOptions.templateUpdates = componentsHmrCanBeUsed && environment_options_1.useComponentTemplateHmr;
124
123
  browserOptions.incrementalResults = true;
125
124
  // Setup the prebundling transformer that will be shared across Vite prebundling requests
126
125
  const prebundleTransformer = new internal_1.JavaScriptTransformer(
@@ -14,6 +14,12 @@ export interface CompilerPluginOptions {
14
14
  sourcemap: boolean | 'external';
15
15
  tsconfig: string;
16
16
  jit?: boolean;
17
+ /**
18
+ * Include class metadata and JIT information in built code.
19
+ * The Angular TestBed APIs require additional metadata for the Angular aspects of the application
20
+ * such as Components, Modules, Pipes, etc.
21
+ * TestBed may also leverage JIT capabilities during testing (e.g., overrideComponent).
22
+ */
17
23
  includeTestMetadata?: boolean;
18
24
  advancedOptimizations?: boolean;
19
25
  thirdPartySourcemaps?: boolean;
@@ -89,7 +89,7 @@ function createCompilerPlugin(pluginOptions, compilationOrFactory, stylesheetBun
89
89
  sourcemap: !!pluginOptions.sourcemap,
90
90
  thirdPartySourcemaps: pluginOptions.thirdPartySourcemaps,
91
91
  advancedOptimizations: pluginOptions.advancedOptimizations,
92
- jit: pluginOptions.jit,
92
+ jit: pluginOptions.jit || pluginOptions.includeTestMetadata,
93
93
  }, environment_options_1.maxWorkers, cacheStore?.createCache('jstransformer'));
94
94
  // Setup defines based on the values used by the Angular compiler-cli
95
95
  build.initialOptions.define ??= {};
@@ -553,6 +553,7 @@ function createCompilerOptionsTransformer(setupWarnings, pluginOptions, preserve
553
553
  externalRuntimeStyles: pluginOptions.externalRuntimeStyles,
554
554
  _enableHmr: !!pluginOptions.templateUpdates,
555
555
  supportTestBed: !!pluginOptions.includeTestMetadata,
556
+ supportJitMode: !!pluginOptions.includeTestMetadata,
556
557
  };
557
558
  };
558
559
  }
@@ -51,6 +51,13 @@ const piscina_1 = __importDefault(require("piscina"));
51
51
  const load_esm_1 = require("../../utils/load-esm");
52
52
  const textDecoder = new TextDecoder();
53
53
  const textEncoder = new TextEncoder();
54
+ /**
55
+ * The function name prefix for all Angular partial compilation functions.
56
+ * Used to determine if linking of a JavaScript file is required.
57
+ * If any additional declarations are added or otherwise changed in the linker,
58
+ * the names MUST begin with this prefix.
59
+ */
60
+ const LINKER_DECLARATION_PREFIX = 'ɵɵngDeclare';
54
61
  async function transformJavaScript(request) {
55
62
  const { filename, data, ...options } = request;
56
63
  const textData = typeof data === 'string' ? data : textDecoder.decode(data);
@@ -62,10 +69,6 @@ async function transformJavaScript(request) {
62
69
  * Cached instance of the compiler-cli linker's createEs2015LinkerPlugin function.
63
70
  */
64
71
  let linkerPluginCreator;
65
- /**
66
- * Cached instance of the compiler-cli linker's needsLinking function.
67
- */
68
- let needsLinking;
69
72
  async function transformWithBabel(filename, data, options) {
70
73
  const shouldLink = !options.skipLinker && (await requiresLinking(filename, data));
71
74
  const useInputSourcemap = options.sourcemap &&
@@ -120,14 +123,10 @@ async function requiresLinking(path, source) {
120
123
  if (/[\\/]@angular[\\/](?:compiler|core)|\.tsx?$/.test(path)) {
121
124
  return false;
122
125
  }
123
- if (!needsLinking) {
124
- // Load ESM `@angular/compiler-cli/linker` using the TypeScript dynamic import workaround.
125
- // Once TypeScript provides support for keeping the dynamic import this workaround can be
126
- // changed to a direct dynamic import.
127
- const linkerModule = await (0, load_esm_1.loadEsmModule)('@angular/compiler-cli/linker');
128
- needsLinking = linkerModule.needsLinking;
129
- }
130
- return needsLinking(path, source);
126
+ // Check if the source code includes one of the declaration functions.
127
+ // There is a low chance of a false positive but the names are fairly unique
128
+ // and the result would be an unnecessary no-op additional plugin pass.
129
+ return source.includes(LINKER_DECLARATION_PREFIX);
131
130
  }
132
131
  async function createLinkerPlugin(options) {
133
132
  linkerPluginCreator ??= (await (0, load_esm_1.loadEsmModule)('@angular/compiler-cli/linker/babel')).createEs2015LinkerPlugin;
@@ -39,6 +39,9 @@ class JavaScriptTransformer {
39
39
  this.#fileCacheKeyBase = Buffer.from(JSON.stringify(this.#commonOptions), 'utf-8');
40
40
  }
41
41
  #ensureWorkerPool() {
42
+ if (this.#workerPool) {
43
+ return this.#workerPool;
44
+ }
42
45
  const workerPoolOptions = {
43
46
  filename: require.resolve('./javascript-transformer-worker'),
44
47
  maxThreads: this.maxThreads,
@@ -48,7 +51,7 @@ class JavaScriptTransformer {
48
51
  if (process.execArgv.length !== filteredExecArgv.length) {
49
52
  workerPoolOptions.execArgv = filteredExecArgv;
50
53
  }
51
- this.#workerPool ??= new worker_pool_1.WorkerPool(workerPoolOptions);
54
+ this.#workerPool = new worker_pool_1.WorkerPool(workerPoolOptions);
52
55
  return this.#workerPool;
53
56
  }
54
57
  /**
@@ -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-rc.3';
13
+ const VERSION = '20.0.0-rc.4';
14
14
  function hasCacheMetadata(value) {
15
15
  return (!!value &&
16
16
  typeof value === 'object' &&