@angular/build 18.0.3 → 18.1.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 (104) hide show
  1. package/package.json +17 -17
  2. package/src/builders/application/build-action.js +1 -2
  3. package/src/builders/application/execute-build.js +1 -2
  4. package/src/builders/application/execute-post-bundle.js +1 -2
  5. package/src/builders/application/i18n.js +2 -3
  6. package/src/builders/application/index.js +2 -3
  7. package/src/builders/application/options.d.ts +2 -2
  8. package/src/builders/application/options.js +1 -2
  9. package/src/builders/application/setup-bundling.js +2 -8
  10. package/src/builders/dev-server/builder.d.ts +0 -1
  11. package/src/builders/dev-server/builder.js +1 -2
  12. package/src/builders/dev-server/options.d.ts +4 -0
  13. package/src/builders/dev-server/options.js +26 -2
  14. package/src/builders/dev-server/schema.d.ts +10 -0
  15. package/src/builders/dev-server/schema.json +11 -0
  16. package/src/builders/dev-server/vite-server.js +42 -34
  17. package/src/builders/extract-i18n/application-extraction.js +1 -2
  18. package/src/builders/extract-i18n/builder.js +1 -2
  19. package/src/builders/extract-i18n/options.js +1 -2
  20. package/src/tools/babel/plugins/adjust-static-class-members.d.ts +0 -1
  21. package/src/tools/babel/plugins/adjust-static-class-members.js +2 -3
  22. package/src/tools/babel/plugins/adjust-typescript-enums.d.ts +0 -1
  23. package/src/tools/babel/plugins/adjust-typescript-enums.js +2 -3
  24. package/src/tools/babel/plugins/elide-angular-metadata.d.ts +0 -1
  25. package/src/tools/babel/plugins/elide-angular-metadata.js +2 -3
  26. package/src/tools/babel/plugins/pure-toplevel-functions.d.ts +0 -1
  27. package/src/tools/babel/plugins/pure-toplevel-functions.js +1 -1
  28. package/src/tools/esbuild/angular/angular-host.js +2 -3
  29. package/src/tools/esbuild/angular/compilation/aot-compilation.js +42 -7
  30. package/src/tools/esbuild/angular/compilation/factory.js +1 -2
  31. package/src/tools/esbuild/angular/compilation/jit-bootstrap-transformer.js +2 -3
  32. package/src/tools/esbuild/angular/compilation/parallel-worker.d.ts +2 -1
  33. package/src/tools/esbuild/angular/compilation/parallel-worker.js +10 -7
  34. package/src/tools/esbuild/angular/compilation-state.js +2 -2
  35. package/src/tools/esbuild/angular/compiler-plugin.js +15 -7
  36. package/src/tools/esbuild/angular/diagnostics.js +1 -2
  37. package/src/tools/esbuild/angular/jit-plugin-callbacks.js +1 -2
  38. package/src/tools/esbuild/angular/jit-resource-transformer.js +1 -2
  39. package/src/tools/esbuild/angular/uri.js +4 -4
  40. package/src/tools/esbuild/angular/web-worker-transformer.js +1 -2
  41. package/src/tools/esbuild/application-code-bundle.js +4 -5
  42. package/src/tools/esbuild/budget-stats.js +1 -2
  43. package/src/tools/esbuild/commonjs-checker.js +1 -2
  44. package/src/tools/esbuild/compiler-plugin-options.js +1 -2
  45. package/src/tools/esbuild/external-packages-plugin.js +1 -2
  46. package/src/tools/esbuild/global-scripts.js +1 -2
  47. package/src/tools/esbuild/global-styles.js +1 -2
  48. package/src/tools/esbuild/i18n-inliner-worker.d.ts +1 -1
  49. package/src/tools/esbuild/i18n-inliner-worker.js +1 -1
  50. package/src/tools/esbuild/i18n-locale-plugin.js +2 -2
  51. package/src/tools/esbuild/index-html-generator.js +1 -2
  52. package/src/tools/esbuild/javascript-transformer-worker.js +1 -1
  53. package/src/tools/esbuild/javascript-transformer.d.ts +1 -1
  54. package/src/tools/esbuild/license-extractor.js +1 -2
  55. package/src/tools/esbuild/load-result-cache.js +2 -2
  56. package/src/tools/esbuild/profiling.js +4 -5
  57. package/src/tools/esbuild/rxjs-esm-resolution-plugin.js +1 -2
  58. package/src/tools/esbuild/sourcemap-ignorelist-plugin.js +1 -2
  59. package/src/tools/esbuild/stylesheets/bundle-options.js +1 -2
  60. package/src/tools/esbuild/stylesheets/css-inline-fonts-plugin.js +1 -2
  61. package/src/tools/esbuild/stylesheets/css-resource-plugin.js +1 -2
  62. package/src/tools/esbuild/stylesheets/sass-language.js +2 -2
  63. package/src/tools/esbuild/utils.js +15 -16
  64. package/src/tools/esbuild/virtual-module-plugin.js +1 -2
  65. package/src/tools/esbuild/watcher.js +2 -2
  66. package/src/tools/sass/lexer.js +1 -2
  67. package/src/tools/sass/rebasing-importer.js +2 -2
  68. package/src/tools/sass/sass-service.js +3 -1
  69. package/src/tools/sass/worker.d.ts +2 -4
  70. package/src/tools/sass/worker.js +1 -1
  71. package/src/tools/vite/angular-memory-plugin.js +1 -2
  72. package/src/tools/vite/i18n-locale-plugin.js +2 -2
  73. package/src/utils/bundle-calculator.js +4 -4
  74. package/src/utils/check-port.js +1 -2
  75. package/src/utils/delete-output-dir.js +1 -2
  76. package/src/utils/error.js +1 -2
  77. package/src/utils/format-bytes.js +1 -2
  78. package/src/utils/i18n-options.js +2 -3
  79. package/src/utils/index-file/add-event-dispatch-contract.js +1 -2
  80. package/src/utils/index-file/augment-index-html.js +1 -2
  81. package/src/utils/index-file/html-rewriting-stream.js +1 -2
  82. package/src/utils/index-file/nonce.js +1 -2
  83. package/src/utils/load-esm.js +1 -2
  84. package/src/utils/load-proxy-config.js +1 -2
  85. package/src/utils/load-translations.js +1 -2
  86. package/src/utils/normalize-asset-patterns.js +2 -2
  87. package/src/utils/normalize-cache.js +2 -3
  88. package/src/utils/normalize-optimization.js +1 -2
  89. package/src/utils/normalize-source-maps.js +1 -2
  90. package/src/utils/postcss-configuration.js +3 -4
  91. package/src/utils/purge-cache.js +1 -2
  92. package/src/utils/resolve-assets.js +1 -2
  93. package/src/utils/server-rendering/esm-in-memory-loader/loader-hooks.js +3 -4
  94. package/src/utils/server-rendering/fetch-patch.js +1 -2
  95. package/src/utils/server-rendering/load-esm-from-memory.js +1 -2
  96. package/src/utils/server-rendering/prerender.js +1 -2
  97. package/src/utils/server-rendering/render-page.js +1 -2
  98. package/src/utils/service-worker.d.ts +0 -2
  99. package/src/utils/service-worker.js +3 -4
  100. package/src/utils/stats-table.js +2 -3
  101. package/src/utils/supported-browsers.js +1 -2
  102. package/src/utils/tty.js +1 -2
  103. package/src/utils/url.js +1 -2
  104. package/src/utils/version.js +1 -2
