Skip to content

TS6 & TSDown#48

Merged
Pearce-Ropion merged 4 commits intomainfrom
pearce/ts-build-system
May 8, 2026
Merged

TS6 & TSDown#48
Pearce-Ropion merged 4 commits intomainfrom
pearce/ts-build-system

Conversation

@Pearce-Ropion
Copy link
Copy Markdown
Collaborator

@Pearce-Ropion Pearce-Ropion commented May 8, 2026

Various changes and fixes to the build system

  • Update to TS6
  • Change build system to tsdown
    • Expose both cjs and esm builds
    • Added publint unused and attw plugins to ensure published package is correct
      • Removed react-dom since it was unused
  • Add yarn types because the build system no longer runs type check
  • Add separate typecheck job to CI
  • Fix jest version mismatches
  • Add __VERSION__ injection instead of importing package.json in runtime

This was referenced May 8, 2026
@Pearce-Ropion Pearce-Ropion requested a review from ryan-sigma May 8, 2026 05:56
Comment thread tsdown.config.ts Outdated
},
},
outExtensions: ({ format }) => {
if (format === 'es') return { js: '.js', dts: '.d.ts' };
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this to avoid us having .mjs as an extension for some reason?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might not be necessary. I was having trouble getting attw to pass. I'll give it another go

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude said this...

outExtensions is necessary because of "type": "module" in [package.json:7](vscode-webview://0mk05v0rhfbp3n674ov47ss8o9rrtckoum75g9addagbqjl3f4o9/package.json#L7).

With that field set, Node treats every .js file as ESM. So the CJS build can't use .js — it has to be .cjs, otherwise Node would try to load it as ESM at runtime and crash on require/module.exports.

The matching .d.cts for the CJS types is required for TypeScript's node16/nodenext module resolution. When a consumer does require('@sigmacomputing/plugin'), TS only picks up the CJS declaration if its extension lines up with the JS file (.cjs → .d.cts). The exports map in [package.json:11-22](vscode-webview://0mk05v0rhfbp3n674ov47ss8o9rrtckoum75g9addagbqjl3f4o9/package.json#L11-L22) is wired up the same way:

import → dist/esm/index.js + dist/esm/index.d.ts
require → dist/cjs/index.cjs + dist/cjs/index.d.cts
Without the override, tsdown would emit .js/.d.ts for both formats and the CJS half of the dual package would be broken — attw and publint (both enabled at [tsdown.config.ts:36-37](vscode-webview://0mk05v0rhfbp3n674ov47ss8o9rrtckoum75g9addagbqjl3f4o9/tsdown.config.ts#L36-L37)) would also fail.

But I tried removing it and it had no effect... so removing

ryan-sigma
ryan-sigma previously approved these changes May 8, 2026
@Pearce-Ropion Pearce-Ropion merged commit 76f2acf into main May 8, 2026
6 checks passed
@Pearce-Ropion Pearce-Ropion deleted the pearce/ts-build-system branch May 8, 2026 21:09
@Pearce-Ropion Pearce-Ropion restored the pearce/ts-build-system branch May 8, 2026 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants