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

re-expose a way to get webpack stats.json #8789

Closed
samccone opened this issue Apr 5, 2020 · 0 comments · Fixed by #8790
Closed

re-expose a way to get webpack stats.json #8789

samccone opened this issue Apr 5, 2020 · 0 comments · Fixed by #8790

Comments

@samccone
Copy link
Contributor

samccone commented Apr 5, 2020

Is your proposal related to a problem?

In CRA 2.X it was possible via a --stats flag to dump out webpack's stats.json file for further bundle analysis.

This functionality was originally from:
7c85938

And then was removed via a combination of changes:

  1. primary removal:
    e7a427a

  2. additional cleanup here:
    140e182

This was originally reported as a breaking change back on Apr 25, 2019
#6904

The conversation on this thread was focused around bundle file source analysis which could rightfully be done with only using the sourcemaps. The conversation however missed the perspective that the stats.json file holds more information than just file size. The stats.json file contains a mapping between files and their dependencies. This module level dependency information is critical to understand and answer questions like:

"why am I pulling in this file"

"how is this file getting into my bundle"

"how many source files depend on this file".

All of these are questions that we are aiming to answer with tooling like bundle-buddy. Full details and design of this here:
https://docs.google.com/document/d/1ycGVBJmwIVs34yhC0oTqv_WH5f0fs2SAFmzyTiBK99k/edit

We have done work with Rome, Rollup, and the webpack teams to expose this information. However with CRA dropping the ability to get stats.json we are now unable to provide this level of analysis to users.

Describe the solution you'd like

Expose the --stats flag again

Which can be done via a rollback of this change
e7a427a
(Describe your proposed solution here.)

⭐️ ⭐️ ⭐️
I have prepared and tested this change in a PR #8790
⭐️ ⭐️ ⭐️

Describe alternatives you've considered

Only supporting CRA 2.0

Pros:
No work needed

Cons:
Makes it impossible for people using newer versions of CRA to understand their bundle size

Requiring people to manually apply a patch to react-scripts

Pros:
no work needed by the core team

Cons:
Significantly more friction for developers to do this sort of analysis
Manual patch will drift from the source code meaning a continual amount of upkeep required to the patch

samccone added a commit to samccone/create-react-app that referenced this issue Apr 5, 2020
This commit is a manual revert of the following commits:
facebook@e7a427a
facebook@140e182

And a re-introduction of
facebook@7c85938

Fixes: facebook#8789
Fixes: facebook#6904

Tested:

Manually ran yarn link and then ran yarn build from a 3.x version of CRA
with react-scripts linked in from this patch.

Verification:
Saw that a bundle-stats.json file was written out where as before in the
pre-linked version it was not.
@samccone samccone changed the title reexpose a way to get webpack stats.json re-expose a way to get webpack stats.json Apr 5, 2020
@lock lock bot locked and limited conversation to collaborators May 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant