@angular/build 19.0.3 → 19.0.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": "19.0.3",
3
+ "version": "19.0.4",
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.1900.3",
26
+ "@angular-devkit/architect": "0.1900.4",
27
27
  "@babel/core": "7.26.0",
28
28
  "@babel/helper-annotate-as-pure": "7.25.9",
29
29
  "@babel/helper-split-export-declaration": "7.24.7",
@@ -57,7 +57,7 @@
57
57
  "@angular/localize": "^19.0.0",
58
58
  "@angular/platform-server": "^19.0.0",
59
59
  "@angular/service-worker": "^19.0.0",
60
- "@angular/ssr": "^19.0.3",
60
+ "@angular/ssr": "^19.0.4",
61
61
  "less": "^4.2.0",
62
62
  "postcss": "^8.4.0",
63
63
  "tailwindcss": "^2.0.0 || ^3.0.0",
@@ -601,6 +601,25 @@ async function setupServer(serverOptions, outputFiles, assets, preserveSymlinks,
601
601
  }
602
602
  function getDepOptimizationConfig({ disabled, exclude, include, target, zoneless, prebundleTransformer, ssr, loader, thirdPartySourcemaps, }) {
603
603
  const plugins = [
604
+ {
605
+ name: 'angular-browser-node-built-in',
606
+ setup(build) {
607
+ // This namespace is configured by vite.
608
+ // @see: https://github.com/vitejs/vite/blob/a1dd396da856401a12c921d0cd2c4e97cb63f1b5/packages/vite/src/node/optimizer/esbuildDepPlugin.ts#L109
609
+ build.onLoad({ filter: /.*/, namespace: 'browser-external' }, (args) => {
610
+ if (!(0, node_module_1.isBuiltin)(args.path)) {
611
+ return;
612
+ }
613
+ return {
614
+ errors: [
615
+ {
616
+ text: `The package "${args.path}" wasn't found on the file system but is built into node.`,
617
+ },
618
+ ],
619
+ };
620
+ });
621
+ },
622
+ },
604
623
  {
605
624
  name: `angular-vite-optimize-deps${ssr ? '-ssr' : ''}${thirdPartySourcemaps ? '-vendor-sourcemap' : ''}`,
606
625
  setup(build) {
@@ -24,4 +24,4 @@ export interface AngularHostOptions {
24
24
  * @param program The TypeScript Program instance to patch.
25
25
  */
26
26
  export declare function ensureSourceFileVersions(program: ts.Program): void;
27
- export declare function createAngularCompilerHost(typescript: typeof ts, compilerOptions: AngularCompilerOptions, hostOptions: AngularHostOptions): AngularCompilerHost;
27
+ export declare function createAngularCompilerHost(typescript: typeof ts, compilerOptions: AngularCompilerOptions, hostOptions: AngularHostOptions, packageJsonCache: ts.PackageJsonInfoCache | undefined): AngularCompilerHost;
@@ -91,7 +91,7 @@ function augmentHostWithReplacements(typescript, host, replacements, moduleResol
91
91
  };
92
92
  augmentResolveModuleNames(typescript, host, tryReplace, moduleResolutionCache);
93
93
  }
94
- function createAngularCompilerHost(typescript, compilerOptions, hostOptions) {
94
+ function createAngularCompilerHost(typescript, compilerOptions, hostOptions, packageJsonCache) {
95
95
  // Create TypeScript compiler host
96
96
  const host = typescript.createIncrementalCompilerHost(compilerOptions);
97
97
  // Set the parsing mode to the same as TS 5.3+ default for tsc. This provides a parse
@@ -135,11 +135,11 @@ function createAngularCompilerHost(typescript, compilerOptions, hostOptions) {
135
135
  host.getModifiedResourceFiles = function () {
136
136
  return hostOptions.modifiedFiles;
137
137
  };
138
+ // Provide a resolution cache to ensure package.json lookups are cached
139
+ const resolutionCache = typescript.createModuleResolutionCache(host.getCurrentDirectory(), host.getCanonicalFileName.bind(host), compilerOptions, packageJsonCache);
140
+ host.getModuleResolutionCache = () => resolutionCache;
138
141
  // Augment TypeScript Host for file replacements option
139
142
  if (hostOptions.fileReplacements) {
140
- // Provide a resolution cache since overriding resolution prevents automatic creation
141
- const resolutionCache = typescript.createModuleResolutionCache(host.getCurrentDirectory(), host.getCanonicalFileName.bind(host), compilerOptions);
142
- host.getModuleResolutionCache = () => resolutionCache;
143
143
  augmentHostWithReplacements(typescript, host, hostOptions.fileReplacements, resolutionCache);
144
144
  }
145
145
  // Augment TypeScript Host with source file caching if provided
@@ -51,19 +51,32 @@ class AotCompilation extends angular_compilation_1.AngularCompilation {
51
51
  if (compilerOptions.externalRuntimeStyles) {
52
52
  hostOptions.externalStylesheets ??= new Map();
53
53
  }
54
- // Collect stale source files for HMR analysis of inline component resources
54
+ // Reuse the package.json cache from the previous compilation
55
+ const packageJsonCache = this.#state?.compilerHost
56
+ .getModuleResolutionCache?.()
57
+ ?.getPackageJsonInfoCache();
58
+ const useHmr = compilerOptions['_enableHmr'];
55
59
  let staleSourceFiles;
56
- if (compilerOptions['_enableHmr'] && hostOptions.modifiedFiles && this.#state) {
60
+ let clearPackageJsonCache = false;
61
+ if (hostOptions.modifiedFiles && this.#state) {
57
62
  for (const modifiedFile of hostOptions.modifiedFiles) {
58
- const sourceFile = this.#state.typeScriptProgram.getSourceFile(modifiedFile);
59
- if (sourceFile) {
60
- staleSourceFiles ??= new Map();
61
- staleSourceFiles.set(modifiedFile, sourceFile);
63
+ // Clear package.json cache if a node modules file was modified
64
+ if (!clearPackageJsonCache && modifiedFile.includes('node_modules')) {
65
+ clearPackageJsonCache = true;
66
+ packageJsonCache?.clear();
67
+ }
68
+ // Collect stale source files for HMR analysis of inline component resources
69
+ if (useHmr) {
70
+ const sourceFile = this.#state.typeScriptProgram.getSourceFile(modifiedFile);
71
+ if (sourceFile) {
72
+ staleSourceFiles ??= new Map();
73
+ staleSourceFiles.set(modifiedFile, sourceFile);
74
+ }
62
75
  }
63
76
  }
64
77
  }
65
78
  // Create Angular compiler host
66
- const host = (0, angular_host_1.createAngularCompilerHost)(typescript_1.default, compilerOptions, hostOptions);
79
+ const host = (0, angular_host_1.createAngularCompilerHost)(typescript_1.default, compilerOptions, hostOptions, packageJsonCache);
67
80
  // Create the Angular specific program that contains the Angular compiler
68
81
  const angularProgram = (0, profiling_1.profileSync)('NG_CREATE_PROGRAM', () => new NgtscProgram(rootNames, compilerOptions, host, this.#state?.angularProgram));
69
82
  const angularCompiler = angularProgram.compiler;
@@ -42,7 +42,7 @@ class JitCompilation extends angular_compilation_1.AngularCompilation {
42
42
  const { options: originalCompilerOptions, rootNames, errors: configurationDiagnostics, } = await this.loadConfiguration(tsconfig);
43
43
  const compilerOptions = compilerOptionsTransformer?.(originalCompilerOptions) ?? originalCompilerOptions;
44
44
  // Create Angular compiler host
45
- const host = (0, angular_host_1.createAngularCompilerHost)(typescript_1.default, compilerOptions, hostOptions);
45
+ const host = (0, angular_host_1.createAngularCompilerHost)(typescript_1.default, compilerOptions, hostOptions, undefined);
46
46
  // Create the TypeScript Program
47
47
  const typeScriptProgram = (0, profiling_1.profileSync)('TS_CREATE_PROGRAM', () => typescript_1.default.createEmitAndSemanticDiagnosticsBuilderProgram(rootNames, compilerOptions, host, this.#state?.typeScriptProgram ?? typescript_1.default.readBuilderProgram(compilerOptions, host), configurationDiagnostics));
48
48
  const affectedFiles = (0, profiling_1.profileSync)('TS_FIND_AFFECTED', () => findAffectedFiles(typeScriptProgram));
@@ -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 = '19.0.3';
13
+ const VERSION = '19.0.4';
14
14
  function hasCacheMetadata(value) {
15
15
  return (!!value &&
16
16
  typeof value === 'object' &&