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

@storybook/[email protected] breaks module resolving if react folder in user sources #5204

Closed
galefebvre-adeo opened this issue Jan 10, 2019 · 4 comments

Comments

@galefebvre-adeo
Copy link

galefebvre-adeo commented Jan 10, 2019

Describe the bug

Having a src/react folder in the user sources breaks absolute imports with @storybook/[email protected].

To Reproduce
Steps to reproduce the behavior:

  1. Install latest yarn add -D @storybook/[email protected].
  2. Create a component in src/react/components/Button.jsx.
  3. Import this component from a story.
  4. Launch storybook start-storybook -p 9001 -c .storybook.
  5. Error in console Module not found: Error: Can't resolve 'react/components/Button' in XXX.

Expected behavior
The storybook builds fine.

System:

  • OS: Windows10
  • Framework: react
  • Version: 4.1.6

Additional context
This comes from this PR: #5148, specifically line 87 of lib/core/src/server/preview/iframe-webpack.config.js. It adds an alias of react to node_modules/react to make sure to import the react version of the user instead of the version used by the storybook ui. The problem is that webpack doesn't lookup the folders specified in resolve.modules (i.e. src) if it finds that the imported path matches an alias.

For the time being I simply overrode the webpack config in .storybook/webpack.config.js to remove the react alias since I'm using the same version as storybook.

// .storybook/webpack.config.js
module.exports = (baseConfig, env, defaultConfig) => {
  delete defaultConfig.resolve.alias.react;
  return defaultConfig;
};

This is not ideal since it basically removes the feature of importing the user react version. Not sure how to fix this besides changing the src/react folder name, but that makes storybook enforce an arbitrary rule to the user code base.

@stale
Copy link

stale bot commented Feb 7, 2019

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

@stale stale bot added the inactive label Feb 7, 2019
@mpelekh
Copy link

mpelekh commented Feb 22, 2019

The same issue exists with storybook/[email protected] as well.

@stale
Copy link

stale bot commented Mar 15, 2019

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

@stale stale bot added the inactive label Mar 15, 2019
@stale
Copy link

stale bot commented Apr 14, 2019

Hey there, it's me again! I am going close this issue to help our maintainers focus on the current development roadmap instead. If the issue mentioned is still a concern, please open a new ticket and mention this old one. Cheers and thanks for using Storybook!

@stale stale bot closed this as completed Apr 14, 2019
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

3 participants