Switch from `node12` to `node16` to avoid top-level await issues
DanielRosenwasser opened this issue · 9 comments
Today, --moduleResolution node12
is a pit-of-failure experience because Node.js 12 is already oldish and doesn't support top-level await
. This was brought up in #46452 (and in this comment #46452 (comment))
Before TypeScript 4.7 RC, we should remove node12
as an option and provide a node16
option instead.`
I get wanting a newer numbered node
version (and am all for it); but is there a reason to remove the node12
support? It's the first node
version with native esm support, and it has some important caveats in its resolution (in addition to the whole no-TLA thing) that are fixed or changed by later versions.
It's the first
node
version with native esm support, and it has some important caveats in its resolution (in addition to the whole no-TLA thing) that are fixed or changed by later versions.
The way I see it, every time a user has to decide between these, and every time we have to list every possible option, is a place where dropping node12
and starting at node14
/node16
could improve those experiences. So let's not provide awkward middle grounds leading up to the experience that most users will want, and let's not obligate ourselves to supporting the caveats either of Node 12 either.
You don't see users wanting to support every node version that supports esm format source code?
Like, I'm all for nodenext
being the preferred mode - you really don't have a good reason to not track latest node unless you're building for maximal compatibility.
Well people need a stable target. I just think we have a decent amount of agreement on #46452 (comment) around dropping node12
in favor of a later version which would both allow us to shed some extra corner-cases and remove a step of friction for users.
node16
will be the first node version to support https
imports in it's release line, as an FYI.
FYI @DanielRosenwasser TLA in node is still documented as experimental even in 18 (though there's an open PR to stabilize it in the 18 timeframe since it's officially stabilized in v8). If we respect the docs, we shouldn't even allow TLA in a hypothetical node18 just yet.
@DanielRosenwasser @weswigham
node v12
has reached end-of-life April 30th 2022 https://nodejs.org/en/about/releases/ it's probably a good idea to drop node12
altogether and move to node16
directly for TypeScript v4.7
.
After this change, a nightly, RC, or stable version of TypeScript will issue the following error message:
error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node16', 'nodenext'.
error TS6046: Argument for '--moduleResolution' option must be: 'node', 'classic', 'node16', 'nodenext'.
Instead of node12
, you should switch to node16
or nodenext
.