Closed AngusFu closed 5 years ago
This prevents me from using buble in a vue project
Removing the comment from the line of last argument makes it transform correctly
@iamareebjamal As a solution for now, just exclude vue in buble plugin/loader options, since all files in vue/dist
are pre-transpiled.
Two minimised test cases:
function x(a//
){return{b:1,c:2}}
(a//
)=>({b:1,c:2})
In each case it improperly strips the comma after b:1
, leaving b:1c:2
. Looks to affect the first object literal with more than one element in the function, if the function has at least one argument and a line comment immediately before its arguments’ closing paren.
Bumped into a similar (same?) bug in https://github.com/rollup/rollup-plugin-buble/issues/13, from where I condensed another test case:
['x'].forEach(function () { } // this comment causes the bug
);
['x', 'y', 'z'].forEach(console.log)
If the comment "this comment causes the bug" is present, the result is ['x' 'y', 'z'].forEach(console.log)
. If the comment of stripped, it works. Bublé version 0.19.6.
It looks like this bug breaks not only Vue, but also the latest version of ReactDOM (https://unpkg.com/react-dom@16/umd/react-dom.development.js).
And like I mentioned in the other issue, my workaround for this for now: strip comments before running code through buble (in my case, using the rollup plugin rollup-plugin-cleanup).
Thanks for the report! I'm pretty sure this is an issue in my src/utils/removeTrailingComma.js.
Weird bug. The following screenshot describes better than words.
BTW, I got the function from Vue dist file vue.esm.js at line 4384.