-
Notifications
You must be signed in to change notification settings - Fork 38
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
Fix empty transpiled file cache issue #227
Fix empty transpiled file cache issue #227
Conversation
@gilbsgilbs Please check it when you have time 🙏 |
Thanks for your contribution.
I'm not sure I understand this part. What would be the keys of such weakMap? Instances of Also, do you know at which point this broke? Or was it always broken somehow? Did you try with the latest release candidate + completely removing and recreating your lockfile and node_modules? |
I can confirm that this patch works great. Without this, the output will always be the last file. |
bac0bc1
to
6b8aee7
Compare
I just checked, and the api object indeed changes across calls (so I really don't understand how a weakmap is supposed to help here). I think the most sensible thing to do would be to create a cache per package.json (by using "root" or finding the closest to the source file using pkg-up or something) and fallback to a global cache only in last resort. But given nobody may actually have a use-case for this and as Added a commit with miscellaneous improvements not really related to your PR while I was playing around. Thanks for your contribution @xu3u4 🙏 . |
Published under 0.9.0-rc.1 . I'll make a final release at some point. |
Thank you very much! 🙏
Sorry it may not fit this case as the keys are string instead of object. But I guess the suggestion is trying to say that weakMap element can be garbage collected if the key is removed. |
To fix #208
I found the
exporterCache
object doesn't persist across all the runs in newer babel versions(7.16.10+).After some runs, it becomes empty.
The solution is inspired by babel/babel#13590 (comment)
It points out that the cache object needs to be put outside the plugin function. (maybe we can also consider to use
weakMap
for the performance improvement.)Btw, thank you for the awesome plugin, it really helps our i18n flow a lot by reducing many manual steps! 🌟 🌟 🌟