Open Sti2nd opened 3 years ago
We're hoping that Node + ESM support will make it into TypeScript 4.5, https://github.com/microsoft/TypeScript/pull/44501 - so realistically I don't think we should be pushing that as the default here
That weird, I am successfully transpiling TypeScript with ESM and using it in Node 14, and TSC is emitting ESM as well. I thought the only thing needed to match between Node and TSC was the supported EcmaScript (target) version.
So obviously there is something that I am not understanding, and that is ok 🙂 Will wait for TypeScript 4.5 and see what happens.
Background: I created a new Node project and wanted to use
@tsconfig/node14
base in my tsconfig. As EcmaScript modules are fully supported in Node 14 I began using the ESM syntax and got a runtime error because the base specifies CommonJS as module system.I got the same error as this Stack Overflow post.
Discussion point: Since ESM is a stable feature in Node 14, should ESM also be the module system in the
@tsconfig/node14
? I think it makes sense. Also wrote something in a comment on the docs https://github.com/microsoft/TypeScript-Website/issues/1366#issuecomment-880128638.Lastly, I can add that overriding the base works by simply specifying the field you want to override in your own tsconfig.json. One can still use the base, so this is just a discussion about what should be the default.