-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: deprecate
svelte:component
(#12694)
* feat: deprecate `svelte:component` Co-authored-by: Oscar Dominguez <dominguez.celada@gmail.com> * move logic into the visitor * tweak docs --------- Co-authored-by: Oscar Dominguez <dominguez.celada@gmail.com> Co-authored-by: Rich Harris <rich.harris@vercel.com>
- Loading branch information
1 parent
9a67ab1
commit cbcd761
Showing
7 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'svelte': patch | ||
--- | ||
|
||
feat: deprecate `svelte:component` |
This file contains 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
5 changes: 5 additions & 0 deletions
5
packages/svelte/src/compiler/phases/2-analyze/visitors/SvelteComponent.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,16 @@ | ||
/** @import { SvelteComponent } from '#compiler' */ | ||
/** @import { Context } from '../types' */ | ||
import * as w from '../../../warnings.js'; | ||
import { visit_component } from './shared/component.js'; | ||
|
||
/** | ||
* @param {SvelteComponent} node | ||
* @param {Context} context | ||
*/ | ||
export function SvelteComponent(node, context) { | ||
if (context.state.analysis.runes) { | ||
w.svelte_component_deprecated(node); | ||
} | ||
|
||
visit_component(node, context); | ||
} |
This file contains 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
This file contains 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
7 changes: 7 additions & 0 deletions
7
packages/svelte/tests/validator/samples/svelte-component-deprecated/input.svelte
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<svelte:options runes /> | ||
|
||
<script> | ||
import A from './A.svelte'; | ||
</script> | ||
|
||
<svelte:component this={A} /> |
14 changes: 14 additions & 0 deletions
14
packages/svelte/tests/validator/samples/svelte-component-deprecated/warnings.json
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[ | ||
{ | ||
"code": "svelte_component_deprecated", | ||
"message": "`<svelte:component>` is deprecated in runes mode — components are dynamic by default", | ||
"start": { | ||
"line": 7, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 7, | ||
"column": 29 | ||
} | ||
} | ||
] |