-
Notifications
You must be signed in to change notification settings - Fork 292
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
Webpack next caching #162
Webpack next caching #162
Conversation
5cf4b30
to
2168863
Compare
CI failure here is due to Javascript heap out of memory :( I've tried bumping the heap size. |
Seems like it could be related to a memory leak in Webpack 5. I would refrain from bumping it further, as we shouldn't see such increased memory use relative to the webpack 4 branch |
So it looks like this is actually only happening when running the tests with coverage (as is done on CI). Seems like it might be jestjs/jest#5837 then. |
Codecov Report
@@ Coverage Diff @@
## master #162 +/- ##
==========================================
- Coverage 77.29% 67.35% -9.95%
==========================================
Files 11 12 +1
Lines 511 579 +68
==========================================
- Hits 395 390 -5
- Misses 116 189 +73
Continue to review full report at Codecov.
|
6b7be97
to
26cb3ff
Compare
Ok, finally got this fixed with a manual GC run. Turns out the bump before would have fixed it to, it was just done on the wrong test. For the coverage - because we don't have coverage on the |
34ad8c3
to
9911d86
Compare
test/index.test.js
Outdated
{ | ||
// enabling cache stops saslprep.js test from working | ||
// which seems like a Webpack 5 cache bug... | ||
cache: false, |
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.
The saslprep.js
test was failing until I disabled the cache explicitly. The failure was that the asset wasn't being emitted.
When the saslprep.js test is run on its own in isolation it passes fine, regardless of cache state, so it seems like some kind of interaction between webpack cache and previous build memoization.
Because it works in isolation fine, and this is the only test that fails, I don't think this is as bad as it sounds, but it's worth bearing in mind.
The remaining error here is that switching from the "src" to the "dist" ncc build results in Webpack assigning different ids to the modules so the unit test output tests fail! For now, I've just commited the two versions as I have no idea how to trace down why there is a difference between the two in Webpack 5 only... |
d427fc4
to
db6eb51
Compare
41d481a
to
99b03ca
Compare
I've updated this branch to include a watcher for both the API and CLI through |
99b03ca
to
2a1a02d
Compare
Implements the "next" webpack branch caching for #46.
Here are the stats for the self build:
And in fact the remaining time there is actually mostly minification, so it should be possible to get this down to of the order of seconds pretty easily if we go with the approach in #115.
The Webpack upgrade was mostly pretty smooth. There was an issue with the parser injection for the top-level return handling, which was tricky to fix as there seemed to be a different instance of the parser in use in Webpack to the one we could hook into.
Instead I have disabled that test for now, and also posted a Webpack bug and PR for the root cause at webpack/webpack#8509 and webpack/webpack#8510.
Cache Handling
I couldn't work out how to manage the cache with a custom persistence layer here, so Webpack is entirely owning the file system side of things here.
There is currently no cache eviction, this seems like it will be an area of development in Webpack 5 to handle evicting old items as the cache reaches a certain size based on usage, otherwise it it at risk of eventually "taking over" the file system entirely :P
The other thing that was mentioned in the PR thread was handling "relocations" of the cache. Eg if I have app1/node_modules/dep1 and another app has the same app2/node_modules/dep1 there is a lot of duplication going on. Again, this is something that would likely need to happen on the Webpack core side to better handle these types of redundancies. Perhaps this relocation is more of a problem for ncc maintaining its own cache, as webpack actually defaults to
node_modules/.cache/webpack
for a per-project cache, while the ncc cache is across-projects.The final thing to watch out for will of course be invalidation issues, which will likely be the most important thing to test for releasing this.
API
The API gets a
cache
option which is the string directory to use for the cache defaulting toos.tmpdir/ncc-cache
. The cache can be disabled withcache: false
(it is on by default).CLI
The CLI commands are
ncc cache clean
,ncc cache dir
andncc cache size
.It also comes with a new
--no-cache
flag.