bublejs / buble

https://buble.surge.sh
MIT License
871 stars 64 forks source link

Nested spread and computed properties have wrong runtime behaviour after transpiling #163

Closed adrianheine closed 4 years ago

adrianheine commented 6 years ago

From rollup/rollup-plugin-buble#9:

function test(state, action) {
  return {
    ...state,
    [action.page]: {
      ...state[action.page],
      [action.key]: action.value
    }
  };
}

console.log(test({}, { page: "z", key: "x", value: "y" })); // => { z: { x: 'y' } }

bublé mixes up the closing parentheses like this:

function test(state, action) {
  var obj, obj$1;

  return Object.assign({}, state,
    ( obj$1 = {}, obj$1[action.page] = Object.assign({}, state[action.page],
      ( obj = {}, obj[action.key] = action.value, obj ), obj$1 )));
}

console.log(test({}, { page: "z", key: "x", value: "y" })); // => { x: 'y' }