I recently updated to Storybook 9 and in parallel started using rolldown-vite. I found that storybook 9 worked fine before updating to rolldown-vite, and storybook 8 works fine with rolldown-vite, but the combination caused problems.
I've narrowed at least one of the issues down to using a render
function that renders a component that imports from import '@storybook/react-vite'
.
To reproduce:
pnpm build-storybook
pnpm dlx http-server storybook-static --port 6006 --silent
- Navigate to http://localhost:6006/?path=/story/repro--default
- Open the console, see the error:
chunk-N3U7HZRZ-DqlWfFHk.js:2 Uncaught ReferenceError: __STORYBOOK_MODULE_PREVIEW_API__ is not defined
- Open
helper.tsx
, comment out import. - Rebuild storybook
- Refresh the storybook browser tab (make sure to clear cache)
- It should now load fine