svelte
svelte copied to clipboard
Expose Svelte AST node types from `svelte/compiler` to public
Describe the problem
As per thread on Discord.
I was working on addon for Storybook - @storybook/addon-svelte-csf. It uses svelte/compiler to extract Svelte AST nodes and analyss them for further code transformation.
Then I upgraded Svelte version. And I have noticed that since this release [email protected] AST nodes from svelte/compiler are no longer exposed to public.
Such as:
Component(AST version)RootSnippetBlockSvelteNode- ... etc.
Possibly related PR: https://github.com/Rich-Harris/dts-buddy/pull/82
Describe the proposed solution
I would like to be able to access those Svelte AST nodes, so I can have a better typings experience on those AST data structures.
Importance
would make my life easier
We also need need this to get SvelteKit passing against the ecosystem CI since enhanced-img uses things like TemplateNode, BaseDirective, Attribute, and SpreadAttribute
https://github.com/sveltejs/kit/blob/43544107269013e8b5160d268da25f1e003b6f6f/packages/enhanced-img/src/preprocessor.js#L44 https://github.com/sveltejs/kit/blob/43544107269013e8b5160d268da25f1e003b6f6f/packages/enhanced-img/src/preprocessor.js#L216
If we expose them again I'd like us to make sure somehow to not expose the internal properties of the AST nodes (for example metadata)
Hey @dummdidumm, is it just the metadata that needs to be omitted from the public interfaces or is there more? Not having these types is blocking us on a couple of things, so we are willing to attempt a PR with some guidance.
I imagine the desire is to incorporate this into the build script rather than just exporting with Omit right?
Yeah metadata is basically all that needs to be removed (and if there's a parent property, then that, too).
I have no opinion at this time how it should be accomplished, as long as it's low maintenance, stable and relatively straightforward
@huntabyte there was some additional discussion in the original Discord thread FYI: https://discord.com/channels/457912077277855764/1258093339232702556