Skip to content

fix(tsdown-plugin): install typescript so the lib preset's declarations build - #283

Merged
rqbazan merged 1 commit into
mainfrom
fix/tsdown-plugin-typescript
Oct 18, 2026
Merged

rqbazan merged 1 commit into
mainfrom
fix/tsdown-plugin-typescript

Conversation

@rqbazan

@rqbazan rqbazan commented Oct 18, 2026

Copy link
Copy Markdown
Member

Summary

@rrlab/tsdown-config's default lib preset sets dts: true. tsdown takes typescript only as an optional peer, and rr plugins add tsdown didn't install it, so rr pack failed in any project without the ts or astro plugin.

 install(ctx)  // @rrlab/tsdown-plugin
   devDependencies
     tsdown ^0.22.0
+    typescript ^6.0.0   // unless dependencies/devDependencies already have it
     @rrlab/tsdown-config
 uninstall(ctx)
   remove tsdown, @rrlab/tsdown-config   // typescript stays: the host or ts/astro may use it
  • ^6.0.0 is the same pin as the ts and astro plugins, so the order of rr plugins add ts and rr plugins add tsdown doesn't matter.
  • A host that already installs typescript keeps its range: pnpm add would otherwise rewrite it. A peer-only declaration doesn't count, because it isn't installed.
  • New optional peer typescript >=5.0.0: the bin preset builds without it.

Evidence

Non-TTY e2e in a temp project, with the worktree's packed @rrlab/cli and @rrlab/tsdown-plugin (via pnpm.overrides) and rr plugins add oxc, so the ts plugin isn't installed:

  • Before (npm 1.2.1): rr plugins add tsdown </dev/null adds no typescript. rr pack exits 1 with Error: TypeScript is not installed. You should install typescript package.
    After: typescript ^6.0.3 is added. rr pack exits 0 and writes dist/index.d.mts, and rr check passes.
  • Host on typescript ~5.9: left as ~5.9.3. Host with typescript only as a peer: installed. ts then tsdown, and tsdown then ts, both end with one typescript and green rr pack/rr tsc. rr plugins remove tsdown --yes leaves typescript.
  • install.test.ts: with the index.ts fix reverted, 5 tests fail, covering the create, skip, decline, user-skip and peer-only paths. With the fix, 25/25 pass.

Merge Danger

Door: two-way

Blast Radius: small

Only rr plugins add tsdown changes: it adds one dev dependency when it's missing. Existing projects aren't touched until they re-run the add.

🤖 Generated with Claude Code

https://claude.ai/code/session_01EZVC7xzzsEmByszmfff4u2

The lib preset's `dts: true` needs `typescript` installed, and tsdown
only takes it as an optional peer, so `rr pack` failed with "TypeScript
is not installed" in a project without the ts plugin. install() now adds
`typescript` (^6.0.0, the ts and astro plugins' pin) on every path,
unless the package already has it in dependencies or devDependencies.
uninstall() keeps it, since the project or another plugin may use it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EZVC7xzzsEmByszmfff4u2
@changeset-bot

changeset-bot Bot commented Oct 18, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8ae3af4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@rrlab/tsdown-plugin Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vland-bot

vland-bot Bot commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

Preview release

Latest commit: 8ae3af4

Some packages have been released:

Package Version Install
@rrlab/tsdown-plugin 1.2.2-git-8ae3af4.0 @rrlab/tsdown-plugin@1.2.2-git-8ae3af4.0

Note

Use the PR number as tag to install any package. For instance:

pnpm add @rrlab/tsdown-plugin@pr-283

@rqbazan
rqbazan merged commit ed0fbae into main Oct 18, 2026
10 checks passed
@rqbazan
rqbazan deleted the fix/tsdown-plugin-typescript branch October 18, 2026 18:00
@vland-bot vland-bot Bot mentioned this pull request Oct 18, 2026
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