Using:
"babel-cli": "^6.18.0",
"babel-plugin-transform-react-jsx": "^6.8.0",
"babel-preset-babili": "0.0.9",
Node 6.2.0
const min = babel.transform(data, {
presets: ['babel-preset-babili'],
plugins: ['transform-react-jsx'],
compact: true,
comments: false
});
The following code:
if (parts.includes(PATH_DELIMETERS.get('user'))) {
({state, parts, error} = this._parseUser(parts, state));
if (error !== null) {
error = `cannot parse the User path: ${error}`;
return {error, state};
}
}
gets converted to the following. You'll notice that both parts and error are j.
if (j.includes(PATH_DELIMETERS.get('user')) && (( { state : h , parts : j , error : j } = this._parseUser(j, h)),
null !== g))
return g = `cannot parse the User path: ${g}`,
{
error: g,
state: h
};
Removing the object destructuring corrects the problem.
if (parts.includes(PATH_DELIMETERS.get('user'))) {
let parsed = this._parseUser(parts, state);
state = parsed.state;
parts = parsed.parts;
error = parsed.error;
if (error !== null) {
error = `cannot parse the User path: ${error}`;
return {error, state};
}
}
if (j.includes(PATH_DELIMETERS.get('user'))) {
let n = this._parseUser(j, h);
if (h = n.state,
j = n.parts,
g = n.error,
null !== g)
return g = `cannot parse the User path: ${g}`,
{
error: g,
state: h
}
}
This has also happened in other places in the script where there was destructuring.
Interesting. A mangler bug. I'll take a look.
Snippet reproducing the error -
function a() {
let foo, bar, baz;
({foo, bar, baz} = {});
return {foo, bar, baz};
}
output:
function a(){
let b,c,d;
return({ foo: d, bar: c, baz: d } = {}), { foo: b, bar: c, baz: d };
}
Most helpful comment
Interesting. A mangler bug. I'll take a look.
Snippet reproducing the error -
output: