feat(migrate): rework migrations and initial sveltekit-3 migration - #1138
Conversation
🦋 Changeset detectedLatest commit: 2808c15 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 |
| * For each matching file, the `edit` callback is called with the file content, | ||
| * and should return the new content (or `false` to abort editing that file). | ||
| * | ||
| * Note: always adds excludes for `node_modules` and dot-prefixed directories |
There was a problem hiding this comment.
| * Note: always adds excludes for `node_modules` and dot-prefixed directories | |
| * Note: `node_modules` and dot-prefixed directories are always excluded. |
Should this also mention build and dist? Maybe link to the source for the curious? Should there be an option to override this?
There was a problem hiding this comment.
Mhmm yeah, maybe it should. On the other hand it wouldn't cause any problems, because your next build is just going to override it. But in node_modules it could cause problems as this is sometimes treated as the source.
Co-authored-by: Scott Wu <sw@scottwu.ca>
Relevant for sveltejs/cli#1138. This is basically just an option from `esrap` that we pass through. That will allow tools like `sv migrate` to provide a guessed indent based on the other file contents and therefore allow us to produce way smaller diffs. Since we are just passing an option, there is no need for a test here. Technically a `feat:` but i dont think this is relevant enough. ### Before submitting the PR, please make sure you do the following - [x] It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs - [x] Prefix your PR title with `feat:`, `fix:`, `chore:`, or `docs:`. - [x] This message body should clearly illustrate what problems it solves. - [ ] Ideally, include a test that fails without this PR but passes with it. - [x] If this PR changes code within `packages/svelte/src`, add a changeset (`npx changeset`). ### Tests and linting - [x] Run the tests with `pnpm test` and lint the project with `pnpm lint`
|
Updated to latest svelte. |
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