module: refactor commonjs typescript loader#58657
module: refactor commonjs typescript loader#58657nodejs-github-bot merged 2 commits intonodejs:mainfrom
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:
|
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>
|
With this change, how should a library detect if the current node has enabled builtin strip-types support? Should a library do the version check? Previously in Babel we checked |
|
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: nodejs#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>
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: nodejs#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>
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: nodejs#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>
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 Backport-PR-URL: #57298 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> PR-URL: #56350 Fixes: nodejs/typescript#17
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 Backport-PR-URL: #57298 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> PR-URL: #56350 Fixes: nodejs/typescript#17
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._extensionsthe 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: