1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-30 08:09:15 +01:00
metamask-extension/patches/watchify+4.0.0.patch
Elliot Winkler e951fe6a64
Improve autorebuilding in dev to reduce CPU load (#11886)
On an M1 Mac, when running `yarn start`, CPU can spike to 100% CPU, and
sometimes a bunch of `mdworker` instances will get spawned. This seems
to be caused by the file-watching mechanism used in dev to automatically
regenerate the build when something is changed. More specifically, we
are using an older version of `watchify`, which uses an older version of
`chokidar`, which is the package that actually does the watching. v4.0.0
of `watchify` upgrades `chokidar` to v3.x ([1]), which comes with
"massive CPU & RAM consumption improvements" ([2]). After the upgrade,
CPU usage decreases to 20-40%.

[1]: https://github.com/browserify/watchify/blob/master/CHANGELOG.md#400
[2]: https://github.com/paulmillr/chokidar/releases/tag/3.0.0
2021-10-25 13:56:26 -06:00

39 lines
1.1 KiB
Diff

diff --git a/node_modules/watchify/index.js b/node_modules/watchify/index.js
index 0753b9f..05efb1b 100644
--- a/node_modules/watchify/index.js
+++ b/node_modules/watchify/index.js
@@ -58,33 +58,6 @@ function watchify (b, opts) {
if (pkgcache) pkgcache[file] = pkg;
});
- b.on('reset', reset);
- reset();
-
- function reset () {
- var time = null;
- var bytes = 0;
- b.pipeline.get('record').on('end', function () {
- time = Date.now();
- });
-
- b.pipeline.get('wrap').push(through(write, end));
- function write (buf, enc, next) {
- bytes += buf.length;
- this.push(buf);
- next();
- }
- function end () {
- var delta = Date.now() - time;
- b.emit('time', delta);
- b.emit('bytes', bytes);
- b.emit('log', bytes + ' bytes written ('
- + (delta / 1000).toFixed(2) + ' seconds)'
- );
- this.push(null);
- }
- }
-
var fwatchers = {};
var fwatcherFiles = {};
var ignoredFiles = {};