A powerful GitHub Action that helps teams migrate from Svelte 4 to Svelte 5 by analysing your codebase for deprecated patterns and providing actionable migration guidance. Get automated PR comments with detailed migration recommendations powered by static analysis and optional AI insights.
Add this to your workflow file
(.github/workflows/svelte-migration.yml
):
name: Svelte Migration Analysis
on:
pull_request:
paths:
- '**/*.svelte'
- '**/*.ts'
- '**/*.js'
jobs:
svelte-migration:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Analyse Svelte Migration
uses: spences10/svelte-migration-action@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
Important: To enable PR comments and full functionality, you need to configure your repository permissions:
Workflow Permissions (Settings → Actions → General → Workflow permissions):
Why these permissions are needed:
HttpError: Resource not accessible by integration
If you prefer more granular control, you can add explicit permissions to your workflow:
jobs:
svelte-migration:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
issues: write
steps:
# ... rest of your workflow
The action identifies common Svelte 4 patterns that need updating:
createEventDispatcher
usage → Use callback propsbeforeUpdate
/afterUpdate
lifecycle hooks → Use $effect.pre()
and $effect()
new
→ Use mount()
or hydrate()
$$props
and $$restProps
→ Use destructuring with $props()
$$slots
usage → Use snippet parameters$:
) → Replace with $derived
or $effect
export let
declarations → Replace with $props()
on:
event directives → Replace with event properties$state
for reactive variablesInput | Description | Default | Required |
---|---|---|---|
github-token |
GitHub token for API access | ${{ github.token }} |
No |
filter-changed-files |
Only analyse files changed in PR | true |
No |
fail-on-error |
Fail action if migration issues found | false |
No |
fail-on-warning |
Fail action if migration warnings found | false |
No |
paths |
Paths to search for Svelte files | src\napp\nlib |
No |
exclude-paths |
Paths to exclude from analysis | node_modules\n.git\ndist\nbuild |
No |
anthropic-api-key |
Anthropic API key for AI analysis | No | |
enable-ai-analysis |
Enable AI-powered analysis | false |
No |
Output | Description |
---|---|
issues-found |
Number of migration issues found |
warnings-found |
Number of migration warnings found |
files-analyzed |
Number of files analysed |
has-issues |
Whether any issues were found |
summary |
Summary of the analysis |
- name: Analyse Svelte Migration
uses: spences10/svelte-migration-action@v1
with:
paths: |
src/components
src/routes
lib
exclude-paths: |
node_modules
.svelte-kit
build
dist
test
- name: Analyse Svelte Migration
uses: spences10/svelte-migration-action@v1
with:
fail-on-error: true
fail-on-warning: true
- name: Analyse Svelte Migration
uses: spences10/svelte-migration-action@v1
with:
anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }}
enable-ai-analysis: true
For enhanced migration suggestions powered by Claude 4:
ANTHROPIC_API_KEY
with:
anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }}
enable-ai-analysis: true
The AI will provide:
When the action runs, it will:
# 🔄 Svelte Migration Analysis Results
## 📊 Summary
- **Files analysed:** 15
- **Issues found:** 3
- **Warnings found:** 8
## ❌ Issues (3)
These are breaking changes that must be addressed for Svelte 5:
<details>
<summary>📄 <code>src/components/Modal.svelte</code> - 1 issue</summary>
- **Line 15:** createEventDispatcher is deprecated in Svelte 5
- 💡 **Suggestion:** Use callback props instead of
createEventDispatcher
</details>
<details>
<summary>📄 <code>src/routes/+page.svelte</code> - 2 issues</summary>
- **Line 23:** beforeUpdate/afterUpdate are deprecated in Svelte 5
- 💡 **Suggestion:** Use $effect.pre() and $effect() instead
- **Line 30:** $$props and $$restProps are deprecated
- 💡 **Suggestion:** Use destructuring with rest in $props(): let {
foo, ...rest } = $props()
</details>
## ⚠️ Warnings (8)
These patterns will still work but are deprecated in Svelte 5:
<details>
<summary>📄 <code>src/components/Button.svelte</code> - 5 warnings</summary>
- **Line 5:** export let should be replaced with $props()
- 💡 **Suggestion:** Replace with: let { propName } = $props()
- **Line 10:** Reactive statement ($:) should be replaced with
$derived or $effect
- 💡 **Suggestion:** Use $derived for computed values or $effect for
side effects
- **Line 22:** on: event directives should be replaced with event
properties
- 💡 **Suggestion:** Replace on:click with onclick
</details>
<details>
<summary>📄 <code>src/components/Input.svelte</code> - 3 warnings</summary>
- **Line 8:** export let should be replaced with $props()
- 💡 **Suggestion:** Replace with: let { propName } = $props()
- **Line 15:** Named slots should be replaced with snippets
- 💡 **Suggestion:** Use {#snippet name()} and {@render name()}
instead
</details>
## 📚 Migration Resources
- [Svelte 5 Migration Guide](https://svelte.dev/docs/svelte/v5-migration-guide)
- [Automatic Migration Tool](https://svelte.dev/docs/svelte/v5-migration-guide#migration-script):
`npx sv migrate svelte-5`
- [Svelte 5 Documentation](https://svelte.dev/docs/svelte)
# Clone the repository
git clone https://github.com/spences10/svelte-migration-action.git
cd svelte-migration-action
# Install dependencies
pnpm install
# Run tests
pnpm test
# Build the action
pnpm build
# Package for distribution
pnpm package
# Run all tests
pnpm test
# Run tests with coverage
pnpm test:coverage
# Run linting
pnpm lint
# Format code
pnpm format
We welcome contributions! Please see our Contributing Guide for details.
git checkout -b feature/amazing-feature
pnpm test
git commit -m 'Add amazing feature'
git push origin feature/amazing-feature
This project is licensed under the MIT Licence - see the LICENSE file for details.
Made with ❤️ for the Svelte community
Help teams migrate to Svelte 5 with confidence! 🚀