You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The expected result should be: [vite] hmr update /src/my-element.ts
when set storyStoreV7: true,
update /src/my-element.ts, then got the error Log:
Failed to execute 'define' on 'CustomElementRegistry': the name "my-element" has already been used with this registry
Error: Failed to execute 'define' on 'CustomElementRegistry': the name "my-element" has already been used with this registry
at legacyCustomElement (http://localhost:6008/node_modules/.vite-storybook/deps/lit_decorators_js.js?v=53feff7d:16:25)
at http://localhost:6008/node_modules/.vite-storybook/deps/lit_decorators_js.js?v=53feff7d:29:99
at __decorateClass (http://localhost:6008/src/my-element.ts?t=1651908414168:7:57)
at http://localhost:6008/src/my-element.ts?t=1651908414168:50:13
The expected result should be: [vite] hmr update /src/my-element.ts
IanVS
changed the title
[Bug] HMR & storyStoreV7 is not works with framework: "@storybook/web-components"
[Bug] storyStoreV7 is not compatible with framework: "@storybook/web-components"
May 8, 2022
Fixes#370.
When using `storyStoreV7`, we configure HMR to swap out the `importFn` when stories change. However, this breaks web-components projects (see https://github.com/storybookjs/storybook/tree/master/app/web-components#setup-page-reload-via-hmr).
So, instead, this change checks if the framework is `web-components` and if so, refreshes the page instead of performing an HMR. It's still pretty quick, and not a full page reload.
You can test this out by starting up our `lit-ts` example (which I've configured to use storyStoreV7 now), open the story, and save the component or story file. It shouldn't blow up anymore.
One bummer is that MDX files also no longer HMR, though technically they could. But I can't find a way to detect which part of the `importFn` changed, in order to determine whether to HMR or not, and it's safer to just avoid it for all stories when using web-components.
What version of
vite
are you using?2.9.7
System info and storybook versions
Environment Info:
System:
OS: macOS 10.15.7
CPU: (12) x64 Intel(R) Core(TM) i7-8700B CPU @ 3.20GHz
Binaries:
Node: 16.14.0 - ~/.nvm/versions/node/v16.14.0/bin/node
Yarn: 3.2.0 - ~/.nvm/versions/node/v16.14.0/bin/yarn
npm: 8.3.1 - ~/.nvm/versions/node/v16.14.0/bin/npm
Browsers:
Chrome: 101.0.4951.54
Firefox: 100.0
Safari: 15.0
npmPackages:
@storybook/addon-actions: ^6.4.22 => 6.4.22
@storybook/addon-essentials: ^6.4.22 => 6.4.22
@storybook/addon-links: ^6.4.22 => 6.4.22
@storybook/builder-vite: ^0.1.33 => 0.1.33
@storybook/web-components: ^6.4.22 => 6.4.22
Describe the Bug
when not set storyStoreV7:
update /src/my-element.ts , got the Log :
[vite] page reload src/my-element.ts
The expected result should be:
[vite] hmr update /src/my-element.ts
when set
storyStoreV7: true
,update /src/my-element.ts, then got the error Log:
The expected result should be:
[vite] hmr update /src/my-element.ts
Link to Minimal Reproducible Example
https://github.com/boeto/test-vite-lit-storybook-story-store-V7
Participation
The text was updated successfully, but these errors were encountered: