File: nodenextNode16.md

package info (click to toggle)
ts-node 10.9.2%2B~cs64.13.20-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,388 kB
  • sloc: javascript: 15,071; sh: 83; makefile: 15; xml: 9
file content (53 lines) | stat: -rw-r--r-- 1,491 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# 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 `getOutput` emits, done
- else call `nodeModuleTypeClassifier`
  - delegate to appropriate `getOutput` based on its response