Skip to content

Commit 2f3996d

Browse files
committed
fix: storybook-vue/nuxt compat
1 parent 3d2877c commit 2f3996d

File tree

3 files changed

+96
-69
lines changed

3 files changed

+96
-69
lines changed

.storybook/main.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,33 @@ const config = {
1111
async viteFinal(newConfig) {
1212
newConfig.plugins ??= []
1313

14+
// Bridge compatibility between Storybook v10 core and v9 @storybook-vue/nuxt
15+
// v10 expects module federation globals that v9 doesn't provide
16+
newConfig.plugins.push({
17+
name: 'storybook-v10-compat',
18+
transformIndexHtml: {
19+
order: 'pre',
20+
handler(html) {
21+
const script = `
22+
<script>
23+
// Minimal shims for Storybook v10 module federation system
24+
// These will be replaced when Storybook runtime loads
25+
window.__STORYBOOK_MODULE_GLOBAL__ = { global: window };
26+
window.__STORYBOOK_MODULE_CLIENT_LOGGER__ = {
27+
deprecate: console.warn.bind(console, '[deprecated]'),
28+
once: console.log.bind(console),
29+
logger: console
30+
};
31+
window.__STORYBOOK_MODULE_CHANNELS__ = {
32+
Channel: class { on() {} off() {} emit() {} once() {} },
33+
createBrowserChannel: () => new window.__STORYBOOK_MODULE_CHANNELS__.Channel()
34+
};
35+
</script>`
36+
return html.replace(/<script>/, script + '<script>')
37+
},
38+
},
39+
})
40+
1441
newConfig.plugins.push({
1542
name: 'ignore-internals',
1643
transform(_, id) {

0 commit comments

Comments
 (0)