Skip to content

Commit a142f6f

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. (cherry picked from commit 3eba6f7)
1 parent d4a48e3 commit a142f6f

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
@@ -459,7 +459,7 @@ export function createCompilerPlugin(
459459
if (!requiresAngularCompiler(directContents)) {
460460
return {
461461
warnings: [createMissingFileDiagnostic(request, args.path, diangosticRoot, false)],
462-
contents,
462+
contents: directContents,
463463
loader: 'ts',
464464
resolveDir: path.dirname(request),
465465
};

0 commit comments

Comments
 (0)