Skip to content

Commit df0a03e

Browse files
Paul Mulliganclaude
andcommitted
fix(widget): skip declaration bundling under Storybook build
Storybook's Vite builder loads vite.config.ts, so vite-plugin-dts ran during 'storybook build' and failed: api-extractor looked for dist/index.d.ts, which only the library build produces. Guard the dts plugin behind process.env.STORYBOOK so it runs only for the library build. Verified locally: 'pnpm build' still emits dist/index.d.ts (+ .d.cts) and 'pnpm build-storybook' now succeeds. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 73bae66 commit df0a03e

1 file changed

Lines changed: 25 additions & 17 deletions

File tree

widget/vite.config.ts

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,31 @@ import { resolve } from "path";
66
export default defineConfig({
77
plugins: [
88
react(),
9-
dts({
10-
// unplugin-dts (vite-plugin-dts v5) calls declaration bundling
11-
// `bundleTypes` (the old `rollupTypes` name is ignored). This rolls the
12-
// whole public surface into a single dist/index.d.ts via api-extractor.
13-
bundleTypes: true,
14-
tsconfigPath: "./tsconfig.json",
15-
include: ["src"],
16-
exclude: [
17-
"src/**/*.test.ts",
18-
"src/**/*.test.tsx",
19-
"src/**/*.stories.tsx",
20-
"src/test-setup.ts",
21-
"src/test-utils/**",
22-
"src/main.tsx",
23-
"src/embed.tsx",
24-
],
25-
}),
9+
// Storybook's Vite builder also loads this config, but it builds to its own
10+
// output (not dist/), so the declaration bundler would fail looking for
11+
// dist/index.d.ts. Emit declarations only for the library build.
12+
...(process.env.STORYBOOK
13+
? []
14+
: [
15+
dts({
16+
// unplugin-dts (vite-plugin-dts v5) calls declaration bundling
17+
// `bundleTypes` (the old `rollupTypes` name is ignored). This rolls
18+
// the whole public surface into a single dist/index.d.ts via
19+
// api-extractor.
20+
bundleTypes: true,
21+
tsconfigPath: "./tsconfig.json",
22+
include: ["src"],
23+
exclude: [
24+
"src/**/*.test.ts",
25+
"src/**/*.test.tsx",
26+
"src/**/*.stories.tsx",
27+
"src/test-setup.ts",
28+
"src/test-utils/**",
29+
"src/main.tsx",
30+
"src/embed.tsx",
31+
],
32+
}),
33+
]),
2634
],
2735
server: {
2836
port: 5173,

0 commit comments

Comments
 (0)