Looks like buble supports it, as long as you pass an option for objectAssign: 'Object.assign' but in practice it doesn't seem to be working.
My code:
import { h } from 'preact'
export default ({ title, ...rest }) => (
<div {...rest} className={`${rest.className}`} />
)
Output:
SyntaxError: Unexpected token (3:25) /some/path/page.js (nodent)
export default ({ title, ...rest }) => (
-------------------------^
The problem is in Rollup as i remember.
Try out
const opts = { input: 1, a: 2, bbbb: 3 };
const { input, ...rest } = opts;
console.log(rest);
and
rollup -i foo.js -o bar.js -f es
It still fails.
Rollup idealogy is to "add acorn plugin" for such things.
I just ran into this. One quick workaround is to transpile with babel's transform-object-rest-spread first, then run microbundle on the intermediary output, e.g. in crosslink.
Update Rollup to 0.56, it now support ecmaVersion: 9. But yea, there still need to have sup prebundling compilation for most recent javascript. _Or_ to add acorn-stage3 to rollup here.
is there a workarround in the mean time, or can we simply not use object spread with microbundle until it gets fixed upstream?
@MobiusHorizons you can pre-transform it through babel for now, e.g. https://github.com/tlvince/react-router-crosslink/blob/1ce2b6aad7f001e1dbea36ba76877ec8bbcda94e/package.json#L10-L11
And if someone want to contribute, there are few things that may be done to help.
babylon - https://github.com/babel/babel/issues/7369babylon with the ESPree plugin by default, because it needs the ESPree AST - https://github.com/rollup/rollup/issues/1690The medium-term fix would be to allow using Babel with Microbundle, triggered by the existence of a .babelrc.
@developit I've had a WIP here. Should we revive this PR until we switch to babel entirely?
Just tried it out with 0.9.0 and I can't reproduce this issue anymore with the code from the first post 馃帀
Most helpful comment
The medium-term fix would be to allow using Babel with Microbundle, triggered by the existence of a
.babelrc.