-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Add instructions to use source-map-explorer #1641
Conversation
37183a8
to
83f302c
Compare
README.md
Outdated
@@ -104,6 +104,7 @@ The [User Guide](https://github.com/facebookincubator/create-react-app/blob/mast | |||
- [Updating to New Releases](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#updating-to-new-releases) | |||
- [Folder Structure](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#folder-structure) | |||
- [Available Scripts](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#available-scripts) | |||
- [Adding bundle analyzer script (source-map-explorer)](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#adding-bundle-analyzer-scrip-source-map-explorer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would move this closer to the end (perhaps before Deployment) and call the section Analyzing the Bundle Size
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved
"build": "react-scripts build", | ||
"test": "react-scripts test --env=jsdom", | ||
+ "analyze": "source-map-explorer build/static/js/main.* " | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please explain what to do next.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
83f302c
to
4cb5934
Compare
The wildcard in this command fails on Windows 10 with error "no such file or directory". I wasn't able to find an alternative other than changing it to
May want to include a disclaimer in there. |
I will play around with it when I get home and see if I can't find a solution for windows. Thanks for the heads up. |
I have tried the @gr33nfury Thanks for sharing! |
4cb5934
to
5d44850
Compare
@hostr Sorry it took me so long to get back to this. I updated the README. I tried finding another way in windows but I also couldn't get anything other than typing the full name of the file out to work. |
almost a month has passed, any news about this issue? |
I'm not sure what it is waiting on. Is there still something I need to change? |
Why not adding source-map-explorer to create-react-app? |
We would love a brief writeup to explain how to analyze the produced output. Tell the users what to be on the lookout for, explain that huge (squares) modules are what's taking up space, that they may want to see if they offer a es6 build that may reduce size, etc. |
May I suggest @gr33nfury something like: Analyzing and reducing the bundle sizeThe size of the Javascript bundle directly impacts the time your application takes to load, in particular on mobile devices. Without any tooling, it may be painful to reduce the size of the bundle. To add source-map-explorer in your CRA project: npm install source-map-explorer --save-dev Then you can generate a report by typing: npm run build
./node_modules/.bin/source-map-explorer build/static/js/main.* It should open a html report in your browser similar to the following: In this interactive report, each module is represented by a rectangle. The bigger the rectangle, the bigger the module in bytes. All the sizes listed here are uncompressed. If you feel that some of your modules is too large, you can:
If you feel that a third party module is too large compared to the functionalities it provides, you may:
You also may notice the bundle can contain 2 different versions of the same module (like React for instance), it usually comes from the peer dependencies being incompatible. |
@baptistemanson @Timer |
I've been using it more lately and I don't know how I ever lived without Maybe there's an API we can leverage as a secondary package to recommend / suggest to the user what to change / defer loading. I'm a little tied up with work right now so I can't lay out a more detailed plan, but in a few days I'll have some free time. |
@baptistemanson - I reckon you should go ahead and add I wouldn't think this requires e2e or any other tests. But one of the maintainers might correct me. They might want an e2e just to make sure the command works across platform etc. I think making automated recommendations to the user is pretty hard. Just letting people see whats causing issues is a huge help. For me personally, its allowed me to fine heaps of large bundles being imported by packages I use and make PRs to remove them. Often it's something silly like all of lodash being imported just for one function. Or just realise when I should roll my own because the dependency is much too large. |
@ro-savage @Timer why do you use source-map-explorer and not webpack-bundle-analyzer? Just wondering because I myself find the source-map-explorer UI so unclear and cluttered. (Maybe for me it helps to have the color distinction or something. Although I do understand different strokes.. ;) ) |
@SR-H see this twitter thread for context
I do not believe this is a path we are going to take, but there will be discussions soon once |
@Timer beautiful, thanks! |
@Timer That's referring to webpack-bundle-size-analyzer not webpack-bundle-analyzer, does the latter also have that same issue? (I havent noticed that in my apps before I started using CRA) |
@SR-H |
Cool :) |
This is really great. Thank you. |
* upstream/master: (55 commits) Fix minor typo (facebook#2679) Bootstrap with Yarn when available (facebook#2673) Add more info about apache client side routing (facebook#2666) Test Node 8 on Travis (facebook#2659) Add json and css to lint-staged in template README (facebook#2671) Add a note about fixed vulnerability in 1.0.8 Publish Changelog for 1.0.8 (facebook#2664) Reformat source code with Prettier 1.5.2 Update Prettier to v1 (facebook#2465) Update ISSUE_TEMPLATE.md Local testing docker links (facebook#2662) Better React Native Web support (facebook#2511) Bump dependencies (facebook#2658) Minor code style edits to user guide (facebook#2660) Don't ask to install webpack for using Styleguidist (facebook#2656) Put react-scripts in dependencies, not devDependencies (facebook#2657) Razzle added to the alternatives (facebook#2517) Warn about large bundle sizes (facebook#2648) Add instructions to use source-map-explorer (facebook#1641) ... # Conflicts: # packages/react-dev-utils/package.json # packages/react-scripts/config/webpack.config.dev.js # packages/react-scripts/config/webpack.config.prod.js # packages/react-scripts/package.json
#798
Add steps in the README to add source-map-explorer to a create react app project
Changes discussed in #1464