Typescript 4.7's "module": "Node16" yields invalid output or error for library build #46181
Labels
area: compiler
Issues related to `ngc`, Angular's template compiler
area: packaging
Issues related to Angular's creation of npm packages
bug
P3
An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
state: confirmed
Milestone
Which @angular/* package(s) are the source of the bug?
compiler-cli
Is this a regression?
No
Description
Using typescript 4.7's
"module": "Node16"
in a library yields errors or invalid output:Without
"type": "module"
inpackage.json
with all files given the.mts
file extension an error is generated by@angular/compiler-cli
:With
"type": "module"
inpackage.json
the generated bundle index is emitted as CJS instead of ESM, which results in invalid FESM files. Coincidentally, the generated CJS bundle index file contains inline tslib helpers, even with"importHelpers": true
in the tsconfig.Note that ng-packagr actually outputs all files as CJS instead of ESM. That seems to be an issue with ng-packagr itself, as other library pipeline(s) don't show the same behaviour. The generated bundle file is always CJS, regardless of tooling.
Generated bundle index file
± empty FESM2020 file generated by ng-packagr
invalid FESM2020 file generated by other library pipeline (not included in repro repo)
A clear error message would be helpful if the Node16 module/moduleResolution is not supported (yet).
Please provide a link to a minimal reproduction of the bug
https://github.com/bgotink/angular-typescript-4.7-Node16
Please provide the exception or error you saw
No response
Please provide the environment you discovered this bug in (run
ng version
)Anything else?
No response
The text was updated successfully, but these errors were encountered: