Comments (5)
Hum, it's not what à i posted few days ago. I'll remake it
Edit: Stackblitz fixed! Tell me if it's not good yet.
from storybook.
Inspecting this issue, I firstly suspected @storybookjs/addon-svelte-csf
(because __docgen
sounded familiar to me) code transformation - commenting out the export default
or export { meta }
. It wasn't the root cause for this issue, I've verified it quickly by changing the plugin to remove instead of commenting out. No luck.
Below is my observations notes, perhaps could help other maintainers debug quicker to figure out why it doesn't work.
In this reproduction case, I noticed the Calendar
is using "compound component", quite common pattern in React AFAIK.
<!-- calendar-svelte -->
<script lang="ts">
import { Calendar as CalendarPrimitive } from "bits-ui";
import * as Calendar from "./index.js"; // This breaks the Storybook
import { cn } from "$lib/utils.js";
// ...
</script>
The imported file content is:
// calendar/index.js
import Root from "./calendar.svelte";
import Cell from "./calendar-cell.svelte";
import Day from "./calendar-day.svelte";
import Grid from "./calendar-grid.svelte";
import Header from "./calendar-header.svelte";
import Months from "./calendar-months.svelte";
import GridRow from "./calendar-grid-row.svelte";
import Heading from "./calendar-heading.svelte";
import GridBody from "./calendar-grid-body.svelte";
import GridHead from "./calendar-grid-head.svelte";
import HeadCell from "./calendar-head-cell.svelte";
import NextButton from "./calendar-next-button.svelte";
import PrevButton from "./calendar-prev-button.svelte";
export {
Day,
Cell,
Grid,
Header,
Months,
GridRow,
Heading,
GridBody,
GridHead,
HeadCell,
NextButton,
PrevButton,
//
Root as Calendar,
};
For some reason which I haven't found yet, this breaks only in Storybook. It works with normal Vite build.
Current workaround
This is not what you want for sure, it will decrease code readability. But it will work, at least for the time being until the issue is resolved - if that's acceptable for you.
<script lang="ts">
import { Calendar as CalendarPrimitive } from "bits-ui";
- import * as Calendar from "./index.js"; // This breaks the Storybook
+ import { Day, Cell, Grid, Header, Months, GridRow, Heading, GridBody, GridHead, HeadCell, NextButton, PrevButton, Calendar } from "./index.js";
import { cn } from "$lib/utils.js";
// ...
</script>
from storybook.
i'm having the same issue - also with shadcn-svelte in storybook
from storybook.
The reproduction link doesn't show the setup you described, nor show the issue you have.
from storybook.
I tried, and it works. It's not optimal, but at least it works and it's simple to fix. Thanks a lot !
from storybook.
Related Issues (20)
- [Bug]: TypeScript 5.5 breaks components using generic forwardRef HOT 2
- [Bug]: Invariant failed: Expected package.json#version to be defined in the "undefined" package} HOT 6
- [Tracking] Coverage prototype HOT 2
- [Tracking]: Replace Lodash Usage with Native Functionality or Alternatives HOT 8
- CLI: Add SvelteKit to storybook@latest init in empty directory HOT 1
- [Bug]: @storybook/core is (wrongly) specifying @storybook/global as a devDependency HOT 5
- [Bug]: Storybook doesn't work with `Yarn 4 (nodeLinker: pnpm)`, `Vue 3`, `Vite 5`, `Storybook 8`
- [Bug]: Onboarding fails when PascalCase story is created HOT 1
- Vitest: Create "Component Coverage" per story file HOT 1
- Vitest|Storybook: Create communication channel to gather coverage information HOT 1
- File Selection: Show coverage for all relevant files HOT 1
- Storybook Coverage Viewer Addon - Create UI for Displaying Coverage Data HOT 1
- [Bug]: Boolean controls break when attributes names use hyphens(-) in Lit HOT 1
- [Bug]: error when starting `storybook` using `postcss-url` plugin to inline assets HOT 1
- [Bug]: Cannot access Next router in custom container when using NextJS preset with Docs add-on
- [Bug]: Docs broken with high CPU usage HOT 3
- [Bug]: Docs page menu item cannot be clicked; the page does not respond. HOT 4
- [Bug]: Docs page renders the Toast multiple times
- [Bug]: Addon build fails due to missing `@storybook/manager/globals` on 8.2.x
- [Bug]: links on docs page for config point to 404 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from storybook.