You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Add experimentalSpecifierResolution to CLI flags, tsconfig, public API
* Make moduleTypes page link to https://www.typescriptlang.org/docs/handbook/esm-node.html
* Allow .jsx imports to remap to .tsx, the same way .js can map to .tsx
* improve experimentalResolver docs
* again tweak moduleTypeOverrides doc
* lint-fix
* tweak `experimentalResolver` docs
Copy file name to clipboardexpand all lines: website/docs/module-type-overrides.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -2,8 +2,8 @@
2
2
title: Module type overrides
3
3
---
4
4
5
-
> Wherever possible, it is recommended to use TypeScript's [`NodeNext` or `Node16` mode](https://devblogs.microsoft.com/typescript/announcing-typescript-4-7-rc/#ecmascript-module-support-in-node-js) instead of the options described
6
-
in this section. `NodeNext`, `.mts`, and `.cts` should work well for most projects.
5
+
> Wherever possible, it is recommended to use TypeScript's [`NodeNext` or `Node16` mode](https://www.typescriptlang.org/docs/handbook/esm-node.html) instead of the options described
6
+
in this section. Setting `"module": "NodeNext"`and using the `.cts` file extension should work well for most projects.
7
7
8
8
When deciding how a file should be compiled and executed -- as either CommonJS or native ECMAScript module -- ts-node matches
9
9
`node` and `tsc` behavior. This means TypeScript files are transformed according to your `tsconfig.json``"module"`
Copy file name to clipboardexpand all lines: website/docs/options.md
+26-2
Original file line number
Diff line number
Diff line change
@@ -369,11 +369,35 @@ Disable top-level await in REPL. Equivalent to node's [`--no-experimental-repl-
369
369
370
370
### experimentalResolver
371
371
372
-
Enable experimental features that re-map imports and require calls to support:`baseUrl`, `paths`, `rootDirs`, `.js` to `.ts` file extension mappings, `outDir` to `rootDir` mappings for composite projects and monorepos. For details, see [#1514](https://github.com/TypeStrong/ts-node/issues/1514)
372
+
Enable experimental hooks that re-map imports and require calls to support:
373
373
374
-
*Default:*`false`<br/>
374
+
* resolves `.js` to `.ts`, so that `import "./foo.js"` will execute `foo.ts`
375
+
* resolves `.cjs` to `.cts`
376
+
* resolves `.mjs` to `.mts`
377
+
* allows including file extensions in CommonJS, for consistency with ESM where this is often mandatory
378
+
379
+
In the future, this hook will also support:
380
+
381
+
*`baseUrl`, `paths`
382
+
*`rootDirs`
383
+
*`outDir` to `rootDir` mappings for composite projects and monorepos
384
+
385
+
For details, see [#1514](https://github.com/TypeStrong/ts-node/issues/1514).
386
+
387
+
*Default:*`false`, but will likely be enabled by default in a future version<br/>
375
388
*Can only be specified via `tsconfig.json` or API.*
376
389
390
+
### experimentalSpecifierResolution
391
+
392
+
```shell
393
+
ts-node --experimentalSpecifierResolution node
394
+
```
395
+
396
+
Like node's [`--experimental-specifier-resolution`](https://nodejs.org/dist/latest-v18.x/docs/api/esm.html#customizing-esm-specifier-resolution-algorithm), but can also be set in your `tsconfig.json` for convenience.
397
+
Requires `esm` to be enabled.
398
+
399
+
*Default:*`explicit`<br/>
400
+
377
401
## API Options
378
402
379
403
The API includes [additional options](https://typestrong.org/ts-node/api/interfaces/RegisterOptions.html) not shown here.
0 commit comments