[7.0] Incompatible with sveltekit
See original GitHub issueDescribe the bug A standard bootstrap of a sveltekit + storybook project fails to start.
To Reproduce
yarn create svelte
- follow the prompts, choose
skeleton
for the template andno
for everything else yarn
npx sb@future init
yarn storybook
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in /Users/ianvs/code/experiments/sveltekit-generator/node_modules/@sveltejs/adapter-auto/package.json
It seems like this happens because of a require
call here: https://github.com/storybookjs/storybook/blob/b42f0edea70f4f97d1d64aa86945f3beeff2a7b7/code/lib/core-common/src/utils/interpret-require.ts#L24
But sveltekit is ESM-only. I tried changing the generated .storybook/main.cjs
file into esm, but that still didn’t help.
System N/A
Additional context I’ve requested a way to specify all sveltekit options via command line flags, so that we can create a repro template for sveltekit and add it to our test suite: https://github.com/sveltejs/kit/issues/7064
Issue Analytics
- State:
- Created a year ago
- Comments:40 (34 by maintainers)
Top Results From Across the Web
[7.0] Incompatible with sveltekit #19280 - Issuehunt
Describe the bug A standard bootstrap of a sveltekit + storybook project fails to start. To Reproduce. yarn create svelte; follow the prompts, ......
Read more >run command failing on newest version of sveltekit : r/sveltejs
Hi guys I have a digital ocean node setup with sveltekit, until now I ran the app like this node build/index.js but now...
Read more >Error installing sveltekit app after upgrading Node to latest ...
The version you've got cached locally could be incompatible with the current version of SvelteKit. Alternative things to try:.
Read more >Major Svelte Kit API Change - Fixing `load`, and tightening up ...
https://github.com/sveltejs/kit/discussions/5748Simple Made Easy: https://www.youtube.com/watch?v=SxdOUGdseq4Become a Level Up Pro and take ...
Read more >SvelteKit Crash Course Tutorial #7 - Reset Layouts - YouTube
Get access to this course on Net Ninja Pro:https://netninja.dev/p/ sveltekit -tutorial Get access to more premium courses on Net Ninja ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’ll do a follow up PR that removes the SvelteKit Vite plugin.
I think it’s mainly importing the SvelteKit specific modules. I agree most of them don’t make sense in a deep component that you’d have in a Storybook story, eg.
@sveltejs/kit/hooks
doesn’t make sense in a Storybook context. But I can see some of them make sense, eg.:$app/environment
- As @Amerlander mentions should probably always bebrowser
in SB$lib/
imports - I’d guess is just a simple Vite alias.$app/paths
- components showing the current URL or a path to an asset or whatever$app/stores
- thepage
and the navigation stores could be useful for components that navigates.But I think all of these should ideally be treated similar to props (or “args”), so users could “mock” them or define them as needed per story. Setting the current
page
for a given story, or making$app/navigation/goto
call a Storybook action when called. I think all of this is out of scope for our SvelteKit support for now, but I think it would be the ideal DX for anyone or the community to build.My hunch is that the biggest annoyance would be that we don’t support
$lib/
imports, I can see that being used quite often in any component.I agree with benmccann. But I can give some examples for SvelteKit-specific code I used in my components and had to change to use with Storybook. It were only about the SvelteKit specific
$app/environment
browser
variable and$app/stores
page
store:I have a menu component which uses the
page
store:I haven’t thought about a workaround yet, I just decided to not add this component to storybook for now.
And I had components which used the
browser
variable to prevent code from being ssr. Those components are already changed to not usebrowser
anymore and I think that also improved the components. Also, I think thebrowser
variable for example could be hard coded to be alwaystrue
in storybook and then easily be used.I would rather prefer to be able to build storybook than to have these sveltekit specific things available.