Closed HeWenKe closed 1 year ago
Please provide a reproduction as well as the expected behavior.
look under code const a = 'a'; const b = 'b'; const c = 'c'; let ary = []; for (let val of ['a','b','c']){ ary.push(eval(val)) } console.log(ary) //打包以上代码,会把变量a,b,c 全部remove 掉,导致我for 循环的时候,找不到
Edit by @rschristian for clarity:
const a = 'a';
const b = 'b';
const c = 'c';
let ary = [];
for (let val of ['a','b','c']){
ary.push(eval(val))
}
console.log(ary)
a
, b
, and c
are incorrectly stripped out, they're seen as dead code despite the later eval()
call.
This is probably an upstream issue, but will look into it.
perfect, can you speak chinese ? can ,netx time please speak it。wowo
No, I cannot. Just tossed it into Google translate and hoped for the best.
ok,thanks
Upstream "issue" in Rollup, see: https://github.com/rollup/rollup/issues/3228, https://github.com/rollup/rollup/issues/2963
We don't really have a solution for this here, nor does there seem to be one upstream. Using eval
is something that should be avoided whenever possible anyways.
Closing this out as there's nothing actionable for us here to my knowledge.
很多变量,定义后需要动态调用,但是打包的时候直接把变量打包没了