gentleeduck/duck-ui / .claude/skills/tsdown
tsdown
VerifiedBundle TypeScript and JavaScript libraries with blazing-fast speed powered by Rolldown. Use when building libraries, generating type declarations, bundling for multiple formats, or migrating from tsup.
references/recipe-svelte.md
View on GitHub# Svelte Support
Build Svelte component libraries with `tsdown` using `rollup-plugin-svelte`.
## Quick Start
```bash
npx create-tsdown@latest -t svelte
```
## Configuration
```ts
import svelte from 'rollup-plugin-svelte'
import { sveltePreprocess } from 'svelte-preprocess'
import { defineConfig } from 'tsdown'
export default defineConfig({
entry: ['./src/index.ts'],
platform: 'neutral',
plugins: [svelte({ preprocess: sveltePreprocess() })],
})
```
## Dependencies
```bash
npm install -D rollup-plugin-svelte svelte svelte-preprocess
```
## Distribution Strategy
**Recommended: Ship `.svelte` source files** instead of precompiled JS. Let consumers' tooling (Vite + `@sveltejs/vite-plugin-svelte`) compile in their apps.
Reasons:
- Avoids version compatibility issues with `svelte/internal`
- Better SSR/hydration consistency
- Consumers get better HMR, diagnostics, and tree-shaking
- Fewer republish cycles on Svelte upgrades
**Exceptions** where shipping JS makes sense:
- Web Components via `customElement` mode
- CDN direct-load without a build step
## Key Points
- Mark `svelte`/`svelte/*` as external; declare `svelte` in `peerDependencies`
- Use `svelte2tsx` to emit `.d.ts` for Svelte components
- Keep `.svelte` in source form for distribution
## Related
- [Plugins](advanced-plugins.md) - Plugin configuration
- [Dependencies](option-dependencies.md) - External dependencies
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementation | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirements | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallback | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |