Skip to content

Commit b43e39f

Browse files
dancormierclaude
andcommitted
fix(docs-next): resolve @stackoverflow/stacks via ESM entry for Rollup
Rollup (used by Vite for production builds) cannot statically extract named exports from webpack's UMD bundle format, causing "hidePopover is not exported" when stacks-editor's ESM source imports from @stackoverflow/stacks. - Add lib/esm-no-css.ts: an ESM entry that mirrors lib/index.ts but omits the CSS side-effect (the docs site imports the CSS directly via app.css) - Alias @stackoverflow/stacks to this entry in vite.config.ts (exact match via regex; subpath imports like /dist/css/stacks.css are unaffected) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 6526821 commit b43e39f

2 files changed

Lines changed: 39 additions & 0 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// ESM entry for bundlers that need named exports (e.g. Vite/Rollup).
2+
// Mirrors lib/index.ts but omits the CSS side-effect import;
3+
// consumers should import the stylesheet separately.
4+
import {
5+
BannerController,
6+
ModalController,
7+
PopoverController,
8+
TableController,
9+
TabListController,
10+
ToastController,
11+
TooltipController,
12+
} from "./controllers";
13+
import { application, StacksApplication } from "./stacks";
14+
15+
application.register("s-banner", BannerController);
16+
application.register("s-modal", ModalController);
17+
application.register("s-toast", ToastController);
18+
application.register("s-navigation-tablist", TabListController);
19+
application.register("s-popover", PopoverController);
20+
application.register("s-table", TableController);
21+
application.register("s-tooltip", TooltipController);
22+
23+
StacksApplication.finalize();
24+
25+
export * from "./controllers";
26+
export * from "./stacks";

packages/stacks-docs-next/vite.config.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
import fs from "fs";
2+
import { fileURLToPath } from "url";
3+
import { dirname, resolve } from "path";
24
import { sveltekit } from "@sveltejs/kit/vite";
35
import { defineConfig } from "vite";
46

57
import pkgMain from "../stacks-classic/package.json";
68
import pkgSvelte from "../stacks-svelte/package.json";
79

10+
const __dirname = dirname(fileURLToPath(import.meta.url));
11+
812
export default defineConfig({
913
plugins: [
1014
sveltekit(),
@@ -18,6 +22,15 @@ export default defineConfig({
1822
},
1923
},
2024
],
25+
resolve: {
26+
alias: [
27+
{
28+
// Exact match only — subpath imports like /dist/css/stacks.css are unaffected
29+
find: /^@stackoverflow\/stacks$/,
30+
replacement: resolve(__dirname, "../stacks-classic/lib/esm-no-css.ts"),
31+
},
32+
],
33+
},
2134
define: {
2235
__APP_VERSION__: JSON.stringify(pkgMain.version),
2336
__SVELTE_VERSION__: JSON.stringify(pkgSvelte.version),

0 commit comments

Comments
 (0)