-
I have a rather unusual question. I try to build a "plugin" for Svelte, where I want to hook into the compile pipeline of Svelte. My use case is that I want to transform a bit of the HTML in the The problem is that I have to get the AST of the source code, but neither the AST parser of the My question is if there is any way to hook into the compile pipeline of SvelteKit, after TypeScript has transformed to JavaScript, but before anything is turned into the final JavaScript. Alternatively, I would need a way to get the AST of the Source Code even though TypeScript is present. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Take a Look at how https://github.com/svelte-add/svelte-add/blob/main/projects/svelte-add/package.json uses estree-walker for ast mainpulation |
Beta Was this translation helpful? Give feedback.
-
I now use |
Beta Was this translation helpful? Give feedback.
I now use
htmlparser2
for parsing the HTML and@typescript-eslint/typescript-estree
for parsing the TypeScript. And thendom-serializer
to serialize the modified DOM back to HTML. For my use-case this works fine.