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

Request for making the condition more flexible for: Expected '@storybook/addon-docs' to be listed before '@storybook/addon-essentials' #13202

Closed
jon301 opened this issue Nov 21, 2020 · 2 comments

Comments

@jon301
Copy link
Contributor

jon301 commented Nov 21, 2020

Hey Storybook team :) Little request here:

Is your feature request related to a problem? Please describe
I'm trying to create a private package abstracting all storybook core dependencies (e.g. @storybook/react, @storybook/addon-essentials, babel-loader, etc.) so I would not have to install those manually in each of my projects.
This package would also return a minimal config with some defaults for the consumer. Something like that:

function getStorybookConfig(config) {
  return {
    ....
    addons: [
      require.resolve('@storybook/addon-essentials')
    ].concat(config.addons),
    ....
  };
}
module.exports = getStorybookConfig;

When starting storybook, essentials addons do not work, and I get the following warning in the console:

...
info => Adding stories defined in ".storybook/main.js"
WARN Expected '@storybook/addon-docs' to be listed before '@storybook/addon-controls' (or '@storybook/addon-essentials'). Check your main.js?
WARN
WARN https://github.com/storybookjs/storybook/issues/11442
info => Using custom postcss.config.js
...

After digging a bit, I've found the check in @storybook/addon-controls ensuring that Docs is placed before @storybook/addon-essentials :

return name && name.startsWith(addon);

The problem is that the condition uses startsWith('@storybook/addon-essentials').
And because my essentials addon is in a subpackage, I had to require.resolve it, giving the following path '/Users/jon301/my-app/node_modules/@jon301/my-storybook-preset/node_modules/@storybook/addon-essentials/dist/index.js', which does not satisfy the startsWith condition.

Describe the solution you'd like
Be more flexible by replacing name.startsWith(addon) by name.includes(addon).

Please let me know if you are OK with this and I'll create a PR 🙏
Thanks !

@shilman
Copy link
Member

shilman commented Nov 21, 2020

@jon301 Sounds good to me! PRs welcome! 🙏

@shilman
Copy link
Member

shilman commented Nov 25, 2020

Shiver me timbers!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.1.6 containing PR #13204 that references this issue. Upgrade today to the @latest NPM tag to try it out!

npx sb upgrade

Closing this issue. Please re-open if you think there's still more to do.

@shilman shilman closed this as completed Nov 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants