Skip to content

Update tsconfig build settings #233

Open
@SebastienGllmt

Description

@SebastienGllmt

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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions