!((
input,
processed = {
foo: 1,
...input
}
) => {
window.console.log(processed)
})({
bar: 2 // input configuration
})被缩小为:
((t, e = {
foo: 1,
bar: 2
}) => {
window.console.log(e);
})();为了以后的配置,我需要那个input参数
问题:如何维护原始模式?
我需要的输出:
((t, e = {
foo: 1,
...t
}) => {
window.console.log(e);
})({bar: 2});评论后的最新情况:
let input1 = { bar:2 }
!((
input,
processed = {
foo: 1,
...input
}
) => {
window.console.log(processed)
})( input1 )产出:
((t, e = {
foo: 1,
...t
}) => {
window.console.log(e);
})({
bar: 2
});发布于 2020-03-12 11:29:11
Terser将负责当前版本的代码。现在,您将一个常量参数传递给一个函数,因此terser只需内联它就可以阻止中间对象的创建。
如果将来您在函数内部(对于原语值)或在函数外部(对于对象)更改此参数,则terser应该识别该参数,而不再是内联的。
令人惊讶的是,已经将参数声明为变量似乎给了terser适当的提示,OP发现了这一点:
let input1 = { bar:2 }
!((
input,
processed = {
foo: 1,
...input
}
) => {
window.console.log(processed)
})( input1 )会导致
((t, e = {
foo: 1,
...t
}) => {
window.console.log(e);
})({
bar: 2
});https://stackoverflow.com/questions/60651211
复制相似问题