Check for existing results to rebuild#123
Conversation
|
Hi @anthony-zhou , appreciate your contribution and memory analyze. I see we have already similar PR opened #101, could you pls check it and make a new measurement with your test case? so we can kill 2 PRs if it successful. |
|
@floydspace After trying #101, the memory usage there is the same as before -- it increases exponentially (~3GB memory usage after 6 changes). I think the reason is that, in #101, the initial build is not created with the |
|
@anthony-zhou okay merging it. Looks fine for me |
|
🎉 This PR is included in version 1.10.5 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Currently, this plugin calls the ESBuild
buildmethod each time a file is changed.As documented in #98, this behavior results in exponentially increasing memory usage as files are changed. Personally, I saw my memory usage (from the esbuild process) spike from an initial value of 600 MB to 2GB after just 5 changes. Ultimately, the memory usage results in a fatal error, where the JavaScript heap runs out of memory.
What I did
In this pull request, I've added a conditional check in the
bundlemethod to callrebuildinstead ofbuildif there are existing build results.I also set the
bundlemethod to enable incremental builds by default. From what I understand, the way the ESBuild process works is as documented here:incremental: true.rebuildon the existing build result.Results
With the change in this PR, memory usage increases much more slowly. After about 10 file changes, the memory only increased to about 1GB (I noticed a linear increase of about 30MB each time). Further debugging is needed to determine the source of that slight memory usage increase, but it seems like this optimization addresses the majority of the existing increases in memory usage.