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

Don't mangle function names for production builds #2705

Merged

Conversation

pascalduez
Copy link
Contributor

@pascalduez pascalduez commented Jan 10, 2018

Issue:

Function names are mangled by UglifyJS during production build.
They are important for React stateless components, especially in a styleguide context such as Storybook. This allows playing nicely with third party libraries such as react-element-to-jsx-string.
The issue happened after #2530.

What I did

Passed the compress: { keep_fnames: true } option to all production builds UglifyJS plugin.
Did not noticed significant bundle size increase on our internal styleguide, which is quite large.

How to test

Is this testable with jest or storyshots? Nope

Does this need a new example in the kitchen sink apps? Nope

Does this need an update to the documentation? Nope

If your answer is yes to any of these, please make sure to include it in your PR.

@codecov
Copy link

codecov bot commented Jan 10, 2018

Codecov Report

Merging #2705 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2705   +/-   ##
=======================================
  Coverage   34.35%   34.35%           
=======================================
  Files         390      390           
  Lines        8772     8772           
  Branches      911      916    +5     
=======================================
  Hits         3014     3014           
- Misses       5136     5140    +4     
+ Partials      622      618    -4
Impacted Files Coverage Δ
app/react/src/server/config/webpack.config.prod.js 0% <ø> (ø) ⬆️
app/vue/src/server/config/webpack.config.prod.js 0% <ø> (ø) ⬆️
...ct-native/src/server/config/webpack.config.prod.js 0% <ø> (ø) ⬆️
...p/angular/src/server/config/webpack.config.prod.js 0% <ø> (ø) ⬆️
app/react/src/server/config/babel.js 0% <0%> (-100%) ⬇️
app/react/src/server/utils.js 0% <0%> (-53.58%) ⬇️
...-native/src/preview/components/OnDeviceUI/style.js 0% <0%> (ø) ⬆️
addons/events/src/components/Event.js 38.55% <0%> (ø) ⬆️
addons/info/src/components/types/Enum.js 0% <0%> (ø) ⬆️
addons/info/src/components/Story.js 88.88% <0%> (ø) ⬆️
... and 61 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 41813b6...960a804. Read the comment docs.

@Hypnosphi
Copy link
Member

Thanks @pascalduez , totally makes sense

@pascalduez
Copy link
Contributor Author

Not sure if this should be applied to Angular, Vue builds as well.

Copy link
Member

@Hypnosphi Hypnosphi left a comment

Choose a reason for hiding this comment

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

Not sure if this should be applied to Angular, Vue builds as well.

It should, please do that

@pascalduez pascalduez force-pushed the feature/minify-nomangle-fn-names branch from 48a980d to e5d29f2 Compare January 10, 2018 16:26
@pascalduez pascalduez changed the title Don't mangle function names for react production build Don't mangle function names for react builds Jan 10, 2018
@pascalduez pascalduez changed the title Don't mangle function names for react builds Don't mangle function names for production builds Jan 10, 2018
@pascalduez
Copy link
Contributor Author

@Hypnosphi Done.

@Hypnosphi Hypnosphi added vue react angular patch:yes Bugfix & documentation PR that need to be picked to main branch labels Jan 10, 2018
@Hypnosphi Hypnosphi merged commit eeb012a into storybookjs:master Jan 10, 2018
shilman pushed a commit that referenced this pull request Jan 13, 2018
…ames

Don't mangle function names for production builds
@Hypnosphi Hypnosphi added patch:done Patch/release PRs already cherry-picked to main/release branch and removed patch:done Patch/release PRs already cherry-picked to main/release branch labels Mar 6, 2018
@pascalduez pascalduez deleted the feature/minify-nomangle-fn-names branch August 17, 2020 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
angular patch:done Patch/release PRs already cherry-picked to main/release branch patch:yes Bugfix & documentation PR that need to be picked to main branch react vue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants