sv migrate - Svelte Migration Tool: AI-Optimized Technical Reference
Overview
Official Svelte CLI tool that automates migration between major Svelte versions. Handles ~80% of mechanical upgrades automatically but requires manual intervention for complex patterns.
Critical Capabilities & Limitations
What sv migrate Successfully Handles
- Basic state conversion:
let count = 0
→let count = $state(0)
- Reactive statements:
$: doubled = count * 2
→let doubled = $derived(count * 2)
- Props patterns:
export let name
→ destructured$props()
- Event handlers:
on:click
→onclick
- SvelteKit routing updates: API pattern migrations for SvelteKit 2
- Legacy cleanup: Svelte 3/4 deprecated patterns
Critical Failure Points
- Complex reactive patterns: Multiple dependent
$:
statements - Custom stores: Intricate reactivity patterns with lifecycle dependencies
- Third-party library integration: Component libraries depending on Svelte 4 internals
- Edge cases: Custom event dispatchers, slot manipulation, dynamic component patterns
- Undocumented Svelte internals: Direct DOM manipulation, programmatic component creation
Resource Requirements & Timelines
Project Size vs Migration Time
Project Size | Tool Runtime | Total Debug Time | Complexity Factor |
---|---|---|---|
Small (10-20 components) | 30 seconds | 1 hour | Simple patterns only |
Medium (50 components) | 2-3 minutes | Half-day | 10-15 @migration comments |
Large (100+ components) | 5-10 minutes | 2-3 days | Custom stores, complex patterns |
Prerequisites (Critical)
- Node.js 16+ (version tolerance high)
- Clean git state - Tool can corrupt files on weird syntax
- Passing tests - Baseline functionality verification
- Component library compatibility check - Most break initially
Implementation Workflow
Pre-Migration Safety Protocol
git add . && git commit -m "Before migration - backup point"
git checkout -b svelte-5-migration
git status # Must be clean
Core Commands
# Interactive picker
npx sv migrate
# Direct Svelte 5 migration
npx sv migrate svelte-5
# Find manual work locations
grep -r "@migration" src/
Post-Migration Debugging Process
- Dependency resolution:
npm install
(often breaks) - Manual fixes: Address
@migration
comments - Test suite:
npm test
(component behavior changes) - Manual testing: Forms, state flows, component communication
Critical Warnings & Failure Modes
Dependency Hell Indicators
npm ERR! peer dep missing
- Library requires Svelte 4- Build failures from TypeScript config incompatibility
- Test failures from testing library rune incompatibility
Common Breaking Patterns
- Custom stores with lifecycle dependencies
- Dynamic component patterns:
<svelte:component this={component}>
- Multiple interdependent reactive statements
- Build tool incompatibility: Custom preprocessors, webpack configs
Rollback Strategies
# Nuclear option - complete revert
git checkout . && git clean -fd
# Selective revert
git checkout HEAD -- src/components/broken-component.svelte
Testing & Validation Requirements
Immediate Testing Protocol
- Test suite execution: Component behavior changes likely
- Manual testing checklist: Forms (two-way binding), state flows, component communication
- Browser console: Deprecation warnings expected
- Performance verification: Not automatically better despite claims
Common Test Failures
- Tests depending on specific DOM structure (runes change rendering)
- Component internal/lifecycle behavior tests
- Component store or complex reactive pattern tests
Compatibility & Library Support
Library Categories by Risk Level
- High Risk: Older UI component libraries, custom animation libraries
- Medium Risk: Libraries with deep Svelte integration
- Low Risk: Basic stores (writable, readable, derived)
TypeScript Integration
- Usually compatible with stricter type checking
- May reveal previously hidden type errors
- Component types change from class-based to function-based
Decision Support Information
When to Use sv migrate
- Projects with standard Svelte patterns
- When manual migration time exceeds debugging time
- As starting point for complex projects (not complete solution)
Alternative Approaches
- VS Code "Migrate Component" command: Safer for complex components
- Svelte Playground migrate button: Testing individual patterns
- Manual migration: Complex patterns requiring full control
Operational Intelligence
Hidden Costs
- Library replacement time: Popular libraries may lack Svelte 5 support
- Team learning curve: New rune patterns require training
- Performance regression debugging: Optimization patterns may change behavior
Success Indicators
- Clean migration with <5 @migration comments
- All tests pass after basic fixes
- No library compatibility issues
- Performance maintains or improves
Failure Recovery
- Phased approach: Migrate components incrementally
- Branch-based migration: Test before merging
- Component-by-component validation: Isolate problems
Resource Links (Operational)
- Migration Issues: github.com/sveltejs/svelte/discussions/13705
- Real experiences: dev.to migration articles with timelines
- VS Code extension: "Migrate Component" for individual files
- Svelte Discord: #svelte-5 channel for specific problems
- Playground testing: svelte.dev/playground migrate feature
Key Takeaway
sv migrate handles mechanical conversion well but complex applications require significant manual work. Treat as starting point (80% automation) with planned debugging phase (20% manual). Success depends on project complexity, not just size.
Useful Links for Further Investigation
Useful Resources (Where to Get Help When Shit Breaks)
Link | Description |
---|---|
sv migrate Command Reference | Official docs on command options. Decent but incomplete. |
Svelte 5 Migration Guide | Manual migration patterns. You'll need this for complex stuff the tool can't handle. |
Svelte 5 Runes Documentation | Essential reading to understand what your migrated code is trying to do. |
Svelte Discord | Join the #svelte-5 channel. Much better than Stack Overflow for migration issues. |
Migration Issues & Discussions | Where people post their actual migration failures and fixes. |
Svelte CLI Repository | File bugs here when the migration tool fucks up your code. |
Svelte Playground | Has a migrate button for testing individual component patterns. Way better than debugging entire apps. |
VS Code Svelte Extension | "Migrate Component" command works on single files. Safer than CLI for complex components. |
Migration Experience Reports | Real migration stories from people who actually shipped. Read these before starting. |
Library Compatibility Tracker | SvelteKit-specific compatibility tracking. Often more up-to-date than general discussions. |
Dev.to Migration Articles | Real-world migration experiences with actual timelines and gotchas. |
svelte-migrate Package Source | Look at the actual transformation code when the tool does something weird. |
Svelte DevTools | Browser extension for debugging runes behavior after migration. |
Svelte 5 Release Post | Context on why this migration is necessary. |
Svelte CLI Introduction | Background on the tooling ecosystem. |
Related Tools & Recommendations
Vite + React 19 + TypeScript + ESLint 9: Actually Fast Development (When It Works)
Skip the 30-second Webpack wait times - This setup boots in about a second
Vite Performance Optimization - When Your Build Speed Goes to Shit
for devs whose vite setup is now slower than a windows 95 bootup
Vite vs Webpack vs Turbopack vs esbuild vs Rollup - Which Build Tool Won't Make You Hate Life
I've wasted too much time configuring build tools so you don't have to
SvelteKit + TypeScript + Tailwind: What I Learned Building 3 Production Apps
The stack that actually doesn't make you want to throw your laptop out the window
ESLint + Prettier Setup Review - The Hard Truth About JavaScript's Golden Couple
After 7 years of dominance, the cracks are showing
Selenium nervt wie sau, aber weißt du was noch mehr nervt?
Migration auf Playwright: sollte 2 Wochen dauern, waren dann 8 Monate. Typisch halt.
Playwright - Fast and Reliable End-to-End Testing
Cross-browser testing with one API that actually works
Playwright vs Cypress - Which One Won't Drive You Insane?
I've used both on production apps. Here's what actually matters when your tests are failing at 3am.
Storybook - Build Components Without Your App's Bullshit
The tool most frontend teams end up using for building components in isolation
Deploying Deno Fresh + TypeScript + Supabase to Production
How to ship this stack without losing your sanity (or taking down prod)
TypeScript setup that actually works
Set up TypeScript without spending your entire weekend debugging compiler errors
sv migrate - When Your Migration Goes Sideways
Facing sv migrate issues? This guide provides a systematic debugging workflow, common broken patterns, and solutions to fix your app after a failed migration.
SvelteKit at Scale: Where the Dreams Die
Discover the critical challenges of SvelteKit enterprise deployment, from performance bottlenecks with thousands of components to team scalability and framework
  VS Code Dev Containers + Docker + Kubernetes Integration
Skip the "Works on My Machine" Bullshit
VS Code 中国安装配置指南 - 解决网络问题的实用指南
专为中国开发者优化的安装和配置方案,解决常见的网络、下载和中文化问题
VS Code vs Cursor - どっちが本当に使えるのか?
3ヶ月使い倒した結論:AIエディタ戦争の現実
ESLint - Find and Fix Problems in Your JavaScript Code
The pluggable linting utility for JavaScript and JSX
Fix Prettier Plugin Conflicts - The Debugging Guide That Actually Works
When your Prettier plugins hate each other more than your ex-coworkers
Prettier - Opinionated Code Formatter
integrates with Prettier
Drizzle Kit - SQL Migration CLI That Actually Works
Tired of migrations breaking your deployments? Drizzle Kit is the CLI companion to Drizzle ORM that generates readable SQL migrations automatically, handles sch
Recommendations combine user behavior, content similarity, research intelligence, and SEO optimization