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: dedupe addons when merging storybook main config #5592

Merged
merged 3 commits into from
May 20, 2022

Conversation

jtoar
Copy link
Contributor

@jtoar jtoar commented May 19, 2022

Since we added @storybook/addon-essentials #4765, users that already have it in their storybook configs get the following error:

ERR! ValidationError: Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.

The reason is that webpack-merge doesn't seem to dedupe keys that have arrays. It just seems to concat them together. So if a user's storybook config in web/config/storybook.config.js is...

module.exports = {
  /**
   * This line adds all of Storybook's essential addons.
   *
   * @see {@link https://storybook.js.org/addons/tag/essentials}
   */
  addons: ['@storybook/addon-essentials'],
}

The result of this merge here:

return merge(baseConfig, userStorybookConfig)

is...

{
  addons: [
    '@storybook/addon-essentials',
    '@storybook/addon-a11y',
    '@storybook/addon-essentials'
  ],
  // other keys...
}

So this PR dedupes that key.

@jtoar jtoar self-assigned this May 19, 2022
@netlify
Copy link

netlify bot commented May 19, 2022

Deploy Preview for redwoodjs-docs canceled.

Name Link
🔨 Latest commit acac49e
🔍 Latest deploy log https://app.netlify.com/sites/redwoodjs-docs/deploys/6286d8546438130009b7825d

@jtoar jtoar changed the title Fix: dedupe addons when merging storybook main config Fix: dedupe addons when merging storybook main config May 19, 2022
@jtoar
Copy link
Contributor Author

jtoar commented May 19, 2022

@virtuoushub thoughts on if it makes sense to add a test for this?

@virtuoushub
Copy link
Collaborator

@virtuoushub thoughts on if it makes sense to add a test for this?

@jtoar my vote is that I'd rather get this fix out; I will add a line item to add tests for stuff like this in #5269

Copy link
Collaborator

@virtuoushub virtuoushub left a comment

Choose a reason for hiding this comment

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

Great find, thanks for this fix!

@jtoar jtoar enabled auto-merge (squash) May 19, 2022 23:52
@jtoar jtoar merged commit 091c7d3 into main May 20, 2022
@jtoar jtoar deleted the ds-dedupe-storybook-addons branch May 20, 2022 00:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Archived
Development

Successfully merging this pull request may close these issues.

2 participants