closure-compiler icon indicating copy to clipboard operation
closure-compiler copied to clipboard

Parse error for quoted export/import names

Open LiviaMedeiros opened this issue 2 years ago • 1 comments

// e.mjs
const a = 'print me';
export { a as "dove" };
// i.mjs
import { "dove" as b } from './e.mjs';
console.log(b);

"dove" is the quoted name, and this code works (i.mjs prints print me).

Spec reference: ModuleExportName can be StringLiteral.

However, compiler can't parse that:

e.mjs:3:14: ERROR - [JSC_PARSE_ERROR] Parse error. 'identifier' expected
  3| export { a as "dove" };
                   ^
i.mjs:2:9: ERROR - [JSC_PARSE_ERROR] Parse error. '}' expected
  2| import { "dove" as b } from './e.mjs';
              ^

LiviaMedeiros avatar Jun 20 '22 20:06 LiviaMedeiros

This does appear to be a bug in the closure-compiler parser.

Since we use goog.module() / goog.require() instead of ES modules in Google, fixing this is likely to be a very low priority.

I'm labeling it as "help wanted", since it's more likely someone will create a PR to fix this than that the Google closure-compiler team will find time to do it.

brad4d avatar Jun 22 '22 20:06 brad4d