-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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 self-closing-tags migration #12128
Conversation
Companion to sveltejs/svelte#11114. This adds an npx svelte-migrate self-closing-tags migration that replaces all the self-closing non-void elements in your .svelte files.
🦋 Changeset detectedLatest commit: 4a5b9ec The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
'<svelte:options namespace="foreign" /><foo />': '<svelte:options namespace="foreign" /><foo />', | ||
'<script>console.log("<div />")</script>': '<script>console.log("<div />")</script>', | ||
'<script lang="ts">let a: string = ""</script><div />': | ||
'<script lang="ts">let a: string = ""</script><div></div>' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ideally this would work on Svelte 5 codebases too (which means having svelte@next
as a dependency, and using walk from either estree-walker
or zimmerframe
instead of svelte/compiler
)
'<script lang="ts">let a: string = ""</script><div></div>' | |
'<script lang="ts">let a: string = ""</script><div></div>', | |
'{#snippet foo()}<div />{/snippet}': '{#snippet foo()}<div></div>{/snippet}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should work in Svelte 5 code bases, too, because when you do npx ..
aren't you storing the whole dependenies in a isolated folder somewhere on your computer? If not then yes we can switch to zimmerframe.
Oh wait I see what you mean. Mhhhhm how does npx
work in general in these situations? Can it pick up dependencies from the environment it's run in? If so then we can do await import('svelte')
and use that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the local Svelte installation now, tested it successfully on the Svelte 5 repo
Companion to sveltejs/svelte#11114. This adds an npx svelte-migrate self-closing-tags migration that replaces all the self-closing non-void elements in your .svelte files.
Alternative to #12102 with the following adjustments:
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpm changeset
and following the prompts. Changesets that add features should beminor
and those that fix bugs should bepatch
. Please prefix changeset messages withfeat:
,fix:
, orchore:
.Edits