-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
More object-oriented approach to AST traversal #979
Labels
Comments
Merged
Rich-Harris
added a commit
that referenced
this issue
Dec 9, 2017
Has this been completed in #992? |
Yeah I think this has been completed in #992, closing. |
sacrosanctic
pushed a commit
to sacrosanctic/svelte
that referenced
this issue
Dec 24, 2024
* wip * Update +server.ts * Update +server.ts * wip * wip * Update +server.ts * Update +server.ts * wip * cleanup * wip * refactor * cleanupo * Update +server.ts * Update content.ts * wip * Create +server.ts * minimize llms.txt * Filter llms.txt * clean up * package * chore: naming * Update +server.ts * Dynamic path names * clean up * fix * under_score * code style * use real document titles, filter out empty files * move llms.txt to llms-small.txt * llms.txt index * Update +server.ts * Update +server.ts * Fix index * fix * revert VERCEL_URL usage * Update apps/svelte.dev/src/lib/server/content.ts Co-authored-by: Rich Harris <rich.harris@vercel.com> * move llm stuff into its own module * revert whitespace changes * snake_case * tweak * snake_case etc * make ignores work * simplify * unused * reduce indirection * more * move template into separate .md file * add a section to /docs * advent of svelte --------- Co-authored-by: Simon Holthausen <simon.holthausen@vercel.com> Co-authored-by: Rich Harris <rich.harris@vercel.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Other projects I've worked on that involve a lot of AST traversal and analysis, such as Rollup and Bublé, have converged on an approach that I quite like, whereby the (POJO) nodes of an AST are augmented so that they look and feel like instances of a class, like this example of a FunctionDeclaration node. (The augmentation happens here by setting
node.__proto__
— hold your nose if you find that sort of thing distasteful.) The result is a codebase that's a lot neater and reason-about-able than it could easily have devolved into.It occurred to me just now, while bashing my head against a wall trying to get nodes inside a dynamic component to remount to a new instance's slots, that Svelte would benefit a great deal from a similar approach. It would mean the various 'phases' of compilation were no longer spread across the codebase confusingly, and we could get rid of hacks like this. We could probably even unify the visitors for DOM and SSR compilers.
Definitely a chunky refactor, but now that I can picture it I'm really keen to give it a whirl.
The text was updated successfully, but these errors were encountered: