Skip to content

Commit 6a19c21

Browse files
committedJan 14, 2025·
fix(@angular/build): warn when using both isolatedModules and emitDecoratorMetadata
If both the `isolatedModules` and `emitDecoratorMetadata` Typescript options are enabled within a project, a warning will now be issued explaining that not all metadata may be emitting for each decorator. Isolated modules may not have access to non-local type information that would otherwise be needed for complete metadata emit. The `emitDecoratorMetadata` option is not required by Angular and can cause runtime errors due to its underlying implementation when used with ES2015+ output. The option is only compatible with the experimental decorators and cannot be used with standard decorators. New Angular projects also do not enable this option. (cherry picked from commit 61e8185)
1 parent d52f853 commit 6a19c21

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
 

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

+14
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,20 @@ function createCompilerOptionsTransformer(
689689
});
690690
}
691691

692+
if (compilerOptions.isolatedModules && compilerOptions.emitDecoratorMetadata) {
693+
setupWarnings?.push({
694+
text: `TypeScript compiler option 'isolatedModules' may prevent the 'emitDecoratorMetadata' option from emitting all metadata.`,
695+
location: null,
696+
notes: [
697+
{
698+
text:
699+
`The 'emitDecoratorMetadata' option is not required by Angular` +
700+
'and can be removed if not explictly required by the project.',
701+
},
702+
],
703+
});
704+
}
705+
692706
// Synchronize custom resolve conditions.
693707
// Set if using the supported bundler resolution mode (bundler is the default in new projects)
694708
if (compilerOptions.moduleResolution === 100 /* ModuleResolutionKind.Bundler */) {

0 commit comments

Comments
 (0)
Please sign in to comment.