code like this is supported & executed in Node 8.3+ without problems:
module.exports = ({ foo, bar = 10 }) => {
console.log(foo, bar);
}
However if I use ESM to rewrite it into ES module form:
export default ({ foo, bar = 10 }) => {
console.log(foo, bar);
}
I get SyntaxError: Unexpected token (1:32). Removing default value for bar will solve problem, but now I lost default parameter value functionality.
Thanks @srigi!
It's a bug in our object rest/spread extension.
v0.11.0 is released :tada:
Thanks @jdalton, works like a charm.
Is there a unit test to make sure this didn't break again? It seems to have worked through 0.16.0, but is broken again in 0.17.0 馃槶
@okwolf There is a unit test. Can you provide an example of the syntax that's throwing an error?
Update:
Patched https://github.com/standard-things/esm/commit/c89e9222331fd37a8a4cffc90378b5d15875d84a and more tests https://github.com/standard-things/esm/commit/00a3f7cac59ff5e93193a83972a40f2f231217d2.
@jdalton great catch! I hadn't realized it was only an issue with multiple destructured arguments.