chore: replace acorn with Vite's parseSync - #16947
Conversation
|
Install the latest version of pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/804abe81947cce5cf0338d3ecccc55aadee4c31cOpen in |
🦋 Changeset detectedLatest commit: 804abe8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
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? |
|
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. |
|
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 |
Vite 8 exports
parseSync(oxc, bundled inside rolldown) and deprecatesparseAstin its favour: https://vite.dev/guide/migration#advanced. It parses TS natively, so@sveltejs/acorn-typescriptgoes too.