Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: svelte #240

Merged
merged 3 commits into from
Feb 17, 2022
Merged

Fix: svelte #240

merged 3 commits into from
Feb 17, 2022

Conversation

bfanger
Copy link
Contributor

@bfanger bfanger commented Feb 12, 2022

  1. Re-enabled the csfPlugin for svelte
  2. Updated svelte dependencies, that fixed a TypeError: RegisterContext is not a constructor error. (Svelte compiler was in 'ssr' mode)

Fixes #224

(Also implemented support for preprocessors inside *.stories.svelte files)

@IanVS
Copy link
Member

IanVS commented Feb 12, 2022

Thanks for this PR, @bfanger! It looks like our check might need to be updated too?

Error: storybook-builder-vite requires @storybook/addon-svelte-csf to be installed when using @storybook/svelte. Please install it and start storybook again.

@bfanger
Copy link
Contributor Author

bfanger commented Feb 12, 2022

Ah, I missed adding a file in last commit. the locally compiled version of storybook-builder-vite already contained the change.

Not sure why CI fails on @storybook/addon-svelte-csf running the steps from buildExamples.yml locally (macOS) ran without error.

Copy link
Member

@IanVS IanVS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this! When running packages/example-svelte, I'm seeing this error in the browser console.

ClientApi.js:85 Uncaught Error: Singleton client API not yet initialized, cannot call `addArgTypesEnhancer`.

Any idea why that might be?

Also, I needed to add @storybook/svelte to the list in optimizeDeps.ts. Would you mind doing that here as well?

// const __storiesMetaData = parser(${componentName}, ${JSON.stringify(storiesDef)});
// export default __storiesMetaData.meta;
// ${storyDef};
// `);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, why is this commented out?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed the comment, (I copied it from @storybook/addon-svelte-csf for reference, but in contrary to the error message, the export was not the issue.)

@bfanger
Copy link
Contributor Author

bfanger commented Feb 16, 2022

Uncaught Error: Singleton client API not yet initialized, cannot call addArgTypesEnhancer.
That happens when there are multiple versions of the @storybook/client-api installed, each with its own singleton.
#50

After a yarn install I run
rm -rf ./node_modules/@storybook/svelte/node_modules/@storybook/client-api
rm -rf ./node_modules/@storybook/vue3/node_modules/@storybook/client-api

to fix that issue.

I think that's a bug in yarn, it should dedupe that dependency.

Copy link
Member

@IanVS IanVS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was really hoping somehow this would fix that issue, but yeah, I think it's some kind of yarn bug.

But yeah, after jumping through the hoops of removing the extra deps, this works great. Thanks for the help!

@IanVS IanVS merged commit 42131f4 into storybookjs:main Feb 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Problem after updating from 0.1.13 to 0.1.14. Sveltekit + Typescript + Storybook
2 participants