Skip to content

Conversation

@TheMrCam
Copy link
Collaborator

Overview

Consolidates the shared tsc settings into tsconfig.json, and specific build settings into tsconfig.module.json and tsconfig.node.json.

Aims to resolve #493.

Details

Aside from updating to ES2020 in dist-node and the addition of sourceMaps in dist-module, this should not alter the build or exports.

tsconfig

  • tsconfig.json: shared compilerOptions between build:module and build:node. Does not reference any files, or specify an output.
  • tsconfig.module.json: input & output settings for src -> dist-module compilation.
  • tsconfig.node.json: input & output settings for dist-module -> dist-node recompilation.

package.json

  • engines.node >= 14: increased the minimum node version to 14, which AFAICT allows increasing the tsconfig.json "target" to "ES2020".
  • Deleted build:types script: types are now generated by build:module.
  • Added build:rebuild script: composite tsc configuration introduces incremental compilation and *.tsbuildinfo artifacts.
    • These artifacts caused issues as I was testing, so we might want to consider including a cleanup step in build:clean, but that defeats the purpose and benefit of incremental builds. I figure it'll be less of a problem in actual usage.
  • Replaced rm -rf ; with rimraf &&: based on Actually fix windows build #190, I believe this is the last outstanding change needed.

Consolidated the new tsconfig.dev.json into the existing, default
tsconfig.json. Deleted the "build:types" script since it's been absorbed
into "build:module", which now uses the tsconfig.json.
I like to test with npm pack, so this is just a QOL thing for me :)
I figure we don't care too much about node v10 anymore, so I updated the
engines field to use node >=14.0.0—allowing us to update the tsconfig
target to ES2020.
I think, with the current build process, the best way to simplify the
tsc config(s) is actually to keep things separate. Part of the
complication is that we build dist-node out of dist-module (which I
  still don't quite understand why)
I believe, with the way we use tsc with multiple input and output
directories, this is the cleanest way to setup the configuration. Now:

- tsconfig.json: shared base tsc settings
- tsconfig.module.json: src -> dist-module compilation
- tsconfig.node.json: dist-module -> dist-node recompilation

As far as I can tell, this pretty much preserves the existing build
process, just simplifies the settings (and should work better with
  tooling).

The recompilation of dist-module to create dist-node is still
undesirable, but I also still don't quite understand the whole reasoning
there, so I don't want to touch it.
@TheMrCam TheMrCam added the build Related to building and packaging label Jan 21, 2026
Didn't realize my changes to package-lock.json were in error, but CI
seems to think so. Regenerated with `npm install`.
Regenerated package-lock.json to resolve merge conflicts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Related to building and packaging

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consolidate typescript config into a single tsconfig.json

2 participants