-
Notifications
You must be signed in to change notification settings - Fork 27.6k
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
[WIP] Build optimizations #5810
Conversation
We'll squash the PR, so I guess keeping the history here is fine either way. However I think we're pinging everyone that ever contributed to babel-loader with this as the PR is showing 56 participants |
Squashed the commits to remove all the extra participants (sorry about that!). Will address other feedback later today. Thanks! |
From what I gather, this PR implements a custom babel webpack loader with a file system cache. Since webpack5 will have built-in persistent caching (https://twitter.com/TheLarkInn/status/1069246795031576576), will we still need this? I am keen to have an FS-backed cache for next.js asap though, so this looks great! |
@divmain Also, would this loader be useful for other webpack projects? Maybe its better to create a separate repo for it. Also, not sure how close it is to being merged and released, but it might be an idea to override the |
Just occurred to me that this is will not really improve things more than babel's |
# Conflicts: # packages/next/build/webpack/loaders/next-babel-loader/index.js # packages/next/export/index.js # packages/next/package.json
This increase is eliminated when the bundles are gzip'd. There are subtle differences with bundle output, mostly where export names are either preserved or changed differently than before the build-optimizations PR.
@@ -69,7 +69,7 @@ | |||
"http-status": "1.0.1", | |||
"launch-editor": "2.2.1", | |||
"loader-utils": "1.1.0", | |||
"mkdirp-then": "1.2.0", | |||
"mkdirp": "0.5.1", |
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'd go with make-dir
since it's already in the dependency tree via find-cache-dir
.
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'm going to close this PR for now, we'll revisit it 🔜
This PR is probably worth looking at now. All tests pass, although I do intend to add additional tests. I also need to pull in latest
canary
;please advise on direction for the question at the end of this PR description, and that'll inform how I pull in latestcanary
commits.Measuring wins was difficult; I was looking for a good React project (or projects) that could be used to test performance changes (both for this PR and others), but without much success. I put together fuzzponent for this purpose. Given a seed and a recurse-depth, it'll generate a large tree of React component JS files, PRNG-style.
Performance has definitely improved with the changes in this PR. To test, I generated a project of 3021 React components with
fuzzponent -d 2 -s 206
. If you run that command, you should get the same components.All times were measured w/
time next build .
. I haven't yet investigated dev build times; I don't expect to see significant changes. Cold cache times improved because server build step improved (client build warmed the cache).The loader exposes an API for a non-FS-backed cache. This could be an in-memory cache, Redis, or something else.
(no longer relevant)
There are a ton of commits showing here - that is because I preserved the git commit history for
babel-loader
when pulling it in with:I can squash all of that if you don't see value in having history for those files.
@timneutkens @rauchg