cache-require-paths
cache-require-paths copied to clipboard
To save cache json requires a clean exit of the process.
.cache-require-paths.json was not getting created. Looked at code seems that a clean exist needs to be had but when adding it to an existing project that listens on sockets and serves http requests etc it does not exit normally.
Save cache after a timeout of say 5 seconds with an option to increase this time? Or maybe add a saveCache method?
The note in readme would be better placed under the Use section.
Note that the speedup only happens after the first application run finishes successfully and the process exits. The resolution cache needs to be saved to a local file, and this happens only on process exit.
Ok profiled my load up time in main script by putting
console.time('LoadTime') at the top of script under the require for cache-require-paths and a console.timeEnd('LoadTime') at the end.
Was getting 11232.503ms Added a
setTimeout(process.exit, 15000)
So that the cache json is saved to disk.
Removed the timeout and reset the script.
Now I'm getting 5936.497ms startup time thanks!
Not great, but I think I know why. I'm using WSL 2 on Windows 10 and app runs inside a docker container but I map the source code in using a volume which is from the Windows Drive and a Spinning disk at that.
From further reading, IO should be much,much faster in my scenario if mapping the source volume in from the WSL 2 home drive \\wsl$\Ubuntu\root
or something.
(Just putting this info here in-case it helps someone)