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

Expose Svelte AST node types from svelte/compiler to public #12292

Open
xeho91 opened this issue Jul 4, 2024 · 5 comments
Open

Expose Svelte AST node types from svelte/compiler to public #12292

xeho91 opened this issue Jul 4, 2024 · 5 comments
Milestone

Comments

@xeho91
Copy link
Contributor

xeho91 commented Jul 4, 2024

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)
  • Root
  • SnippetBlock
  • SvelteNode
  • ... etc.

Possibly related PR: Rich-Harris/dts-buddy#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

@xeho91 xeho91 changed the title Expose Svelte AST node types from svelte/compiler Expose Svelte AST node types from svelte/compiler to public Jul 4, 2024
@benmccann benmccann added this to the 5.0 milestone Jul 4, 2024
@benmccann
Copy link
Member

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

@dummdidumm
Copy link
Member

dummdidumm commented Jul 6, 2024

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)

@huntabyte
Copy link
Member

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?

@dummdidumm
Copy link
Member

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

@vnphanquang
Copy link

@huntabyte there was some additional discussion in the original Discord thread FYI: https://discord.com/channels/457912077277855764/1258093339232702556

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

5 participants