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

CRA's webpack configuration is mangling function names (and removing prop types) in static build #4717

Closed
jansav opened this issue Nov 5, 2018 · 2 comments

Comments

@jansav
Copy link

jansav commented Nov 5, 2018

Describe the bug
When webpack configuration is used directly when CRA, it causes build-storybook to mangle function names. This causes issues that code source and prop types are not presented correctly.

As #3879 says, it could be solved by adding .displayName to each component, but since CRA is now removing prop types in production builds (facebook/create-react-app#3818), prop types are not visible in static version of storybook.

To Reproduce
Steps to reproduce the behavior:

  1. Create app using Create React App
  2. Install storybook
  3. Create functional component and stories for it
  4. Runnpm run build-storybook (without having custom webpack configuration)
  5. Serve static storybook and see results.

Expected behavior
Function name is used as display name. Prop types are visible in page.

System:

  • Framework: React, react-scripts (2.1.1)
  • Addons: Info, knobs, options
  • Version: 4.0.2

Additional context
It might be that this is something that storybook can't really do anything else than suggest not using CRA's webpack configuration directly. However I would like to see if there is any suggestions how to solve this issue without using full control mode.

@jansav jansav changed the title CRA's webpack configuration is mangling function names in static build CRA's webpack configuration is mangling function names (and removing prop types) in static build Nov 5, 2018
@jansav
Copy link
Author

jansav commented Nov 13, 2018

Any tips?

@davidchristie
Copy link

I recently hit this issue when upgrading @types/react to version 16.7.6.

Dropping back to 16.4.18 fixed it for me: davidchristie/social-network@9d6f004

@shilman shilman added cra Prioritize create-react-app compatibility question / support labels Nov 22, 2018
@igor-dv igor-dv removed the cra Prioritize create-react-app compatibility label Nov 23, 2018
@igor-dv igor-dv added the merged label Nov 24, 2018
@igor-dv igor-dv closed this as completed Nov 25, 2018
@issue-sh issue-sh bot removed the merged label Nov 25, 2018
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

4 participants