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

Work with create react app's output #309

Open
siddharthkp opened this issue Jun 25, 2019 · 0 comments
Open

Work with create react app's output #309

siddharthkp opened this issue Jun 25, 2019 · 0 comments
Labels
feature request has-dependency This issue depends on another issue's implementation

Comments

@siddharthkp
Copy link
Owner

siddharthkp commented Jun 25, 2019

Problem

As a create-react-app / nexstjs / gatsby user, you don't know the name of the build files ahead of time.

You can use bundlesize's glob matching to get files

[
  {
    // this will catch each file individually, not in total
    "path": "build/static/**/*.js",
    "maxSize": "50 kB"
  }
]

which matches an unknown number of files:

41.58 KB  build/static/js/1.238fbfd9.chunk.js
2.36 KB   build/static/js/main.4ba9e49b.chunk.js
1.53 KB   build/static/css/main.9663333b.chunk.css
763 B     build/static/js/runtime~main.229c360f.js

This can be fine tuned by a bundlesize config:

[
  {
    "path": "build/static/**/main*.js",
     "maxSize": "5 kB"
  },
  {
    "path": "build/static/**/*.chunk.js",
     "maxSize": "50 kB"
  }
]

Which is okay, but, there are two problems with this approach overall:

  1. Based on tribal knowledge, you either know where to look or you don't. It's not obvious at all because you would ideally not need to look at the built files.

  2. Depends on an implementation detail that can break across different versions of react-scripts

 

Possible solution:

One possible way to enable a better developer experience (DX) is to read the manifest file and pass those files from that to bundlesize. For create-react-app, that's build/asset-manifest.json.

You'll still need to ask for the maxSize but instead of globs, it can be in terms of main and chunk (or page1, page2 depending on the tool)

This probably should not be in the core, but instead in a plugin (see discussion about plugin system in <#placeholder>)

 

Note: Replace create-react-app with nextjs and you have another feature request

@siddharthkp siddharthkp added this to the Easier to configure milestone Jun 25, 2019
@siddharthkp siddharthkp added this to To do in Road to 1.0.0 Jun 27, 2019
@siddharthkp siddharthkp added the has-dependency This issue depends on another issue's implementation label Jun 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request has-dependency This issue depends on another issue's implementation
Projects
Road to 1.0.0
  
To do
Development

No branches or pull requests

1 participant