Skip to content

Should upgrade acorn's ecmascript version #7840

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

Closed
hackape opened this issue Sep 6, 2022 · 1 comment
Closed

Should upgrade acorn's ecmascript version #7840

hackape opened this issue Sep 6, 2022 · 1 comment

Comments

@hackape
Copy link
Contributor

hackape commented Sep 6, 2022

Describe the bug

Discovered when resolving a stackoverflow question.

Svelte-kit optimistically sets tsconfig.json -> compilerOptions.target = "esnext" which now become ES2022, but svelte/compiler is still using ecmaVersion: 12 aka ES2021, thus any ES2022 language feature will trigger Unexpected Token acorn error.

So it's either:

  • svelte-kit set tsconfig.json -> compilerOptions.target = "ES2021"
  • or, mod svelte/src/compiler/parse/acorn.ts
export const parse = (source: string): Node => code_red.parse(source, {
	sourceType: 'module',
	ecmaVersion: 'latest',
	locations: true
});

I haven't spent time reviewing internal of svelte/compiler module, it's unclear if updating AST to ES2022 will break things. Guess change made on svelte-kit's part is easier path for now, but in the long run ES upgrade need some attention.

Reproduction

Any component that uses latest ES2022 language feature will trigger the bug.

<script>
let name = 'world';
class Greeter {
    greeting; // class field declaration
}
</script>

<h1>Hello {name}!</h1>

Logs

No response

System Info

irrelevant

Severity

blocking an upgrade

@jasonlyu123
Copy link
Member

jasonlyu123 commented Sep 6, 2022

Duplicate of #6900, #6592. There's still AST printing needed to be implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants