guybedford / es-module-lexer

Low-overhead lexer dedicated to ES module parsing for fast analysis
MIT License
933 stars 48 forks source link

Syntax error reported w/ default export #138

Closed robrez closed 2 years ago

robrez commented 2 years ago

Sorry, I don't have a great, minimal reproduction example.. I depend on es-module-lexer transitively from @web/dev-server

Since 1.0.4, started receiving a syntax error for code that looks like this:

foo.js

const css = String.raw;
export default css`:host { solid 1px black }`;

bar.js

import foo from '@org/foo.js';`

@web/dev-server reports the the error as:

Error while transforming node_modules\@org/foo.js: Syntax error

  1 | const css = String.raw;
  2 | export default css`:host { solid 1px black }`;
> 3 |
    | ^

Note that if I change the code, this works:

const css = String.raw;
const blah = css`:host { solid 1px black }`;
export default blah;

My remedial action has been to pin es-module-lexer in my package.json... ^1.0.0 <=1.0.3

guybedford commented 2 years ago

Thanks for sharing the case and version, that helps a lot. Fixed in 1.0.5.