Closed scarletsky closed 3 years ago
@scarletsky 这个情况倒是的确没想到...
数组的问题已经修复了,补丁对应版本为1.1.4。
关于这个concat
的问题,其实直接用map就行了:
https://github.com/afterwind-io/preprocessor-loader/blob/40b3e132daf4c17b8dd4d932c08ffef5346ed120/src/filter.ts#L109
@afterwind-io 哈哈,map 也可以。我也是刚好碰到打包出现异常的时候才留意到这个问题。
Currently the if directive is implemented by the following function:
v.concat
may cause wrong result if the value type is Array. Just a little snippet:keys
is["a", "b"]
values
is[1, 0, 2, 3]
(new Function(...keys, 'return b;'))(...values)
will return0
, and this is an unexpected result.A more robust way is to use
push
instead ofconcat
.