-
-
Notifications
You must be signed in to change notification settings - Fork 37
Svelte 5 implementation #140
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
base: main
Are you sure you want to change the base?
Conversation
|
Friendly ping @pascalbaljet :) |
Claude Code Review
# Code Review: Svelte 5 Implementation (PR #140)
PR: #140 OverviewThis PR adds comprehensive Svelte 5 support to the inertiaui/modal library, bringing it to parity with the existing React and Vue implementations. The implementation includes:
AnalysisStrengths1. Comprehensive Implementation
2. Modern Svelte 5 Approach
3. Accessibility
4. Documentation of Decisions
Issues & Suggestions1. Critical: State Mutation Pattern (svelte/src/lib/modalStack.svelte.js) // Current approach mentioned in PR:
stack.length = 0 // Resets stackThis is a footgun. While it works, it's non-idiomatic and could confuse developers. Consider:
2. Build System Concerns
Recommendation: Investigate Vite library mode or rollup directly for proper bundling. 3. Component Import Pattern (ModalRenderer.svelte) // Requires .default appending
component.defaultThis suggests the module resolution isn't correctly configured. Check:
4. Missing Prop Filtering
Suggestion: Implement prop filtering similar to Vue, or document this as a known limitation. 5. Race Condition with Melt UI This suggests architectural issues. Consider:
6. CI/CD Matrix Complexity
Code QualityPositive:
Concerns:
Test CoverageFrom the diff, tests cover:
Missing Tests:
Security ConsiderationsNo obvious security issues, but:
Performance ImplicationsConcerns:
Recommendations:
Breaking ChangesNone for existing React/Vue users. New Svelte implementation is additive. Documentation Needs
RecommendationsHigh Priority
Medium Priority
Low Priority
VerdictRecommendation: Request Changes This is a solid implementation that demonstrates clear understanding of Svelte 5 and the existing codebase. However, the build system concerns and architectural issues (state mutation pattern, config race conditions, import patterns) should be addressed before merging. Specific Requests:
After these changes, this PR should be ready to merge. The author has done excellent work documenting decisions and maintaining parity with existing implementations. Reviewed by: Claude Code |
|
Thanks William - since this has some attention, I'll rebase main and freshen it up since it's stale. Edit: Rebased and changes made. |
Resolves #130
I've translated the React and Vue components to Svelte 5.
Please forgive me if I've made any major mistakes or made poor decisions - I attempted to keep the implementation as similar to the Vue implementation as possible.
Here are the major notes that identify differences, nuances, and decisions made.
*.sveltefiles insrc/lib. There may be a better way to bundle, but I was unsuccessful after hours of playing with basic Svelte and Vite.aria-hiddenon app mount point, so this was added manually so tests pass. Melt UI adheres to WAI-ARIA design patterns, but settingaria-hiddenseems to be something other headless libraries doHeadlessModalin Vue, but this creates a race condition with Melt UI as it needs to knowcloseExplicitlybefore the headless modal is even mounted. This is duplication that is suggests configuration could be more centrally managed.renderAppseem to both be very different. Vue uses some hyperscript function to render theAppinside theModalRoot- hyperscript seems to allow rendering components programmatically outside of a component. I don't know of a way to do this with Svelte, so I simply rendered theAppinsideModalRootby passingAppas a prop.ModalRendererwhen passing props to the page component - there doesn't seem to be a way to infer what props a component uses in Svelte, so all props are passed to the page.ModalRendererhad to be appended with.default- seems like imports aren't being treated as ECMAScript modules from the component resolver or Svelte doesn't treat components as named exports. I believe this is outside the scope of the project unless there's some javascript configuration somewhere that changes the behaviour.$derived.byforonTopOfStack- updating to latest fixed the issue, so I'm recommending^5.36.0as the svelte version to use$statedoes not support reassignment, meaningstack = []would not trigger for components expecting reactive update. For this reason the$statevariables exported inmodalStack.svelte.jsshould never be reassigned. I.e.stack.length = 0resets the stack entirely.I'll be happy to update the documentation if this is to get adopted.