Skip to content

Commit 40322c5

Browse files
committed
fix(@angular/build): return direct file contents for non-Angular TypeScript files
When a TypeScript file is requested that was not emitted by the TypeScript program compiler (`contents === undefined`), the compiler plugin checks whether the file requires Angular compiler transformations via `requiresAngularCompiler(directContents)`. If the file does not require the Angular compiler, the load hook returns an object with `loader: 'ts'` and a missing file warning so esbuild can compile it directly. However, it previously returned `contents` (which was still `undefined`) instead of `directContents` (which was read directly from disk via `readFile`). This caused esbuild to receive an empty/undefined content object rather than the actual file source code. This change ensures `contents: directContents` is returned so esbuild can properly transpile the file.
1 parent ecf8c08 commit 40322c5

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

packages/angular/build/src/tools/esbuild/angular/compiler-plugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ export function createCompilerPlugin(
456456
if (!requiresAngularCompiler(directContents)) {
457457
return {
458458
warnings: [createMissingFileDiagnostic(request, args.path, diangosticRoot, false)],
459-
contents,
459+
contents: directContents,
460460
loader: 'ts',
461461
resolveDir: path.dirname(request),
462462
};

0 commit comments

Comments
 (0)