minify-builtins leaks vars

Created on 8 Mar 2017  路  3Comments  路  Source: babel/minify

minify-builtins leaks the variables it produces. It needs to look and see if the rest of the code is in an IIFE and put its vars inside if so. And being outside the IIFE, the vars aren't mangled (#425) so that it doesn't decrease the file size and probably not even the gzipped size!

bug has PR

All 3 comments

Hey @curiousdannii! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community that typically always has someone willing to help. You can sign-up here
for an invite.

Moving vars to global scope can be problematic for script concatenation, and the use of var means it can trample global variables in a browser context.

The string deduplicator plugin I wrote has a similar problem with where to put the string declarations, and I solved this by only iterating the top-level scopes and moving variable declarations to the top of these scopes. This is effective in a browser context since use of file-level scopes is common and guarantees the plugin is always safe to apply. minify-builtins ought to take a similar approach IMO, but note that if you know you're in a module context, it is safe to use the top level, which my code didn't take in to account.

Also, there is builtIns: false in preset options.

Was this page helpful?
0 / 5 - 0 ratings