bublejs / buble

https://buble.surge.sh
MIT License
870 stars 67 forks source link

Tagged template literal breaks arrow function #190

Closed lettertwo closed 5 years ago

lettertwo commented 5 years ago

…or maybe arrow function transform breaks tagged template literal?

Example:

const src = "() => tagged`template literal`";

const { code } = transform(src, {
  transforms: { dangerousTaggedTemplateString: true }
});

eval(code);

Expected: code is valid javascript and can eval without error.

Actual: code errors on eval: 'Unexpected identifier`.

See repro on code sandbox

adrianheine commented 5 years ago

Nice catch! Apparently this issue is specific to having an input start with an arrow function expression (or some other syntax element whose start is modified) and include a tagged template expression.