Skip to content
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

feat: add Svelte 4 migration #9729

Merged
merged 7 commits into from
May 30, 2023
Merged

feat: add Svelte 4 migration #9729

merged 7 commits into from
May 30, 2023

Conversation

dummdidumm
Copy link
Member

WIP, depending on what else we can migrate

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • 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
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

@changeset-bot
Copy link

changeset-bot bot commented Apr 20, 2023

🦋 Changeset detected

Latest commit: a134b95

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
svelte-migrate Minor

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

@benmccann
Copy link
Member

looks like the pnpm-lock.yaml will need to be updated

if we find svelte in peerDependencies, we probably want to add || ^4.0.0

@dummdidumm
Copy link
Member Author

if we find svelte in peerDependencies, we probably want to add || ^4.0.0

This is purely about the migrate package for now, we should do the compatibility thing once we're sure that actually works. Can I has approval pleez? 😄

Copy link
Member

@benmccann benmccann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is purely about the migrate package for now

Yeah. I'm suggesting lots of projects (i.e. libraries) have peerDependencies, which will need to be updated and we should probably handle that for them

* @param {string} code
*/
function update_transitions(code) {
return code.replace(/(\s)(transition:|in:|out:)(\w+)(?=[\s>=])/g, '$1$2$3|global');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

per dominik's suggestion on Discord: this might be tedious to undo and most people probably won't want |global even if that's the same behavior as svelte 3. maybe either remove it or make it an option

for (const file of files) {
if (extensions.some((ext) => file.endsWith(ext))) {
if (svelte_extensions.some((ext) => file.endsWith(ext))) {
update_svelte_file(file);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this would break with mdsvex .svx , safer to only do .svelte by default and maybe ask the user for other extensions that contain svelte code that is compatible with the basic regex used in update_svelte_file

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I commented that out because I think it's going to do more harm than good since .svx is probably the most common usage of it

@dominikg
Copy link
Member

Is there a separate documentation that explains to the user which code mods are being done, possibly with examples referencing the breaking changes that made them needed? I understand this is a pretty basic tool, but at the same time we are going to have a larger use for this with svelte-5, and it is going to be used by a lot more people than the sveltekit migrations.

So some attention to UX would go a long way to avoid getting clogged with questions about it

@dummdidumm
Copy link
Member Author

In my opinion that should be part of the migration docs we need to write. "These are the breaking changes, the following are migrated automatically, here's some examples (links to PRs for more details" - sth like that

@benmccann
Copy link
Member

we could potentially add docs on svelte.dev. @PuruVJ made a placeholder page for it: https://svelte-dev-2-75m8guw4t-svelte.vercel.app/docs/migrating-v3-to-v4

we're aiming to try launching the site at the same time as svelte 4. we could flesh out that page a bit if folks think it's a good idea and a good place to host it

@benmccann
Copy link
Member

I noticed this package uses promps and create-svelte uses @clack/prompts

@benmccann benmccann merged commit 8299da1 into master May 30, 2023
@benmccann benmccann deleted the svelte-4-migration branch May 30, 2023 19:02
@github-actions github-actions bot mentioned this pull request May 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants