Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tsconfig build settings #233

Open
SebastienGllmt opened this issue Oct 8, 2023 · 0 comments
Open

Update tsconfig build settings #233

SebastienGllmt opened this issue Oct 8, 2023 · 0 comments
Labels
help wanted Extra attention is needed

Comments

@SebastienGllmt
Copy link
Contributor

SebastienGllmt commented Oct 8, 2023

Currently for our build system we use

"module": "ESNext",
"moduleResolution": "node",

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

Instead, 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 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:

@SebastienGllmt SebastienGllmt added the help wanted Extra attention is needed label Oct 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant