Skip to content

chore: replace acorn with Vite's parseSync - #16947

Merged
Rich-Harris merged 2 commits into
version-3from
replace-acorn-with-vite-parse
Aug 27, 2026
Merged

chore: replace acorn with Vite's parseSync#16947
Rich-Harris merged 2 commits into
version-3from
replace-acorn-with-vite-parse

Conversation

@Nic-Polumeyv

@Nic-Polumeyv Nic-Polumeyv commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Vite 8 exports parseSync (oxc, bundled inside rolldown) and deprecates parseAst in its favour: https://vite.dev/guide/migration#advanced. It parses TS natively, so @sveltejs/acorn-typescript goes too.

@pkg-svelte-dev

pkg-svelte-dev Bot commented Aug 26, 2026

Copy link
Copy Markdown

Install the latest version of @sveltejs/kit from 804abe8:

pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/804abe81947cce5cf0338d3ecccc55aadee4c31c

Open in pkg.svelte.dev: https://pkg.svelte.dev/repos/kit/pr/16947

@changeset-bot

changeset-bot Bot commented Aug 26, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 804abe8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@svelte-docs-bot

Copy link
Copy Markdown

@Conduitry

Copy link
Copy Markdown
Member

Given that Svelte itself will still be using Acorn and this plugin, we won't actually be dropping any dependencies. What are the tradeoffs with aligning with Vite rather than the Svelte compiler?

@Nic-Polumeyv

Copy link
Copy Markdown
Contributor Author

Good point. The way I see it, the two packages use acorn for different jobs. Svelte's compiler is built on the acorn AST end to end, while kit only reads top-level export declarations from page modules and built chunks, which look identical in both ASTs. So there's no compiler code for kit to stay aligned with; kit's parsing is a build-step concern, and the build tool already ships a parser. That lets kit stop declaring its own acorn pair, which I think is also what broke the later reporters in #13809. oxc is marginally faster on top, though that's not my main argument.

@Rich-Harris

Copy link
Copy Markdown
Member

In favour of this even though the two dependencies will still exist in everyone's tree, since it would result in a dropped dep in either a hypothetical future in which everyone is using rsvelte, or one in which there's some preferred alternative to Acorn to use within Svelte. The speed boost is a nice bonus

@Rich-Harris
Rich-Harris merged commit aa4f960 into version-3 Aug 27, 2026
40 checks passed
@Rich-Harris
Rich-Harris deleted the replace-acorn-with-vite-parse branch August 27, 2026 20:56
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

Successfully merging this pull request may close these issues.

3 participants