Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected character '#' , when Computed property names contain invalid javascript identifier #465

Open
icy0307 opened this issue Apr 3, 2023 · 0 comments · May be fixed by #468
Open

Comments

@icy0307
Copy link

icy0307 commented Apr 3, 2023

Please only file bugs/feature requests for rollup-plugin-closure-compiler here.

What's the issue?

Briefly describe the bug/feature request.
When Computed property names contain invalid javascript identifiers, like '#', '!',
acron parser fails because of forgetting to preserve quotation marks.

How do we reproduce the issue?

We'll likely need to know:

  1. Your Rollup configuration.
    the test fixtures:
    mixed-keys.test.js
console.log({
  ['foo#']:'value',
});
  1. Error logs from your console when invoking Rollup with this plugin present.
  Unhandled rejection in test/literal-computed-keys/mixed-keys.test.js

  /Users/icyflzhang/Documents/web/rollup-plugin-closure-compiler/node_modules/acorn/dist/acorn.js:2927

  SyntaxError: Unexpected character '#' (1:54)

  Parser.pp$4.raise (node_modules/acorn/dist/acorn.js:2927:15)
  Parser.pp$9.getTokenFromCode (node_modules/acorn/dist/acorn.js:4695:10)
  Parser.pp$9.readToken (node_modules/acorn/dist/acorn.js:4409:17)
  Parser.pp$9.nextToken (node_modules/acorn/dist/acorn.js:4400:17)
  Parser.pp$9.next (node_modules/acorn/dist/acorn.js:4357:10)
  Parser.pp$3.parseIdent (node_modules/acorn/dist/acorn.js:2880:10)
  Parser.pp$3.parsePropertyName (node_modules/acorn/dist/acorn.js:2686:107)
  Parser.pp$3.parseProperty (node_modules/acorn/dist/acorn.js:2613:10)
  Parser.pp$3.parseObj (node_modules/acorn/dist/acorn.js:2567:23)
  Parser.pp$3.parseExprAtom (node_modules/acorn/dist/acorn.js:2302:19)

If this is a feature request you can use this section to point to a prototype/mockup that will help us understand the request.

Additional context

This is because LiteralComputedKeys transformer use property.key.value, which strip off quotation marks.
Could we use property.key.raw instead when present?

icy0307 pushed a commit to icy0307/rollup-plugin-closure-compiler that referenced this issue Apr 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant