Skip to content

Fix Bun .d.ts bundle broken by TypeScript 7 resolution - #159

Merged
jerome-benoit merged 6 commits into
masterfrom
fix/bun-plugin-dts-bundle
Jul 25, 2026
Merged

Fix Bun .d.ts bundle broken by TypeScript 7 resolution#159
jerome-benoit merged 6 commits into
masterfrom
fix/bun-plugin-dts-bundle

Conversation

@jerome-benoit

Copy link
Copy Markdown
Contributor

Problem

deno task bundle fails on master (independent of any dependency PR):

TypeError: undefined is not an object (evaluating 'ts.sys.getCurrentDirectory')
  at dts-bundle-generator@9.5.1/dist/helpers/check-diagnostics-errors.js:8
Bun build failed → bundle.ts

Root cause

build/bun-build.ts loads bun-plugin-dts@0.4.0dts-bundle-generator@9.5.1, which reads ts.sys at module-evaluation time. dts-bundle-generator declares typescript: ">=5.0.2", and since the repo has no root package.json/lockfile, Bun resolves that range to TypeScript 7 (the native tsgo rewrite), which does not expose the legacy JS compiler API — so ts.sys is undefined.

Verified: without a local package.json, require('typescript').version === '7.0.2' and ts.sys === undefined; pinned to ^5, ts.version === '5.9.3' and ts.sys.getCurrentDirectory is a function.

Fix

Add a build-only build/package.json (private: true) pinning typescript: ^5.9.3, and run bun install --cwd ./build in bundle.ts before the Bun build. No source code touched; the Deno-first publish flow is unchanged (deno.json publish.include does not include package.json).

Verification

Command Result
deno task bundle (cold + warm) exit 0, dist/esm/mod.d.ts (2288 lines) regenerated
resolved TypeScript 5.9.3
deno fmt --check / deno lint exit 0

dts-bundle-generator@9.5.1 reads ts.sys at module load. With no local
package.json, Bun resolves its 'typescript: >=5.0.2' range to TypeScript 7
(native rewrite, no legacy JS API), so ts.sys is undefined and the bundle
crashes. Add a build-only package.json pinning typescript ^5.9.3 and run
bun install --cwd ./build before bundling.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 72af49d188

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread bundle.ts Outdated
// plugin, in particular ts.sys), breaking the .d.ts bundle step.
console.time('Bun install time')
const bunInstall = new Deno.Command('bun', {
args: ['install', '--cwd', './build', '--silent'],

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve diagnostics from failed Bun installs

When the registry is unavailable or a package fails verification, --silent suppresses the diagnostic output that this error path attempts to decode. bun install --help defines this flag as “Don't log anything”; with Bun 1.2.14, a failed silent install exits nonzero with zero-byte stderr, so CI reports only Bun install failed: and hides the package or network error. Use narrower output controls such as --no-progress/--no-summary, or otherwise preserve failure diagnostics.

Useful? React with 👍 / 👎.

@jerome-benoit jerome-benoit Jul 25, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in b16aabe: --silent--no-progress --no-summary (preserves install error diagnostics).

Replace --silent (suppresses all output) with --no-progress --no-summary
so a failed build-dependency install still surfaces the registry/network
error the catch block decodes, instead of an empty 'Bun install failed:'.
@sonarqubecloud

Copy link
Copy Markdown

@jerome-benoit
jerome-benoit merged commit a9fcfdf into master Jul 25, 2026
16 checks passed
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.

1 participant