You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(traverse + block-scoping) → AST → traverse.clearCache() → (traverseFromAST + mangle) results in a naming conflict :)
The following code:
constbabel=require('babel-core');consttraverse=require('babel-traverse').default;constmangle=require('./packages/babel-plugin-minify-mangle-names/lib/index.js');constsrcTxt=` function f(x) { for (let i = 0; i; i++) { let n; if (n) return; g(() => n); } }`;constast=babel.transform(srcTxt,{code: false,plugins: ['transform-es2015-block-scoping'],}).ast;traverse.clearCache();constcode=babel.transformFromAst(ast,null,{plugins: [mangle],}).code;console.log(code);
Sidenote: @kittens Is there any reason that babel.transform* doesn't call traverse.clearCache() before or after it runs? Seems like you'd always want that unless I'm missing something
TLDR:
(traverse + block-scoping) → AST → traverse.clearCache() → (traverseFromAST + mangle) results in a naming conflict :)
The following code:
produces this output:
Notice conflict between
a
in arguments anda
in a loop block. RemovingclearCache
fixes it BUT then mangling is incomplete:The text was updated successfully, but these errors were encountered: