Skip to content

Switch to moduleResolution: bundler#305

Merged
brianmhunt merged 7 commits into
mainfrom
modern-tooling/phase-2-tsgo
Apr 14, 2026
Merged

Switch to moduleResolution: bundler#305
brianmhunt merged 7 commits into
mainfrom
modern-tooling/phase-2-tsgo

Conversation

@brianmhunt
Copy link
Copy Markdown
Member

@brianmhunt brianmhunt commented Apr 14, 2026

Summary

Add TypeScript 7's Go-native compiler (tsgo) alongside tsc. Switch to moduleResolution: "bundler" which is required by tsgo and stricter about package resolution.

Speed

Checker Time
tsc (TypeScript 6) 1.0s
tsgo (TypeScript 7) 0.17s

6x faster. Both produce 0 errors.

What changed (6 files, +28/-9)

  • package.json — add @typescript/native-preview
  • tsconfig.jsonmoduleResolution: "bundler", add @tko/* paths for source resolution, remove deprecated ignoreDeprecations
  • packages/observable/src/index.ts — export Subscription type (was only available via deep import)
  • packages/bind/src/bindingEvent.ts — import Subscription from package root instead of deep path
  • packages/binding.core/src/index.ts — add type annotation to bindings const (bundler resolution inference issue)

Why these source changes?

moduleResolution: "bundler" strictly follows package.json exports fields. TKO's @tko/* workspace packages have exports pointing to ./dist/index.js, which has no type information. The @tko/* paths mapping in tsconfig tells TypeScript to resolve to source (index.ts) during development.

Test plan

  • bunx tsgo — 0 errors
  • bunx tsc — 0 errors
  • make — 27 packages build
  • bunx vitest run — 143 files, 2679 passed

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores

    • Added TypeScript native preview as a development dependency.
    • Updated TypeScript compiler configuration with improved module resolution strategy and new import path mappings.
  • Refactor

    • Consolidated type imports and improved type annotations throughout the codebase.

tsgo requires moduleResolution: "bundler" which strictly follows
package.json exports fields. Fix @tko/* resolution by adding
explicit paths mapping to source files in tsconfig.

Changes:
- Add @typescript/native-preview (tsgo) as devDependency
- moduleResolution: node10 → bundler
- Add @tko/* paths for source resolution during development
- Export Subscription type from @tko/observable
- Fix deep import in bindingEvent.ts to use package root
- Add type annotation to binding.core bindings const

Both tsc and tsgo pass with 0 errors.
Speed: tsc 1.0s → tsgo 0.17s (6x faster).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 14, 2026 15:51
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 14, 2026

📝 Walkthrough

Walkthrough

This PR updates TypeScript configuration with new module resolution settings and import path aliases, consolidates type imports across packages, adds explicit type annotations to exported bindings, exports the Subscription type publicly, and introduces a new TypeScript dev dependency.

Changes

Cohort / File(s) Summary
Type System & Exports
packages/bind/src/bindingEvent.ts, packages/binding.core/src/index.ts, packages/observable/src/index.ts
Consolidates type imports from separate sources into a single @tko/observable import, adds explicit Record<string, unknown> type annotation to exported bindings constant, and exports Subscription type from the observable package's public API.
Build Configuration
tsconfig.json
Changes moduleResolution from node10 to bundler, adds @tko/* path alias mapping to resolve to ./packages/*/index.ts and ./builds/*/index.ts, and removes ignoreDeprecations.
Dependencies
package.json
Adds @typescript/native-preview (version ^7.0.0-dev.20260414.1) as a new devDependency.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Possibly related PRs

  • Code-Coverage #231: Both PRs modify type imports in packages/bind/src/bindingEvent.ts, specifically handling Subscription and Subscribable type consolidation.

Poem

🐰 Types now neat, imports aligned,
Path aliases configured and designed,
Subscription exposed to the light,
TypeScript bundler set just right!
Configuration hops ahead with cheer!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title 'Switch to moduleResolution: bundler' directly describes a key change in the PR but omits the broader modernization initiative (TypeScript 7 tooling and 6x speedup) that motivated this change.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch modern-tooling/phase-2-tsgo

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces the TypeScript 7 Go-native typechecker (tsgo) alongside existing tsc usage, and updates TypeScript module resolution to "bundler" (required by tsgo) with accompanying source-resolution fixes across @tko/* workspace packages.

Changes:

  • Add @typescript/native-preview (tsgo) to devDependencies and lockfile.
  • Switch tsconfig.json to moduleResolution: "bundler" and add @tko/* path mappings to resolve to workspace source entrypoints.
  • Remove a deep import by exporting Subscription from @tko/observable and updating consumers; add a workaround type annotation for bindings in @tko/binding.core.

Reviewed changes

Copilot reviewed 4 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tsconfig.json Switches to bundler resolution and adds @tko/* path mappings for workspace source resolution.
package.json Adds the @typescript/native-preview dependency needed to run tsgo.
bun.lock Locks @typescript/native-preview and its platform-specific optional dependencies.
packages/observable/src/index.ts Exposes Subscription type at the package root to avoid deep imports.
packages/bind/src/bindingEvent.ts Updates Subscription import to use the package root export under bundler resolution.
packages/binding.core/src/index.ts Adds an explicit type to bindings to avoid resolution/inference issues under bundler mode.

Comment thread package.json Outdated
"@eslint/js": "^10.0.1",
"@types/jquery": "^4.0.0",
"@types/mocha": "^10.0.10",
"@typescript/native-preview": "^7.0.0-dev.20260414.1",
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

@typescript/native-preview is referenced with a caret range (^7.0.0-dev.20260414.1). Because this is a dev snapshot, allowing semver-compatible upgrades can unexpectedly pull in a different preview build (or eventually stable 7.0.0) and change typechecking behavior across environments. Consider pinning to an exact version (no ^) or otherwise constraining updates so CI/local installs remain reproducible.

Suggested change
"@typescript/native-preview": "^7.0.0-dev.20260414.1",
"@typescript/native-preview": "7.0.0-dev.20260414.1",

Copilot uses AI. Check for mistakes.
import { using } from './using'

export const bindings = {
export const bindings: Record<string, unknown> = {
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

Typing bindings as Record<string, unknown> forces all handler values to unknown, which discards useful type information for downstream consumers (e.g., no IntelliSense/compile-time checking when accessing specific bindings). If the goal is only to ensure the object conforms to a shape for module-resolution/inference reasons, consider using a satisfies Record<string, unknown> constraint (or a more specific binding-handler type) so the object keeps its inferred property types while still meeting the required contract.

Copilot uses AI. Check for mistakes.
@phillipc
Copy link
Copy Markdown
Member

phillipc commented Apr 14, 2026

Tsgo is still in preview. Don't merge it.

Brian M Hunt and others added 5 commits April 14, 2026 12:03
The "*" wildcard paths were a pre-bundler workaround. Now that
"@tko/*" has its own explicit mapping, the wildcard is unused
and adds unnecessary resolution complexity.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Target/Module: ES2022 (was ES6/ES2015)
- moduleResolution: bundler
- Add bunx tsgo to build commands
- Update path alias description

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
README.md:
- npm→bun, electron→Vitest/Playwright throughout
- Remove stale test-coverage target, SauceLabs, standard references
- Simplify WSL setup to just playwright install

AGENTS.md:
- Fix package count (25→26)
- npx changeset→bunx changeset

plans/modern-tooling.md:
- Phase 1 merged, Phase 2 PR open

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Pin @typescript/native-preview to exact version (no ^)
- Add bunfig.toml with minimumReleaseAge = 172800 (48h)
- Keep Record<string, unknown> annotation on bindings (tsgo needs it)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@brianmhunt
Copy link
Copy Markdown
Member Author

Tsgo is still in preview. Don't merge it.

@phillipc could you please elaborate? That's a strong opinion, is there a specific risk you're concerned about?

@brianmhunt
Copy link
Copy Markdown
Member Author

@phillipc — if you have concerns about this PR, happy to discuss. Here's a summary of the risk assessment:

What this PR actually changes:

  • moduleResolution: "bundler" in tsconfig (supported since TS 5.0, 2023)
  • @tko/* paths mapping for source resolution (auto-resolves new packages via glob)
  • 3 minor source fixes (type export, deep import, type annotation)
  • Adds tsgo as an optional dev tool (not in CI, not replacing tsc)
  • Adds bunfig.toml with 48h minimumReleaseAge for supply-chain protection

What it doesn't change:

  • CI still runs tsc (TypeScript 6) as the gate — tsgo is not in any workflow
  • No runtime changes — @typescript/native-preview is a devDependency only
  • Both tsc and tsgo produce identical results (0 errors each)

Size: 10 files, +62/-59 lines. Mostly config and docs.

The moduleResolution: "bundler" change is the substantive part. It's stricter than node10 about following package.json exports fields, which is why we needed the @tko/* paths mapping. This is the direction TypeScript is going — tsgo removed node10 entirely.

@phillipc
Copy link
Copy Markdown
Member

@brianmhunt:

a) moduleResolution: "bundler" - It's fine, and I even tried it myself. This has nothing to do with tsgo alone.

b) Using unfinished tools creates technical debt and makes long-term stability harder to manage. Breaking-changes, Bugs and co. are daily business..

c) You said it yourself, we're not really using the new dependency, too.

Per phillipc's feedback: tsgo is a preview tool not used in CI.
Keep moduleResolution: bundler (which he confirmed is fine) but
remove the tsgo devDependency. Developers can install it locally
if they want faster typechecking.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@brianmhunt brianmhunt changed the title Add tsgo (TypeScript 7) — 6x faster typechecking Switch to moduleResolution: bundler Apr 14, 2026
@brianmhunt
Copy link
Copy Markdown
Member Author

@phillipc Good points — removed @typescript/native-preview from the dependencies. Developers who want tsgo can install it locally.

The PR now just does the moduleResolution: "bundler" switch (which you confirmed is fine) plus the 3 minor source fixes it requires. No preview tooling in the repo.

@brianmhunt brianmhunt merged commit c98d87e into main Apr 14, 2026
5 checks passed
@brianmhunt brianmhunt deleted the modern-tooling/phase-2-tsgo branch April 14, 2026 17:48
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.

3 participants