Rewrite import specifiers to use .ts extensions, remove tsx#1548
Rewrite import specifiers to use .ts extensions, remove tsx#1548webpro merged 11 commits intowebpro-nl:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR converts import specifiers from using .js extensions to .ts extensions throughout the TypeScript codebase. The change modernizes the import system to leverage TypeScript 5.7's native support for .ts extensions with the rewriteRelativeImportExtensions compiler option, removing the need for runtime extension rewriting.
Changes:
- Updated all relative import statements to use
.tsextensions instead of.js - Modified TypeScript configuration to enable
allowImportingTsExtensionsandrewriteRelativeImportExtensions - Removed
tsxdependency from package.json in favor of native Node.js execution - Updated plugin generation scripts to output imports with
.tsextensions
Reviewed changes
Copilot reviewed 300 out of 744 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/knip/src/**/*.ts | Changed all relative imports from .js to .ts extensions |
| packages/knip/scripts/tsconfig.json | Added compiler options for TypeScript 5.7's .ts extension support |
| packages/knip/package.json | Removed tsx dependency and updated test scripts to use native Node |
| packages/docs/package.json | Updated build script to use Node instead of tsx |
| packages/knip/scripts/generate-plugin-defs.js | Modified to generate imports with .ts extensions |
commit: |
# Conflicts: # packages/knip/src/plugins/index.ts
568c207 to
0a71633
Compare
|
We could leave in |
|
Hint on node -e: https://bsky.app/profile/wojtekmaj.pl/post/3mf5mhsxros2v |
So, like... Rolling back all the changes? Yeah that's what I was afraid of when thinking about Node.js 18 and thought we might wanna wait and just try a PoC :D |
|
No I mean only like I did in the TS 5.0.4 pipeline, it's all green now |
|
Oh wait dumb oversight on my end. Would still publish with .ts everywhere 🙈 |
|
Looks like |
Yeah, this option will indeed do exactly what we want. I just need to resolve conflicts carefully... |
|
Let's go! Thanks a bunch. |
|
🚀 This pull request is included in v5.86.0. See Release 5.86.0 for release notes. Using Knip in a commercial project? Please consider becoming a sponsor. |
Follow-up after discussion in #1541
Likely to fail on older versions of Node (<22.18.0) and/or TypeScript (<5.7), will have to figure out what to do with tests (prebuild on newer version before running on older one? freezing this PR until Node.js 20 is dropped?)
Script used for mass rewrite