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
However, this has to change at some point because updating moduleResolution to a new version (nodenext or node16) is explicitly disallowed by typescript v5.2
This option providers looser restrictions with is meant to make it work well with bundlers (ex: webpack). More specifically, Application authors who use a bundler on their TS or JS files before a runtime consumes that bundle (ref)
This definitely describes us, as we currently bundle Paima either through esbuild when consumed with a game engine, or webpack when consumed by a frontend. It could also help with PaimaStudios/paima-game-templates#46. However, at the same time, this option sounds like it is discouraged for library authors who are emitting JS for other people to consume (which is also us)
Contrary to what you might think, setting module: nodenext doesn't actually set the module mode to nodenext. Rather, it's decided by the package.json for the package so it means we will still be using esnext by default (ref)
This option has the best interop with NodeJS environments, but dual publishing your library as a CJS and ESM package with this configuration without resorting to a bunch of hacky behavior seems like an open issue, and this option is trickier to combine with bundlers which causes issues like mentioned in PaimaStudios/paima-game-templates#46.
What to do?
Given it seems like things are a total mess in the JS build tool world, it might be better to just not do anything for now and try to stick with the existing configuration until future versions of tools improve things (but given the JS tooling ecosystem history, I feel like it just gets worse every year)
Blockers
Codegen tools need to also support ESM modules for this migration to work. This leaves the following blocks:
typechain doesn't support ESM output for web3 (only ethers) at the moment, but this should be solved by Migrate away from web3.js #293
The text was updated successfully, but these errors were encountered:
Currently for our build system we use
However, this has to change at some point because updating
moduleResolution
to a new version (nodenext
ornode16
) is explicitly disallowed by typescript v5.2Instead, it appears we have two options:
Option 1:
moduleResolution: bundler
&module: esnext
This option providers looser restrictions with is meant to make it work well with bundlers (ex: webpack). More specifically,
Application authors who use a bundler on their TS or JS files before a runtime consumes that bundle
(ref)This definitely describes us, as we currently bundle Paima either through
esbuild
when consumed with a game engine, or webpack when consumed by a frontend. It could also help with PaimaStudios/paima-game-templates#46. However, at the same time, this option sounds like it is discouraged for library authors who are emitting JS for other people to consume (which is also us)Option 2:
moduleResolution: nodenext
&module: nodenext
Contrary to what you might think, setting
module: nodenext
doesn't actually set the module mode to nodenext. Rather, it's decided by thepackage.json
for the package so it means we will still be using esnext by default (ref)This option has the best interop with NodeJS environments, but dual publishing your library as a CJS and ESM package with this configuration without resorting to a bunch of hacky behavior seems like an open issue, and this option is trickier to combine with bundlers which causes issues like mentioned in PaimaStudios/paima-game-templates#46.
What to do?
Given it seems like things are a total mess in the JS build tool world, it might be better to just not do anything for now and try to stick with the existing configuration until future versions of tools improve things (but given the JS tooling ecosystem history, I feel like it just gets worse every year)
Blockers
Codegen tools need to also support ESM modules for this migration to work. This leaves the following blocks:
typechain
doesn't support ESM output for web3 (only ethers) at the moment, but this should be solved by Migrate away from web3.js #293The text was updated successfully, but these errors were encountered: