feat(svelte): add compiler-backed Svelte 5 semantic extraction#2013
Open
mafifi wants to merge 4 commits into
Open
feat(svelte): add compiler-backed Svelte 5 semantic extraction#2013mafifi wants to merge 4 commits into
mafifi wants to merge 4 commits into
Conversation
Pin and bundle the Svelte compiler, svelte2tsx, and TypeScript semantic toolchain with an exhaustive schema policy, golden author-syntax corpus, deterministic notices, and Node 18 runtime contract.
Parse each compiler-owned module and instance script as an independent lexical program, retain extraction-scoped author facts, and join binding identities through the canonical JS resolver. This builds on Christian Winther's Svelte import-recovery work in upstream PR Graphify-Labs#714 and composes with the resolver foundations merged in Graphify-Labs#717.
Add synthetic adversarial fixtures for script scopes, binding identity, component and ViewModel relations, rune syntax, resolver behavior, cache ownership, incremental refresh, wheel contents, and bundle growth.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Graphify currently recovers some Svelte imports, but regex and whole-file JavaScript scanning cannot reliably preserve Svelte author semantics. In particular, a component importing a class-based
.svelte.tsViewModel can produce a phantom.sveltetarget, and template/script relationships lose binding identity and trustworthy source locations.This change adds compiler-backed Svelte 5 semantic extraction:
svelte/compilerand parsesparse(source, { modern: true })author ASTs;ast.fragmentgenerically for ESTree expressions, while handling special Svelte node semantics through a typed exhaustive schema policy and golden syntax corpus;svelte2tsxplus TypeScript only for semantic binding identity and maps all facts to original author offsets; generated TSX is never graphed;.svelte.ts/.svelte.js, real-.svelteprecedence, and symlink-normalized identities;EXTRACTED/INFERREDprovenance;The bridge requires Node >=18. Its intentionally bundled compiler/semantic toolchain is 12,441,699 bytes raw (about 2,115,201 bytes gzip); a non-brittle growth guard prevents accidental explosive expansion. The compiler schema gate, deterministic bundle build, lockfile, and third-party notices make upgrades reviewable and reproducible.
Verification
npm test: typecheck and schema corpus pass for Svelte 5.56.6 (38 template + 2 structural AST variants)git diff --check: clean95d5da5146b2a3cd14035d3f28450e4d027493ebf53f9da00d3e8b1d2349df2f9bee87a228b5fb3f03b42fc1edb4278513c318ed3edf206dfd0c3ca326ae1deeCoverage is synthetic and includes adversarial text/comment/tag lookalikes, mixed script languages, module/instance scope collisions, shadowing and aliases, all expression containers including dynamic imports, component rendering and prop flow, ViewModel construction/member access/calls, exact rune forms, canonical/symlink resolution, pruning, negative and bounded caching, incremental refresh, UTF-8 offsets, packaging, and degradation.
This builds on Christian Winther's import-recovery work in #714, which addressed #713, and composes with the TypeScript bare-path and
.svelte.ts/.svelte.jsresolver work merged in #717. Those changes are prior foundations; this PR extends the architecture beyond their original scope.