@@ -7,7 +7,8 @@
7
7
  * found in the LICENSE file at https://angular.io/license
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.getKeywords = void 0;
10
+ exports.getKeywords = getKeywords;
11
+ exports.default = default_1;
11
12
  /**
12
13
  * The name of the Angular class metadata function created by the Angular compiler.
13
14
  */
@@ -29,7 +30,6 @@ const SET_CLASS_DEBUG_INFO_NAME = 'ɵsetClassDebugInfo';
29
30
  function getKeywords() {
30
31
  return Object.keys(angularMetadataFunctions);
31
32
  }
32
- exports.getKeywords = getKeywords;
33
33
  /**
34
34
  * An object map of function names and related value checks for discovery of Angular generated
35
35
  * metadata calls.
@@ -77,7 +77,6 @@ function default_1() {
77
77
  },
78
78
  };
79
79
  }
80
- exports.default = default_1;
81
80
  /** Determines if a function call is a call to `setClassMetadata`. */
82
81
  function isSetClassMetadataCall(callArguments) {
83
82
  // `setClassMetadata` calls have to meet the following criteria:
@@ -5,7 +5,6 @@
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
- /// <reference types="@angular/compiler-cli/private/babel" />
9
8
  import type { PluginObj } from '@babel/core';
10
9
  /**
11
10
  * A babel plugin factory function for adding the PURE annotation to top-level new and call expressions.
@@ -33,6 +33,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
33
33
  return (mod && mod.__esModule) ? mod : { "default": mod };
34
34
  };
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.default = default_1;
36
37
  const helper_annotate_as_pure_1 = __importDefault(require("@babel/helper-annotate-as-pure"));
37
38
  const tslib = __importStar(require("tslib"));
38
39
  /**
@@ -87,4 +88,3 @@ function default_1() {
87
88
  },
88
89
  };
89
90
  }
90
- exports.default = default_1;
@@ -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.createAngularCompilerHost = exports.ensureSourceFileVersions = void 0;
13
+ exports.ensureSourceFileVersions = ensureSourceFileVersions;
14
+ exports.createAngularCompilerHost = createAngularCompilerHost;
14
15
  const node_crypto_1 = require("node:crypto");
15
16
  const node_path_1 = __importDefault(require("node:path"));
16
17
  /**
@@ -32,7 +33,6 @@ function ensureSourceFileVersions(program) {
32
33
  return files;
33
34
  };
34
35
  }
35
- exports.ensureSourceFileVersions = ensureSourceFileVersions;
36
36
  function augmentHostWithCaching(host, cache) {
37
37
  const baseGetSourceFile = host.getSourceFile;
38
38
  host.getSourceFile = function (fileName, languageVersion, onError, shouldCreateNewSourceFile, ...parameters) {
@@ -131,4 +131,3 @@ function createAngularCompilerHost(typescript, compilerOptions, hostOptions) {
131
131
  }
132
132
  return host;
133
133
  }
134
- exports.createAngularCompilerHost = createAngularCompilerHost;
@@ -133,8 +133,10 @@ class AotCompilation extends angular_compilation_1.AngularCompilation {
133
133
  }
134
134
  emitAffectedFiles() {
135
135
  (0, node_assert_1.default)(this.#state, 'Angular compilation must be initialized prior to emitting files.');
136
- const { angularCompiler, compilerHost, typeScriptProgram, webWorkerTransform } = this.#state;
137
- const buildInfoFilename = typeScriptProgram.getCompilerOptions().tsBuildInfoFile ?? '.tsbuildinfo';
136
+ const { affectedFiles, angularCompiler, compilerHost, typeScriptProgram, webWorkerTransform } = this.#state;
137
+ const compilerOptions = typeScriptProgram.getCompilerOptions();
138
+ const buildInfoFilename = compilerOptions.tsBuildInfoFile ?? '.tsbuildinfo';
139
+ const useTypeScriptTranspilation = !compilerOptions.isolatedModules || !!compilerOptions.sourceMap;
138
140
  const emittedFiles = new Map();
139
141
  const writeFileCallback = (filename, contents, _a, _b, sourceFiles) => {
140
142
  if (!sourceFiles?.length && filename.endsWith(buildInfoFilename)) {
@@ -154,9 +156,20 @@ class AotCompilation extends angular_compilation_1.AngularCompilation {
154
156
  transformers.before ??= [];
155
157
  transformers.before.push((0, jit_bootstrap_transformer_1.replaceBootstrap)(() => typeScriptProgram.getProgram().getTypeChecker()));
156
158
  transformers.before.push(webWorkerTransform);
157
- // TypeScript will loop until there are no more affected files in the program
158
- while (typeScriptProgram.emitNextAffectedFile(writeFileCallback, undefined, undefined, transformers)) {
159
- /* empty */
159
+ // Emit is handled in write file callback when using TypeScript
160
+ if (useTypeScriptTranspilation) {
161
+ // TypeScript will loop until there are no more affected files in the program
162
+ while (typeScriptProgram.emitNextAffectedFile(writeFileCallback, undefined, undefined, transformers)) {
163
+ /* empty */
164
+ }
165
+ }
166
+ else if (compilerOptions.tsBuildInfoFile) {
167
+ // Manually get the builder state for the persistent cache
168
+ // The TypeScript API currently embeds this behavior inside the program emit
169
+ // via emitNextAffectedFile but that also applies all internal transforms.
170
+ const programWithGetState = typeScriptProgram.getProgram();
171
+ (0, node_assert_1.default)(typeof programWithGetState.emitBuildInfo === 'function', 'TypeScript program emitBuildInfo is missing.');
172
+ programWithGetState.emitBuildInfo();
160
173
  }
161
174
  // Angular may have files that must be emitted but TypeScript does not consider affected
162
175
  for (const sourceFile of typeScriptProgram.getSourceFiles()) {
@@ -166,10 +179,32 @@ class AotCompilation extends angular_compilation_1.AngularCompilation {
166
179
  if (sourceFile.isDeclarationFile) {
167
180
  continue;
168
181
  }
169
- if (angularCompiler.incrementalCompilation.safeToSkipEmit(sourceFile)) {
182
+ if (angularCompiler.incrementalCompilation.safeToSkipEmit(sourceFile) &&
183
+ !affectedFiles.has(sourceFile)) {
170
184
  continue;
171
185
  }
172
- typeScriptProgram.emit(sourceFile, writeFileCallback, undefined, undefined, transformers);
186
+ if (useTypeScriptTranspilation) {
187
+ typeScriptProgram.emit(sourceFile, writeFileCallback, undefined, undefined, transformers);
188
+ continue;
189
+ }
190
+ // When not using TypeScript transpilation, directly apply only Angular specific transformations
191
+ const transformResult = typescript_1.default.transform(sourceFile, [
192
+ ...(transformers.before ?? []),
193
+ ...(transformers.after ?? []),
194
+ ], compilerOptions);
195
+ (0, node_assert_1.default)(transformResult.transformed.length === 1, 'TypeScript transforms should not produce multiple outputs for ' + sourceFile.fileName);
196
+ let contents;
197
+ if (sourceFile === transformResult.transformed[0]) {
198
+ // Use original content if no changes were made
199
+ contents = sourceFile.text;
200
+ }
201
+ else {
202
+ // Otherwise, print the transformed source file
203
+ const printer = typescript_1.default.createPrinter(compilerOptions, transformResult);
204
+ contents = printer.printFile(transformResult.transformed[0]);
205
+ }
206
+ angularCompiler.incrementalCompilation.recordSuccessfulEmit(sourceFile);
207
+ emittedFiles.set(sourceFile, { filename: sourceFile.fileName, contents });
173
208
  }
174
209
  return emittedFiles.values();
175
210
  }
@@ -30,7 +30,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
30
30
  return result;
31
31
  };
32
32
  Object.defineProperty(exports, "__esModule", { value: true });
33
- exports.createAngularCompilation = void 0;
33
+ exports.createAngularCompilation = createAngularCompilation;
34
34
  const environment_options_1 = require("../../../../utils/environment-options");
35
35
  /**
36
36
  * Creates an Angular compilation object that can be used to perform Angular application
@@ -53,4 +53,3 @@ async function createAngularCompilation(jit) {
53
53
  return new AotCompilation();
54
54
  }
55
55
  }
56
- exports.createAngularCompilation = createAngularCompilation;
@@ -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.elideImports = exports.replaceBootstrap = void 0;
13
+ exports.replaceBootstrap = replaceBootstrap;
14
+ exports.elideImports = elideImports;
14
15
  const typescript_1 = __importDefault(require("typescript"));
15
16
  /**
16
17
  * The name of the Angular platform that should be replaced within
@@ -57,7 +58,6 @@ function replaceBootstrap(getTypeChecker) {
57
58
  };
58
59
  };
59
60
  }
60
- exports.replaceBootstrap = replaceBootstrap;
61
61
  // Remove imports for which all identifiers have been removed.
62
62
  // Needs type checker, and works even if it's not the first transformer.
63
63
  // Works by removing imports for symbols whose identifiers have all been removed.
@@ -179,4 +179,3 @@ function elideImports(sourceFile, removedNodes, getTypeChecker, compilerOptions)
179
179
  }
180
180
  return importNodeRemovals;
181
181
  }
182
- exports.elideImports = elideImports;
@@ -5,7 +5,6 @@
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
- /// <reference types="node" />
9
8
  import type { PartialMessage } from 'esbuild';
10
9
  import { type MessagePort } from 'node:worker_threads';
11
10
  import type { DiagnosticModes } from './angular-compilation';
@@ -23,6 +22,8 @@ export declare function initialize(request: InitRequest): Promise<{
23
22
  referencedFiles: readonly string[];
24
23
  compilerOptions: {
25
24
  allowJs: boolean | undefined;
25
+ isolatedModules: boolean | undefined;
26
+ sourceMap: boolean | undefined;
26
27
  };
27
28
  }>;
28
29
  export declare function diagnose(modes: DiagnosticModes): Promise<{
@@ -10,7 +10,10 @@ 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.update = exports.emit = exports.diagnose = exports.initialize = void 0;
13
+ exports.initialize = initialize;
14
+ exports.diagnose = diagnose;
15
+ exports.emit = emit;
16
+ exports.update = update;
14
17
  const node_assert_1 = __importDefault(require("node:assert"));
15
18
  const node_crypto_1 = require("node:crypto");
16
19
  const node_worker_threads_1 = require("node:worker_threads");
@@ -67,24 +70,24 @@ async function initialize(request) {
67
70
  });
68
71
  return {
69
72
  referencedFiles,
70
- // TODO: Expand? `allowJs` is the only field needed currently.
71
- compilerOptions: { allowJs: compilerOptions.allowJs },
73
+ // TODO: Expand? `allowJs`, `isolatedModules`, `sourceMap` are the only fields needed currently.
74
+ compilerOptions: {
75
+ allowJs: compilerOptions.allowJs,
76
+ isolatedModules: compilerOptions.isolatedModules,
77
+ sourceMap: compilerOptions.sourceMap,
78
+ },
72
79
  };
73
80
  }
74
- exports.initialize = initialize;
75
81
  async function diagnose(modes) {
76
82
  (0, node_assert_1.default)(compilation);
77
83
  const diagnostics = await compilation.diagnoseFiles(modes);
78
84
  return diagnostics;
79
85
  }
80
- exports.diagnose = diagnose;
81
86
  async function emit() {
82
87
  (0, node_assert_1.default)(compilation);
83
88
  const files = await compilation.emitAffectedFiles();
84
89
  return [...files];
85
90
  }
86
- exports.emit = emit;
87
91
  function update(files) {
88
92
  sourceFileCache.invalidate(files);
89
93
  }
90
- exports.update = update;
@@ -7,7 +7,8 @@
7
7
  * found in the LICENSE file at https://angular.io/license
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.getSharedCompilationState = exports.SharedTSCompilationState = void 0;
10
+ exports.SharedTSCompilationState = void 0;
11
+ exports.getSharedCompilationState = getSharedCompilationState;
11
12
  class SharedTSCompilationState {
12
13
  #pendingCompilation = true;
13
14
  #resolveCompilationReady;
@@ -41,4 +42,3 @@ let globalSharedCompilationState;
41
42
  function getSharedCompilationState() {
42
43
  return (globalSharedCompilationState ??= new SharedTSCompilationState());
43
44
  }
44
- exports.getSharedCompilationState = getSharedCompilationState;
@@ -33,7 +33,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
33
33
  return (mod && mod.__esModule) ? mod : { "default": mod };
34
34
  };
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.createCompilerPlugin = void 0;
36
+ exports.createCompilerPlugin = createCompilerPlugin;
37
37
  const node_assert_1 = __importDefault(require("node:assert"));
38
38
  const path = __importStar(require("node:path"));
39
39
  const environment_options_1 = require("../../../utils/environment-options");
@@ -78,6 +78,8 @@ function createCompilerPlugin(pluginOptions, styleOptions) {
78
78
  let hasCompilationErrors = true;
79
79
  // Determines if TypeScript should process JavaScript files based on tsconfig `allowJs` option
80
80
  let shouldTsIgnoreJs = true;
81
+ // Determines if transpilation should be handle by TypeScript or esbuild
82
+ let useTypeScriptTranspilation = true;
81
83
  // Track incremental component stylesheet builds
82
84
  const stylesheetBundler = new component_stylesheets_1.ComponentStylesheetBundler(styleOptions, pluginOptions.incremental);
83
85
  let sharedTSCompilationState;
@@ -180,6 +182,11 @@ function createCompilerPlugin(pluginOptions, styleOptions) {
180
182
  try {
181
183
  const initializationResult = await compilation.initialize(pluginOptions.tsconfig, hostOptions, createCompilerOptionsTransformer(setupWarnings, pluginOptions, preserveSymlinks));
182
184
  shouldTsIgnoreJs = !initializationResult.compilerOptions.allowJs;
185
+ // Isolated modules option ensures safe non-TypeScript transpilation.
186
+ // Typescript printing support for sourcemaps is not yet integrated.
187
+ useTypeScriptTranspilation =
188
+ !initializationResult.compilerOptions.isolatedModules ||
189
+ !!initializationResult.compilerOptions.sourceMap;
183
190
  referencedFiles = initializationResult.referencedFiles;
184
191
  }
185
192
  catch (error) {
@@ -250,8 +257,9 @@ function createCompilerPlugin(pluginOptions, styleOptions) {
250
257
  });
251
258
  build.onLoad({ filter: /\.[cm]?[jt]sx?$/ }, async (args) => {
252
259
  const request = path.normalize(pluginOptions.fileReplacements?.[path.normalize(args.path)] ?? args.path);
260
+ const isJS = /\.[cm]?js$/.test(request);
253
261
  // Skip TS load attempt if JS TypeScript compilation not enabled and file is JS
254
- if (shouldTsIgnoreJs && /\.[cm]?js$/.test(request)) {
262
+ if (shouldTsIgnoreJs && isJS) {
255
263
  return undefined;
256
264
  }
257
265
  // The filename is currently used as a cache key. Since the cache is memory only,
@@ -267,7 +275,7 @@ function createCompilerPlugin(pluginOptions, styleOptions) {
267
275
  }
268
276
  // No TS result indicates the file is not part of the TypeScript program.
269
277
  // If allowJs is enabled and the file is JS then defer to the next load hook.
270
- if (!shouldTsIgnoreJs && /\.[cm]?js$/.test(request)) {
278
+ if (!shouldTsIgnoreJs && isJS) {
271
279
  return undefined;
272
280
  }
273
281
  // Otherwise return an error
@@ -277,8 +285,9 @@ function createCompilerPlugin(pluginOptions, styleOptions) {
277
285
  ],
278
286
  };
279
287
  }
280
- else if (typeof contents === 'string') {
281
- // A string indicates untransformed output from the TS/NG compiler
288
+ else if (typeof contents === 'string' && (useTypeScriptTranspilation || isJS)) {
289
+ // A string indicates untransformed output from the TS/NG compiler.
290
+ // This step is unneeded when using esbuild transpilation.
282
291
  const sideEffects = await hasSideEffects(request);
283
292
  contents = await javascriptTransformer.transformData(request, contents, true /* skipLinker */, sideEffects);
