-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
module: refactor commonjs typescript loader #58657
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
module: refactor commonjs typescript loader #58657
Conversation
This commit refactors the CommonJS loader to remove TypeScript-specific extensions from the require.extensions object for compatibility with libraries that depended on it to initialize extenal TypeScript loaders.
Review requested:
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #58657 +/- ##
=======================================
Coverage 90.14% 90.15%
=======================================
Files 636 636
Lines 188030 187953 -77
Branches 36894 36882 -12
=======================================
- Hits 169506 169451 -55
+ Misses 11276 11268 -8
+ Partials 7248 7234 -14
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Co-authored-by: Joyee Cheung <joyeec9h3@gmail.com>
@marco-ippolito great job! may I ask whether this compatible fix be backported to Node.js 23&24? we're willing to migrate to native typescript support but a easier progressive migration is always preferred. |
v24 yes in the next release |
Landed in 708477b |
This commit refactors the CommonJS loader to remove TypeScript-specific extensions from the require.extensions object for compatibility with libraries that depended on it to initialize extenal TypeScript loaders. PR-URL: #58657 Refs: nodejs/typescript#37 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com> Reviewed-By: Xuguang Mei <meixuguang@gmail.com>
Refs: nodejs/typescript#37
As suggested by @joyeecheung nodejs/typescript#37 (comment), we can refactor the commonjs loader so that we dont have to expose in the
Module._extensions
the TypeScript file extensions.This should unblock the backport of Type Stripping in Node v22.
I tested it against @hardfist https://github.com/hardfist/webpack-ts-break and it fixes the breaking change: