Closed cspotcode closed 2 years ago
With 4.5 beta announced 2 weeks ago, and the final on the horizon, time for us to do something.
@alvis are you referring to a pull request that you have submitted?
I've assigned this to @alvis and added it to our next milestone. Let us know if you need any guidance to implement the necessary changes. I've added some notes below.
At a minimum, you'll need to add require.extensions
hooks for mts
, mjs
, cts
, and cjs
extensions. You may also need to add them to the extensions passed to createResolve
:
https://github.com/TypeStrong/ts-node/blob/3b403651193c0ce942b215c44f6db805b4218f4c/src/esm.ts#L50-L54 https://github.com/TypeStrong/ts-node/blob/3b403651193c0ce942b215c44f6db805b4218f4c/src/index.ts#L482-L491
Should the new extensions be enabled conditionally, only when your TS version is >= 4.5?
I don't expect you'll need to implement any fancy resolving logic beyond that. TS already handles resolving within the typechecker, and node's existing resolution logic should continue to behave.
Will this mean that we can now potentially have import { foo } from './foo'
, basically omitting the extensions just like in commonJS
?
@PodaruDragos you're probably looking for node's --experimental-specifier-resolution=node
which we already support. Just as node requires you to pass that flag, we also require you to pass that flag, often via the NODE_OPTIONS
environment variable.
Will need work on our side to integrate.
https://github.com/microsoft/TypeScript/pull/44501 https://github.com/weswigham/TypeScript/pull/67
Roughly
adds new
module: node12
andmodule: nodeNext
configs In them:.mts
,.mjs
,.cts
,.cjs
force one or the other; ignore package.json "type" fieldQuestions I still have
Are any of the above assumed to be modules without needing to add
export {};
?