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

Accessing non-existent addons channel #19

Closed
IanVS opened this issue Jun 2, 2021 · 6 comments · Fixed by #22
Closed

Accessing non-existent addons channel #19

IanVS opened this issue Jun 2, 2021 · 6 comments · Fixed by #22

Comments

@IanVS
Copy link
Member

IanVS commented Jun 2, 2021

Hi, I'm just switching over to vite, and trying out this builder, and while it seems to build correctly in the terminal, when storybook opens I see an error in the console, and the page does not finish loading:

Uncaught Error: Accessing non-existent addons channel, see https://storybook.js.org/basics/faq/#why-is-there-no-addons-channel
    at AddonStore2.getChannel (:6006/@fs/Users//.../node_modules/storybook-builder-vite/node_modules/.vite/chunk-LAF5HDGZ.js?v=485b51f5:365)
    at :6006/@fs/Users/.../.storybook/preview.js:18

I am using storybook-dark-mode, and listening to events from that addon using their instructions like: https://github.com/hipstersmoothie/storybook-dark-mode#events. This worked fine with the default storybook webpack builder.

Edit: when I remove that addon, I get a similar error from addon-a11y.

I am using storybook 6.3.0-beta.2

@julrich
Copy link

julrich commented Jun 2, 2021

addon-a11y is known to be broken with the vite builder (see #6).

And storybook-dark-mode failed for me, too. Pretty sure it was related to missing esm-modules for dependencies of the plugin, or the plugin itself. We've deactivated it for the time being. But would be open to investigate further, as we liked the plugin itself!

@eirslett
Copy link
Collaborator

eirslett commented Jun 3, 2021

Many of these issues can be fixed by looking at the dependencies - if they use CJS modules (require, module.exports etc) the "easy" fix is to switch to ESM modules (import/export). I don't use these addons myself.

@julrich
Copy link

julrich commented Jun 3, 2021

Speaking for us: we'll probably not go back to addons that don't or won't offer esm-compatible versions.
The other potential solutions (afaik) all imply compromising on the gained performance... potentially (worst case) landing you back where you started to begin with.

Probably a matter of the responsiveness of the original authors, and if they're open to PRs, how fast this can be fixed.
Seems to me quite some of the addons are not under super active development, unfortunately.

@IanVS
Copy link
Member Author

IanVS commented Jun 3, 2021

I don't think this issue is a problem in another plugin. Getting the addon channel should work, I think, right?

@IanVS
Copy link
Member Author

IanVS commented Jun 9, 2021

This seems to have been a problem from using the default export of @storybook/addons, instead of the named export as is suggested in https://github.com/storybookjs/storybook/blob/0981b635eed95b48998b9a5fd6d67216802324fb/lib/addons/src/public_api.ts#L3. Many other parts of storybook also import the default, which causes problems for this builder.

@IanVS
Copy link
Member Author

IanVS commented Jun 9, 2021

Upon further investigation, I don't think it's entirely a problem with the default import. I've created a reproduction of the issue here: https://github.com/IanVS/storybook-vite-issue-19.

It seems that @storybook/react doesn't call the client start method early enough. If I place a throw new Error('starting') line just above https://github.com/storybookjs/storybook/blob/next/app/react/src/client/preview/index.ts#L20 in my node_modules, it gets hit when I don't try to call addons.getChannel(), but never fires when I try to get the channel.

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 a pull request may close this issue.

3 participants