mirror of
https://github.com/hanzoai/ts-node.git
synced 2026-10-30 19:36:25 +00:00
* feat: support .mts .cts * stuff * WIP with TODOs * WIP * lint-fix * WIP * WIP * WIP * fixes * flatten resolver tests by splitting into more functions * address extension-handling code * lint-fix * Fix; update resolver tests to test more things * fix * fix * test against TS rc on nodes 14, 16, 18 (good sanity-checking with these new nodenext features) * Teach ts.transpileModule to handle NodeNext correctly * tweak tests * fix test typos; update pluggable dep tests; update ignore() tests for new file extensions * fix tests * fix * fix build against stable ts, no need for 4.7.0 just yet * Gate nodenext/node16 tests behind a TS version check; fix TSCommon types * Fix nyc require.extensions issues * lint-fix * tricky types * skip nodenext tests on older TS * fix tests * fix bug and tests * fix windows * turn off another test on ancient TS versions * fix windows * fix allowing `moduleTypeOverrides` to override cts/cjs * Update moduleTypes docs * add mts and cts awareness to internal/external classifier; add .d.cts/.d.mts extensions to tests * cleanup misc markdown files * more markdown cleanup Co-authored-by: bluelovers <[email protected]>
1.5 KiB
1.5 KiB
Adding support for NodeNext, Node16, .cts, .mts, .cjs, .mjs
This feature has already been implemented. Here are my notes from when I was doing the work
TODOs
Implement node module type classifier:
- if NodeNext or Node12: ask classifier for CJS or ESM determination
Add
ForceNodeNextCJSEmit
Does our code check for .d.ts extensions anywhere?
- if so, teach it about .d.cts and .d.mts
For nodenext and node12, support supplemental "flavor" information:
Think about splitting out index.ts further:
- register.ts - hooking stuff
- types.ts
- env.ts - env vars and global registration types (process.symbol)
- service.ts
TESTS
Matrix:
- package.json type absent, commonjs, and module
- import and require
- from cjs and esm
- .cts, .cjs
- .mts, .mjs
- typechecking, transpileOnly, and swc
- dynamic import
- import = require
- static import
- allowJs on and off
Notes about specific matrix entries:
- require mjs, mts from cjs throws error
Rethink:
getOutput: null in transpile-only mode. Also may return emitskipped
getOutputTranspileOnly: configured module option
getOutputForceCommonJS: commonjs module option
getOutputForceNodeCommonJS: nodenext cjs module option
getOutputForceESM: esnext module option
Add second layer of classification to classifier:
if classifier returns auto (no moduleType override)
- if
getOutputemits, done - else call
nodeModuleTypeClassifier- delegate to appropriate
getOutputbased on its response
- delegate to appropriate