feat(migrate): rework migrations and initial sveltekit-3 migration#1138
Draft
manuel3108 wants to merge 89 commits into
Draft
feat(migrate): rework migrations and initial sveltekit-3 migration#1138manuel3108 wants to merge 89 commits into
sveltekit-3 migration#1138manuel3108 wants to merge 89 commits into
Conversation
🦋 Changeset detectedLatest commit: 85c1e75 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Merge the missing-package.json and missing-deps cases into one actionable message (absolute path + --cwd/--help hints), and render migration setup failures cleanly instead of dumping a stack trace.
….json Migrations don't all need a svelte/kit project (legacy ones hand off to svelte-migrate). Let each migration's setup declare its own needs; the shared check now only ensures a package.json exists. sveltekit-3 keeps the kit requirement with an actionable message.
manuel3108
commented
Jun 21, 2026
sveltekit-3 migrationsveltekit-3 migration
…en add optional. (let's see)
manuel3108
commented
Jun 26, 2026
* feat: migration-task comment management
- @migration-task comments now work in .svelte files (insert real Comment
nodes into the fragment, since the Svelte printer ignores the JS Comments
registry); fixes the env task silently dropping them.
- single addMigrationTask(message, target): { comments, node } for JS/TS,
{ fragment, anchor? } for .svelte.
- split migrate/index.ts into index.ts (framework) + migration-task.ts.
* fmt
* feat(migrate): defer formatting to project format script Migrate now runs the nearest `format`/`fmt` package.json script (walking up to the workspace root) before falling back to prettier on modified files. `formatFiles` takes a `strategy` param; create/add keep the files-only path. * fix: import order in formatFiles
* feat: migration-task comment management
- @migration-task comments now work in .svelte files (insert real Comment
nodes into the fragment, since the Svelte printer ignores the JS Comments
registry); fixes the env task silently dropping them.
- single addMigrationTask(message, target): { comments, node } for JS/TS,
{ fragment, anchor? } for .svelte.
- split migrate/index.ts into index.ts (framework) + migration-task.ts.
* fmt
* feat: reborn app-state migration (AST-based)
Rebuild `$app/stores` -> `$app/state` as a proper AST task instead of the
regex legacy shell-out. Runnable standalone (`sv migrate app-state`) and
required inside the sveltekit-3 migration.
Bug fixes over the legacy version:
- truthy `$navigating` (e.g. {#if $navigating}) -> `navigating.to`
- bail cases (`$:`, `derived(store)`, `getStores()`) now leave a @migration-task instead of silently skipping
- drop spurious TODO when `.to` is already accessed
---------
Co-authored-by: Manuel <30698007+manuel3108@users.noreply.github.com>
This was referenced Jun 27, 2026
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.
Relates #1111
Closes #1124
Description
This PR lays the groundwork for making
sv migratethe new home for Svelte migrations.It does a few things:
svelte-migrateto a new major version so it can be deprecated in favor ofsv migratesv addover the last two yearsnpx svelte-migrate@1sv addarchitectureMigration system
The new system is built around two concepts: migrations and migration tasks.
A migration is the top-level wrapper. It is similar to what we had before and will usually be added alongside a new version release, though not necessarily only for major releases.
A migration task is the actual execution unit responsible for applying part of a migration. Larger migrations can be split into multiple tasks. For example,
sveltekit-3currently consists of separate tasks forpackage.json,svelte.config.js, and environment variable changes.Tasks can be required or optional. Optional tasks can be selected or deselected by the user, which has a few important benefits:
Each task receives almost the same parameters as an addon, with only minor differences. This allows migrations to re-use addon functionality directly. For example, the
sveltekit-3migration calls theexperimentaladdon to updatepackage.jsonand the relevant peer dependencies.Multi-file migrations
To support migrations that need to edit multiple files, this PR introduces
sv.filesin addition tosv.file:Migrating
Pending work
lint checkWe decided against this for nowWe decided against this for nowsvelte-checksv.filessv migrateenv-varsmigrationFix and bumpesrapIt currently generates a lot of new lines where the previous content did not have them.This may be difficult and could potentially require a major bump foresrap.esrapas it takes theastas an argument and is unaware of the input. Therefore implemented based on a text diff library that does the job pretty goodpreserveOriginalNewlines$app/environmentto$app/envcheck migration for app-state (legacy) and see if we can use that one or if we should rewrite itShould be fine, migration was published over 1.5 years agoexpose an api for migrations, so that we can use it from the playground, vs code extension and whateverwill be implemented at a later pointChecklist