284
293
  // Store as the returned Uint8Array to allow caching the fully transformed code
@@ -286,7 +295,7 @@ function createCompilerPlugin(pluginOptions, styleOptions) {
286
295
  }
287
296
  return {
288
297
  contents,
289
- loader: 'js',
298
+ loader: useTypeScriptTranspilation || isJS ? 'js' : 'ts',
290
299
  };
291
300
  });
292
301
  build.onLoad({ filter: /\.[cm]?js$/ }, (0, load_result_cache_1.createCachedLoad)(pluginOptions.loadResultCache, async (args) => {
@@ -344,7 +353,6 @@ function createCompilerPlugin(pluginOptions, styleOptions) {
344
353
  },
345
354
  };
346
355
  }
347
- exports.createCompilerPlugin = createCompilerPlugin;
348
356
  function createCompilerOptionsTransformer(setupWarnings, pluginOptions, preserveSymlinks) {
349
357
  return (compilerOptions) => {
350
358
  // target of 9 is ES2022 (using the number avoids an expensive import of typescript just for an enum)
@@ -7,7 +7,7 @@
7
7
  * found in the LICENSE file at https://angular.io/license
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.convertTypeScriptDiagnostic = void 0;
10
+ exports.convertTypeScriptDiagnostic = convertTypeScriptDiagnostic;
11
11
  const node_os_1 = require("node:os");
12
12
  /**
13
13
  * Converts TypeScript Diagnostic related information into an esbuild compatible note object.
@@ -66,4 +66,3 @@ function convertTypeScriptDiagnostic(typescript, diagnostic) {
66
66
  }
67
67
  return message;
68
68
  }
69
- exports.convertTypeScriptDiagnostic = convertTypeScriptDiagnostic;
@@ -7,7 +7,7 @@
7
7
  * found in the LICENSE file at https://angular.io/license
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.setupJitPluginCallbacks = void 0;
10
+ exports.setupJitPluginCallbacks = setupJitPluginCallbacks;
11
11
  const promises_1 = require("node:fs/promises");
12
12
  const node_path_1 = require("node:path");
13
13
  const load_result_cache_1 = require("../load-result-cache");
@@ -114,4 +114,3 @@ function setupJitPluginCallbacks(build, stylesheetBundler, additionalResultFiles
114
114
  };
115
115
  }));
116
116
  }
117
- exports.setupJitPluginCallbacks = setupJitPluginCallbacks;
@@ -10,7 +10,7 @@ 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.createJitResourceTransformer = void 0;
13
+ exports.createJitResourceTransformer = createJitResourceTransformer;
14
14
  const typescript_1 = __importDefault(require("typescript"));
15
15
  const uri_1 = require("./uri");
16
16
  /**
@@ -50,7 +50,6 @@ function createJitResourceTransformer(getTypeChecker) {
50
50
  };
51
51
  };
52
52
  }
53
- exports.createJitResourceTransformer = createJitResourceTransformer;
54
53
  function visitDecorator(nodeFactory, node, typeChecker, resourceImportDeclarations) {
55
54
  const origin = getDecoratorOrigin(node, typeChecker);
56
55
  if (!origin || origin.module !== '@angular/core' || origin.name !== 'Component') {
@@ -7,7 +7,10 @@
7
7
  * found in the LICENSE file at https://angular.io/license
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.parseJitUri = exports.generateJitInlineUri = exports.generateJitFileUri = exports.JIT_NAMESPACE_REGEXP = exports.JIT_TEMPLATE_NAMESPACE = exports.JIT_STYLE_NAMESPACE = void 0;
10
+ exports.JIT_NAMESPACE_REGEXP = exports.JIT_TEMPLATE_NAMESPACE = exports.JIT_STYLE_NAMESPACE = void 0;
11
+ exports.generateJitFileUri = generateJitFileUri;
12
+ exports.generateJitInlineUri = generateJitInlineUri;
13
+ exports.parseJitUri = parseJitUri;
11
14
  /**
12
15
  * A string value representing the base namespace for Angular JIT mode related imports.
13
16
  */
@@ -39,7 +42,6 @@ exports.JIT_NAMESPACE_REGEXP = new RegExp(`^${JIT_BASE_NAMESPACE}:(template|styl
39
42
  function generateJitFileUri(file, type) {
40
43
  return `${JIT_BASE_NAMESPACE}:${type}:file;${file}`;
41
44
  }
42
- exports.generateJitFileUri = generateJitFileUri;
43
45
  /**
44
46
  * Generates an Angular JIT mode namespace URI for a given inline style or template.
45
47
  * The provided content is base64 encoded and included in the URI.
@@ -50,7 +52,6 @@ exports.generateJitFileUri = generateJitFileUri;
50
52
  function generateJitInlineUri(data, type) {
51
53
  return `${JIT_BASE_NAMESPACE}:${type}:inline;${Buffer.from(data).toString('base64')}`;
52
54
  }
53
- exports.generateJitInlineUri = generateJitInlineUri;
54
55
  /**
55
56
  * Parses a string containing a JIT namespace URI.
56
57
  * JIT namespace URIs are used to encode the information for an Angular component's stylesheets
@@ -71,4 +72,3 @@ function parseJitUri(uri) {
71
72
  specifier: matches[3],
72
73
  };
73
74
  }
74
- exports.parseJitUri = parseJitUri;
@@ -10,7 +10,7 @@ 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.createWorkerTransformer = void 0;
13
+ exports.createWorkerTransformer = createWorkerTransformer;
14
14
  const typescript_1 = __importDefault(require("typescript"));
15
15
  /**
16
16
  * Creates a TypeScript Transformer to process Worker and SharedWorker entry points and transform
@@ -91,4 +91,3 @@ function createWorkerTransformer(fileProcessor) {
91
91
  };
92
92
  };
93
93
  }
94
- exports.createWorkerTransformer = createWorkerTransformer;
@@ -10,7 +10,10 @@ 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.createServerPolyfillBundleOptions = exports.createServerCodeBundleOptions = exports.createBrowserPolyfillBundleOptions = exports.createBrowserCodeBundleOptions = void 0;
13
+ exports.createBrowserCodeBundleOptions = createBrowserCodeBundleOptions;
14
+ exports.createBrowserPolyfillBundleOptions = createBrowserPolyfillBundleOptions;
15
+ exports.createServerCodeBundleOptions = createServerCodeBundleOptions;
16
+ exports.createServerPolyfillBundleOptions = createServerPolyfillBundleOptions;
14
17
  const node_assert_1 = __importDefault(require("node:assert"));
15
18
  const node_crypto_1 = require("node:crypto");
16
19
  const promises_1 = require("node:fs/promises");
@@ -66,7 +69,6 @@ function createBrowserCodeBundleOptions(options, target, sourceFileCache) {
66
69
  }
67
70
  return buildOptions;
68
71
  }
69
- exports.createBrowserCodeBundleOptions = createBrowserCodeBundleOptions;
70
72
  function createBrowserPolyfillBundleOptions(options, target, sourceFileCache) {
71
73
  const namespace = 'angular:polyfills';
72
74
  const polyfillBundleOptions = getEsBuildCommonPolyfillsOptions(options, namespace, true, sourceFileCache);
@@ -104,7 +106,6 @@ function createBrowserPolyfillBundleOptions(options, target, sourceFileCache) {
104
106
  // cannot be used with fully incremental bundling yet.
105
107
  return hasTypeScriptEntries ? buildOptions : () => buildOptions;
106
108
  }
107
- exports.createBrowserPolyfillBundleOptions = createBrowserPolyfillBundleOptions;
108
109
  /**
109
110
  * Create an esbuild 'build' options object for the server bundle.
110
111
  * @param options The builder's user-provider normalized options.
@@ -185,7 +186,6 @@ function createServerCodeBundleOptions(options, target, sourceFileCache) {
185
186
  }
186
187
  return buildOptions;
187
188
  }
188
- exports.createServerCodeBundleOptions = createServerCodeBundleOptions;
189
189
  function createServerPolyfillBundleOptions(options, target, sourceFileCache) {
190
190
  const serverPolyfills = [];
191
191
  const polyfillsFromConfig = new Set(options.polyfills);
@@ -230,7 +230,6 @@ function createServerPolyfillBundleOptions(options, target, sourceFileCache) {
230
230
  };
231
231
  return () => buildOptions;
232
232
  }
233
- exports.createServerPolyfillBundleOptions = createServerPolyfillBundleOptions;
234
233
  function getEsBuildCommonOptions(options) {
235
234
  const { workspaceRoot, outExtension, optimizationOptions, sourcemapOptions, tsconfig, externalDependencies, outputNames, preserveSymlinks, jit, loaderExtensions, jsonLogs, } = options;
236
235
  // Ensure unique hashes for i18n translation changes when using post-process inlining.
@@ -7,7 +7,7 @@
7
7
  * found in the LICENSE file at https://angular.io/license
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.generateBudgetStats = void 0;
10
+ exports.generateBudgetStats = generateBudgetStats;
11
11
  const node_path_1 = require("node:path");
12
12
  /**
13
13
  * Generates a bundle budget calculator compatible stats object that provides
@@ -56,4 +56,3 @@ function generateBudgetStats(metafile, initialFiles) {
56
56
  }
57
57
  return stats;
58
58
  }
59
- exports.generateBudgetStats = generateBudgetStats;
@@ -7,7 +7,7 @@
7
7
  * found in the LICENSE file at https://angular.io/license
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.checkCommonJSModules = void 0;
10
+ exports.checkCommonJSModules = checkCommonJSModules;
11
11
  /**
12
12
  * Checks the input files of a build to determine if any of the files included
13
13
  * in the build are not ESM. ESM files can be tree-shaken and otherwise optimized
@@ -107,7 +107,6 @@ function checkCommonJSModules(metafile, allowedCommonJsDependencies) {
107
107
  }
108
108
  return messages;
109
109
  }
110
- exports.checkCommonJSModules = checkCommonJSModules;
111
110
  /**
112
111
  * Determines if a file path has an extension that is a JavaScript or TypeScript
113
112
  * code file.
@@ -7,7 +7,7 @@
7
7
  * found in the LICENSE file at https://angular.io/license
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.createCompilerPluginOptions = void 0;
10
+ exports.createCompilerPluginOptions = createCompilerPluginOptions;
11
11
  function createCompilerPluginOptions(options, target, sourceFileCache) {
12
12
  const { workspaceRoot, optimizationOptions, sourcemapOptions, tsconfig, outputNames, fileReplacements, externalDependencies, preserveSymlinks, stylePreprocessorOptions, advancedOptimizations, inlineStyleLanguage, jit, cacheOptions, tailwindConfiguration, postcssConfiguration, publicPath, } = options;
13
13
  return {
@@ -46,4 +46,3 @@ function createCompilerPluginOptions(options, target, sourceFileCache) {
46
46
  },
47
47
  };
48
48
  }
49
- exports.createCompilerPluginOptions = createCompilerPluginOptions;
@@ -7,7 +7,7 @@
7
7
  * found in the LICENSE file at https://angular.io/license
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.createExternalPackagesPlugin = void 0;
10
+ exports.createExternalPackagesPlugin = createExternalPackagesPlugin;
11
11
  const node_path_1 = require("node:path");
12
12
  const EXTERNAL_PACKAGE_RESOLUTION = Symbol('EXTERNAL_PACKAGE_RESOLUTION');
13
13
  /**
@@ -72,4 +72,3 @@ function createExternalPackagesPlugin(options) {
72
72
  },
73
73
  };
74
74
  }
75
- exports.createExternalPackagesPlugin = createExternalPackagesPlugin;
@@ -33,7 +33,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
33
33
  return (mod && mod.__esModule) ? mod : { "default": mod };
34
34
  };
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.createGlobalScriptsBundleOptions = void 0;
36
+ exports.createGlobalScriptsBundleOptions = createGlobalScriptsBundleOptions;
37
37
  const magic_string_1 = __importStar(require("magic-string"));
38
38
  const node_assert_1 = __importDefault(require("node:assert"));
39
39
  const promises_1 = require("node:fs/promises");
@@ -139,4 +139,3 @@ function createGlobalScriptsBundleOptions(options, target, initial) {
139
139
  };
140
140
  };
141
141
  }
142
- exports.createGlobalScriptsBundleOptions = createGlobalScriptsBundleOptions;
@@ -10,7 +10,7 @@ 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.createGlobalStylesBundleOptions = void 0;
13
+ exports.createGlobalStylesBundleOptions = createGlobalStylesBundleOptions;
14
14
  const node_assert_1 = __importDefault(require("node:assert"));
15
15
  const bundle_options_1 = require("./stylesheets/bundle-options");
16
16
  const virtual_module_plugin_1 = require("./virtual-module-plugin");
@@ -71,4 +71,3 @@ function createGlobalStylesBundleOptions(options, target, initial) {
71
71
  return buildOptions;
72
72
  };
73
73
  }
74
- exports.createGlobalStylesBundleOptions = createGlobalStylesBundleOptions;
@@ -35,7 +35,7 @@ export default function inlineLocale(request: InlineRequest): Promise<{
35
35
  code: string;
36
36
  map: string | undefined;
37
37
  messages: {
38
- type: "error" | "warning";
38
+ type: "warning" | "error";
39
39
  message: string;
40
40
  }[];
41
41
  }>;
@@ -10,6 +10,7 @@ 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
14
  const remapping_1 = __importDefault(require("@ampproject/remapping"));
14
15
  const core_1 = require("@babel/core");
15
16
  const node_assert_1 = __importDefault(require("node:assert"));
@@ -39,7 +40,6 @@ async function inlineLocale(request) {
39
40
  messages: result.diagnostics.messages,
40
41
  };
41
42
  }
42
- exports.default = inlineLocale;
43
43
  /**
44
44
  * Cached instance of the `@angular/localize/tools` module.
45
45
  * This is used to remove the need to repeatedly import the module per file translation.
@@ -7,7 +7,8 @@
7
7
  * found in the LICENSE file at https://angular.io/license
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.createAngularLocaleDataPlugin = exports.LOCALE_DATA_BASE_MODULE = exports.LOCALE_DATA_NAMESPACE = void 0;
10
+ exports.LOCALE_DATA_BASE_MODULE = exports.LOCALE_DATA_NAMESPACE = void 0;
11
+ exports.createAngularLocaleDataPlugin = createAngularLocaleDataPlugin;
11
12
  /**
12
13
  * The internal namespace used by generated locale import statements and Angular locale data plugin.
13
14
  */
@@ -117,4 +118,3 @@ function createAngularLocaleDataPlugin() {
117
118
  },
118
119
  };
119
120
  }
120
- exports.createAngularLocaleDataPlugin = createAngularLocaleDataPlugin;
@@ -10,7 +10,7 @@ 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.generateIndexHtml = void 0;
13
+ exports.generateIndexHtml = generateIndexHtml;
14
14
  const node_assert_1 = __importDefault(require("node:assert"));
15
15
  const node_path_1 = __importDefault(require("node:path"));
16
16
  const index_html_generator_1 = require("../../utils/index-file/index-html-generator");
@@ -89,4 +89,3 @@ async function generateIndexHtml(initialFiles, outputFiles, buildOptions, lang)
89
89
  hints,
90
90
  });
91
91
  }
92
- exports.generateIndexHtml = generateIndexHtml;
@@ -33,6 +33,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
33
33
  return (mod && mod.__esModule) ? mod : { "default": mod };
34
34
  };
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.default = transformJavaScript;
36
37
  const core_1 = require("@babel/core");
37
38
  const node_fs_1 = __importDefault(require("node:fs"));
38
39
  const node_path_1 = __importDefault(require("node:path"));
@@ -47,7 +48,6 @@ async function transformJavaScript(request) {
47
48
  // Transfer the data via `move` instead of cloning
48
49
  return piscina_1.default.move(textEncoder.encode(transformedData));
49
50
  }
50
- exports.default = transformJavaScript;
51
51
  /**
52
52
  * Cached instance of the compiler-cli linker's createEs2015LinkerPlugin function.
53
53
  */