eemeli / yaml

YAML parser and stringifier for JavaScript
https://eemeli.org/yaml
ISC License
1.32k stars 116 forks source link

Use .ts extension in relative source imports #591

Open eemeli opened 3 days ago

eemeli commented 3 days ago

This change adopts the --rewriteRelativeImportExtensions option introduced in Typescript 5.7, and changes all relative paths to use the .ts extension.

Due to rollup/plugins#1820, a post-compilation transform is required to get the CLI tool to work right.

An ESLint rule is added to ensure that the .ts extension is always there; this may be of interest to others as well: https://github.com/eemeli/yaml/blob/18e611279076efdcd9f4984766d852b4e1f7db99/eslint.config.mjs#L41-L51

Together with explicit type on imports & exports, this change fixes #301 and makes the library work directly in Deno. A really simple Deno smoke test is included. It would be nice to get the full test suite to run on Deno as well, as discussed in https://github.com/eemeli/yaml/issues/301#issuecomment-2212045604

Ping @justinmchase & @jeff-hykin: Would you have time to see if this works as expected?

jeff-hykin commented 3 days ago

Yeah thanks for the ping! If I remeber once I'm at my PC I'll try it out

eemeli commented 3 days ago

Also needed to add an afterDeclarations transform to drop the .ts extensions from the imports in the .d.ts files, in order to retain compatibility with older TS versions.