From fb85dc03b12b79906181fd64d3740767d03757e6 Mon Sep 17 00:00:00 2001 From: Kiko Beats Date: Sat, 28 Sep 2019 21:20:17 +0200 Subject: [PATCH] fix: don't reload not required modules --- bin/watch/restart-server.js | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/bin/watch/restart-server.js b/bin/watch/restart-server.js index d0aa132..e0e836d 100644 --- a/bin/watch/restart-server.js +++ b/bin/watch/restart-server.js @@ -29,15 +29,9 @@ module.exports = ({ spinner, filepath, pkg, cwd, cli, watchFiles, port, watcher, // Remove file that changed from the `require` cache for (const item of toDelete) { - let location - - try { - location = require.resolve(item) - } catch (err) { - continue - } - - clearModule(location) + // discard items not required before + if (!require.cache[item]) continue + clearModule(item) } // Restart the server