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

Import Link from Gatsby breaks Storybook #29702

Closed
daviddelusenet opened this issue Feb 23, 2021 · 3 comments
Closed

Import Link from Gatsby breaks Storybook #29702

daviddelusenet opened this issue Feb 23, 2021 · 3 comments
Labels
type: bug An issue or pull request relating to a bug in Gatsby

Comments

@daviddelusenet
Copy link

There's already an issue for this but it's closed. However, this bug is still happening even when using the latest versions of Gatsby and Storybook. It really should be fixed.

Related issue: #10668

@daviddelusenet daviddelusenet added the type: bug An issue or pull request relating to a bug in Gatsby label Feb 23, 2021
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Feb 23, 2021
@LekoArts LekoArts removed the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Feb 23, 2021
@LekoArts
Copy link
Contributor

Thank you for opening this!

This is something that should be fixed on Storybook's side so that's why the issue is closed. Storybook needs to be made aware of Gatsby's modules, and it seams the best solution to this is a preset/addon. This feature request is tracked there: #28304

We're marking this issue as answered and closing it for now but please feel free to comment here if you would like to continue this discussion. We also recommend heading over to our communities if you have questions that are not bug reports or feature requests. We hope we managed to help and thank you for using Gatsby!

@TeoTN
Copy link

TeoTN commented Jul 1, 2021

The workaround no longer works with Storybook 6

@ertrzyiks
Copy link

I had the same problem with storybook 6.5 + vite loader + gatsby. I realized that I don't even need storybook to import gatsby so I provided a module replacement.

main.js

module.exports = {
  async viteFinal(config, { configType }) {
    return mergeConfig(config, {
      resolve: {
        alias: {
          gatsby: path.resolve(__dirname, './mocks/gatsby'),
        },
      },
    })
  }
}

and mocks/gatsby.js

import GatsbyLink from 'gatsby-link'

export const Link = GatsbyLink

// Possibly stub other functions
// export function graphql() {
//  return null
//}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

No branches or pull requests

4 participants