diff --git a/.changeset/afraid-moose-matter.md b/.changeset/afraid-moose-matter.md new file mode 100644 index 000000000000..d6be9c8546f7 --- /dev/null +++ b/.changeset/afraid-moose-matter.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: tweak script/style tag parsing/preprocessing logic diff --git a/.changeset/brave-walls-destroy.md b/.changeset/brave-walls-destroy.md new file mode 100644 index 000000000000..86737de23f1b --- /dev/null +++ b/.changeset/brave-walls-destroy.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +chore: use internal `get_descriptors` helper diff --git a/.changeset/brown-spoons-boil.md b/.changeset/brown-spoons-boil.md new file mode 100644 index 000000000000..ba681e7d0547 --- /dev/null +++ b/.changeset/brown-spoons-boil.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +revert: address bug in before/after update diff --git a/.changeset/chatty-taxis-juggle.md b/.changeset/chatty-taxis-juggle.md new file mode 100644 index 000000000000..34eb8bc9a964 --- /dev/null +++ b/.changeset/chatty-taxis-juggle.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: delegate events on elements with bind-this diff --git a/.changeset/chilled-pumas-invite.md b/.changeset/chilled-pumas-invite.md new file mode 100644 index 000000000000..943f2d4836d8 --- /dev/null +++ b/.changeset/chilled-pumas-invite.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: apply keyed validation only for keyed each diff --git a/.changeset/chilly-dolphins-lick.md b/.changeset/chilly-dolphins-lick.md new file mode 100644 index 000000000000..1941f0a6a0e6 --- /dev/null +++ b/.changeset/chilly-dolphins-lick.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +chore: remove selector api diff --git a/.changeset/clean-eels-beg.md b/.changeset/clean-eels-beg.md new file mode 100644 index 000000000000..2cf079196c74 --- /dev/null +++ b/.changeset/clean-eels-beg.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: emit useful error on invalid binding to derived state diff --git a/.changeset/cold-birds-own.md b/.changeset/cold-birds-own.md new file mode 100644 index 000000000000..043f64b0287d --- /dev/null +++ b/.changeset/cold-birds-own.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +chore: add inline new class warning diff --git a/.changeset/config.json b/.changeset/config.json index 8402de2313dd..b56077a9220c 100644 --- a/.changeset/config.json +++ b/.changeset/config.json @@ -1,11 +1,11 @@ { - "$schema": "https://unpkg.com/@changesets/config@2.3.0/schema.json", - "changelog": ["@svitejs/changesets-changelog-github-compact", { "repo": "sveltejs/svelte" }], - "commit": false, - "fixed": [], - "linked": [], - "access": "public", - "baseBranch": "master", - "bumpVersionsWithWorkspaceProtocolOnly": true, - "ignore": ["!(@sveltejs/*|svelte)"] + "$schema": "https://unpkg.com/@changesets/config@2.3.0/schema.json", + "changelog": ["@svitejs/changesets-changelog-github-compact", { "repo": "sveltejs/svelte" }], + "commit": false, + "fixed": [], + "linked": [], + "access": "public", + "baseBranch": "main", + "bumpVersionsWithWorkspaceProtocolOnly": true, + "ignore": ["!(@sveltejs/*|svelte)"] } diff --git a/.changeset/cuddly-pianos-drop.md b/.changeset/cuddly-pianos-drop.md new file mode 100644 index 000000000000..7993ba6289b9 --- /dev/null +++ b/.changeset/cuddly-pianos-drop.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +chore: improve bundle code size diff --git a/.changeset/curly-lizards-dream.md b/.changeset/curly-lizards-dream.md new file mode 100644 index 000000000000..1f7d32f4846c --- /dev/null +++ b/.changeset/curly-lizards-dream.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: coerce attribute value to string before comparison diff --git a/.changeset/dirty-garlics-design.md b/.changeset/dirty-garlics-design.md new file mode 100644 index 000000000000..525160b762fb --- /dev/null +++ b/.changeset/dirty-garlics-design.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +feat: add type of `$effect.active` diff --git a/.changeset/dirty-tips-add.md b/.changeset/dirty-tips-add.md new file mode 100644 index 000000000000..305dbd1b16f4 --- /dev/null +++ b/.changeset/dirty-tips-add.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: correct bind this multiple bindings diff --git a/.changeset/early-ads-tie.md b/.changeset/early-ads-tie.md new file mode 100644 index 000000000000..ee885795ccca --- /dev/null +++ b/.changeset/early-ads-tie.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +chore: rename internal object properties diff --git a/.changeset/eight-steaks-shout.md b/.changeset/eight-steaks-shout.md new file mode 100644 index 000000000000..62dbebafafe4 --- /dev/null +++ b/.changeset/eight-steaks-shout.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: correct update_block index type diff --git a/.changeset/eighty-bikes-camp.md b/.changeset/eighty-bikes-camp.md new file mode 100644 index 000000000000..273e6ad9968e --- /dev/null +++ b/.changeset/eighty-bikes-camp.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: handle private fields in `class` in `.svelte.js` files diff --git a/.changeset/fair-crabs-check.md b/.changeset/fair-crabs-check.md new file mode 100644 index 000000000000..fa51ebf2d58a --- /dev/null +++ b/.changeset/fair-crabs-check.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: prevent false positives when detecting runes mode diff --git a/.changeset/famous-knives-sneeze.md b/.changeset/famous-knives-sneeze.md new file mode 100644 index 000000000000..9c7dcb42d37f --- /dev/null +++ b/.changeset/famous-knives-sneeze.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: ensure implicit children snippet renders correctly diff --git a/.changeset/few-mugs-fail.md b/.changeset/few-mugs-fail.md new file mode 100644 index 000000000000..b3a4a611e004 --- /dev/null +++ b/.changeset/few-mugs-fail.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +chore: reuse common templates diff --git a/.changeset/fifty-steaks-float.md b/.changeset/fifty-steaks-float.md new file mode 100644 index 000000000000..b100f215bed8 --- /dev/null +++ b/.changeset/fifty-steaks-float.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: address unowned propagation signal issue diff --git a/.changeset/flat-melons-protect.md b/.changeset/flat-melons-protect.md new file mode 100644 index 000000000000..43a8c45754d8 --- /dev/null +++ b/.changeset/flat-melons-protect.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: ensure `$$slots` exists in runes mode diff --git a/.changeset/forty-comics-invent.md b/.changeset/forty-comics-invent.md new file mode 100644 index 000000000000..e507f3621d5d --- /dev/null +++ b/.changeset/forty-comics-invent.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: handle undefined bubble events diff --git a/.changeset/fresh-weeks-trade.md b/.changeset/fresh-weeks-trade.md new file mode 100644 index 000000000000..224db4c8960e --- /dev/null +++ b/.changeset/fresh-weeks-trade.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +chore: make operations lazy diff --git a/.changeset/friendly-lies-camp.md b/.changeset/friendly-lies-camp.md new file mode 100644 index 000000000000..fe889998686c --- /dev/null +++ b/.changeset/friendly-lies-camp.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +feat: warn on references to mutated non-state in template diff --git a/.changeset/funny-wombats-argue.md b/.changeset/funny-wombats-argue.md new file mode 100644 index 000000000000..2d5a707a170a --- /dev/null +++ b/.changeset/funny-wombats-argue.md @@ -0,0 +1,5 @@ +--- +"svelte": patch +--- + +fix: allow svelte:self in snippets diff --git a/.changeset/gentle-sheep-hug.md b/.changeset/gentle-sheep-hug.md new file mode 100644 index 000000000000..a2a852449c3c --- /dev/null +++ b/.changeset/gentle-sheep-hug.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +chore: more validation errors diff --git a/.changeset/good-pianos-jump.md b/.changeset/good-pianos-jump.md new file mode 100644 index 000000000000..0ae35e5937da --- /dev/null +++ b/.changeset/good-pianos-jump.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: check that snippet is not rendered as a component diff --git a/.changeset/great-icons-retire.md b/.changeset/great-icons-retire.md new file mode 100644 index 000000000000..53b789db25ee --- /dev/null +++ b/.changeset/great-icons-retire.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: allow `bind:this` with dynamic type on inputs diff --git a/.changeset/green-eggs-approve.md b/.changeset/green-eggs-approve.md new file mode 100644 index 000000000000..90c7ec357e46 --- /dev/null +++ b/.changeset/green-eggs-approve.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: adjust mount and createRoot types diff --git a/.changeset/green-hounds-play.md b/.changeset/green-hounds-play.md new file mode 100644 index 000000000000..6a2922d0d519 --- /dev/null +++ b/.changeset/green-hounds-play.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: deconflict generated names against globals diff --git a/.changeset/honest-icons-change.md b/.changeset/honest-icons-change.md new file mode 100644 index 000000000000..6791a930d5a6 --- /dev/null +++ b/.changeset/honest-icons-change.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +patch: ensure keyed each block fallback to indexed each block diff --git a/.changeset/hungry-dots-fry.md b/.changeset/hungry-dots-fry.md new file mode 100644 index 000000000000..5c2328f6f92c --- /dev/null +++ b/.changeset/hungry-dots-fry.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +chore: more signal perf tuning diff --git a/.changeset/hungry-tips-unite.md b/.changeset/hungry-tips-unite.md new file mode 100644 index 000000000000..b138fd409d53 --- /dev/null +++ b/.changeset/hungry-tips-unite.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: port over props that were set prior to initialization diff --git a/.changeset/itchy-lions-wash.md b/.changeset/itchy-lions-wash.md new file mode 100644 index 000000000000..fdd9085d5ec4 --- /dev/null +++ b/.changeset/itchy-lions-wash.md @@ -0,0 +1,5 @@ +--- +"svelte": patch +--- + +fix: allow member access on directives diff --git a/.changeset/khaki-mails-draw.md b/.changeset/khaki-mails-draw.md new file mode 100644 index 000000000000..cebc5770f4e4 --- /dev/null +++ b/.changeset/khaki-mails-draw.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: tighten up signals implementation diff --git a/.changeset/kind-deers-lay.md b/.changeset/kind-deers-lay.md new file mode 100644 index 000000000000..fad265dd44a6 --- /dev/null +++ b/.changeset/kind-deers-lay.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +chore: more transition code-golfing diff --git a/.changeset/kind-eagles-join.md b/.changeset/kind-eagles-join.md new file mode 100644 index 000000000000..827511c3009f --- /dev/null +++ b/.changeset/kind-eagles-join.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: add children to element typings diff --git a/.changeset/large-clouds-carry.md b/.changeset/large-clouds-carry.md new file mode 100644 index 000000000000..f9738794f862 --- /dev/null +++ b/.changeset/large-clouds-carry.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +feat: $inspect rune diff --git a/.changeset/lazy-spiders-think.md b/.changeset/lazy-spiders-think.md new file mode 100644 index 000000000000..a0e130fc9c7c --- /dev/null +++ b/.changeset/lazy-spiders-think.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: handle dynamic selects with falsy select values diff --git a/.changeset/lemon-geese-drum.md b/.changeset/lemon-geese-drum.md new file mode 100644 index 000000000000..b830138372b1 --- /dev/null +++ b/.changeset/lemon-geese-drum.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: improve `$inspect` type definition diff --git a/.changeset/light-pens-watch.md b/.changeset/light-pens-watch.md new file mode 100644 index 000000000000..62debd2eb4c3 --- /dev/null +++ b/.changeset/light-pens-watch.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: prevent reactive snippet from reinitializing unnecessarily diff --git a/.changeset/long-crews-return.md b/.changeset/long-crews-return.md new file mode 100644 index 000000000000..41434eaf03d2 --- /dev/null +++ b/.changeset/long-crews-return.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +feat: native TypeScript support diff --git a/.changeset/lovely-items-turn.md b/.changeset/lovely-items-turn.md new file mode 100644 index 000000000000..499b1fadf816 --- /dev/null +++ b/.changeset/lovely-items-turn.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: dont error on stores looking like runes when runes explicitly turned off diff --git a/.changeset/lovely-rules-eat.md b/.changeset/lovely-rules-eat.md new file mode 100644 index 000000000000..5ecaa2fc8de8 --- /dev/null +++ b/.changeset/lovely-rules-eat.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: omit this bind this arg if we know it's not a signal diff --git a/.changeset/lucky-schools-hang.md b/.changeset/lucky-schools-hang.md new file mode 100644 index 000000000000..e83a19f3a06e --- /dev/null +++ b/.changeset/lucky-schools-hang.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: ensure dynamic attributes containing call expressions update diff --git a/.changeset/moody-frogs-exist.md b/.changeset/moody-frogs-exist.md new file mode 100644 index 000000000000..c9eb0c6790da --- /dev/null +++ b/.changeset/moody-frogs-exist.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: improve member expression mutation logic diff --git a/.changeset/moody-owls-cry.md b/.changeset/moody-owls-cry.md new file mode 100644 index 000000000000..0d94131ee977 --- /dev/null +++ b/.changeset/moody-owls-cry.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: exclude internal props from spread attributes diff --git a/.changeset/new-boats-wait.md b/.changeset/new-boats-wait.md new file mode 100644 index 000000000000..b7f09bd0a699 --- /dev/null +++ b/.changeset/new-boats-wait.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +chore: bump esrap diff --git a/.changeset/ninety-dingos-walk.md b/.changeset/ninety-dingos-walk.md new file mode 100644 index 000000000000..9a86f55552bb --- /dev/null +++ b/.changeset/ninety-dingos-walk.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: keep fallback value after spread update not setting that prop diff --git a/.changeset/odd-needles-joke.md b/.changeset/odd-needles-joke.md new file mode 100644 index 000000000000..94d2f1f585a4 --- /dev/null +++ b/.changeset/odd-needles-joke.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: address intro transition bugs diff --git a/.changeset/odd-schools-wait.md b/.changeset/odd-schools-wait.md new file mode 100644 index 000000000000..11fe1bdbac24 --- /dev/null +++ b/.changeset/odd-schools-wait.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +chore: untrack keyed validation logic diff --git a/.changeset/odd-shoes-cheat.md b/.changeset/odd-shoes-cheat.md new file mode 100644 index 000000000000..05f652e2cc5c --- /dev/null +++ b/.changeset/odd-shoes-cheat.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: tweak const tag parsing diff --git a/.changeset/polite-pumpkins-guess.md b/.changeset/polite-pumpkins-guess.md new file mode 100644 index 000000000000..e364f9635dcb --- /dev/null +++ b/.changeset/polite-pumpkins-guess.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: take event attributes into account when checking a11y diff --git a/.changeset/poor-eggs-enjoy.md b/.changeset/poor-eggs-enjoy.md new file mode 100644 index 000000000000..2ca830a1de40 --- /dev/null +++ b/.changeset/poor-eggs-enjoy.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: add missing files binding diff --git a/.changeset/popular-mangos-rest.md b/.changeset/popular-mangos-rest.md new file mode 100644 index 000000000000..4293bf3ba086 --- /dev/null +++ b/.changeset/popular-mangos-rest.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +feat: add $effect.active rune diff --git a/.changeset/pre.json b/.changeset/pre.json new file mode 100644 index 000000000000..fc2438c88c19 --- /dev/null +++ b/.changeset/pre.json @@ -0,0 +1,100 @@ +{ + "mode": "pre", + "tag": "next", + "initialVersions": { + "svelte": "5.0.0-next.0", + "svelte-playgrounds-demo": "0.0.1", + "svelte-playgrounds-sandbox": "0.0.1", + "svelte-5-preview": "0.5.0", + "svelte.dev": "1.0.0" + }, + "changesets": [ + "afraid-moose-matter", + "brave-walls-destroy", + "brown-spoons-boil", + "chatty-taxis-juggle", + "chilled-pumas-invite", + "chilly-dolphins-lick", + "clean-eels-beg", + "cold-birds-own", + "cuddly-pianos-drop", + "curly-lizards-dream", + "dirty-garlics-design", + "dirty-tips-add", + "early-ads-tie", + "eight-steaks-shout", + "eighty-bikes-camp", + "fair-crabs-check", + "famous-knives-sneeze", + "few-mugs-fail", + "fifty-steaks-float", + "flat-melons-protect", + "forty-comics-invent", + "fresh-weeks-trade", + "friendly-lies-camp", + "funny-wombats-argue", + "good-pianos-jump", + "great-icons-retire", + "green-eggs-approve", + "green-hounds-play", + "honest-icons-change", + "hungry-dots-fry", + "hungry-tips-unite", + "itchy-lions-wash", + "khaki-mails-draw", + "kind-deers-lay", + "kind-eagles-join", + "large-clouds-carry", + "lazy-spiders-think", + "lemon-geese-drum", + "light-pens-watch", + "long-crews-return", + "lovely-items-turn", + "lovely-rules-eat", + "lucky-schools-hang", + "moody-frogs-exist", + "moody-owls-cry", + "new-boats-wait", + "ninety-dingos-walk", + "odd-needles-joke", + "odd-schools-wait", + "odd-shoes-cheat", + "polite-pumpkins-guess", + "poor-eggs-enjoy", + "popular-mangos-rest", + "quiet-camels-mate", + "rare-pears-whisper", + "rich-sheep-burn", + "rotten-buckets-develop", + "serious-zebras-scream", + "seven-deers-jam", + "seven-ravens-check", + "sharp-gorillas-impress", + "shiny-baboons-play", + "shiny-shrimps-march", + "slimy-clouds-talk", + "small-papayas-laugh", + "soft-geese-learn", + "sour-forks-stare", + "sour-rules-march", + "stale-comics-look", + "strong-lemons-provide", + "swift-ravens-hunt", + "tall-shrimps-worry", + "tall-tigers-wait", + "ten-worms-reflect", + "thin-foxes-lick", + "thirty-flowers-sit", + "thirty-ghosts-fix", + "thirty-impalas-repair", + "thirty-wombats-relax", + "tiny-kings-whisper", + "twelve-onions-juggle", + "two-dragons-yell", + "two-falcons-buy", + "wet-games-fly", + "wicked-clouds-exercise", + "wicked-doors-train", + "witty-camels-warn" + ] +} diff --git a/.changeset/quiet-camels-mate.md b/.changeset/quiet-camels-mate.md new file mode 100644 index 000000000000..6e723bd4ab16 --- /dev/null +++ b/.changeset/quiet-camels-mate.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +chore: improve keyblock treeshaking diff --git a/.changeset/rare-pears-whisper.md b/.changeset/rare-pears-whisper.md new file mode 100644 index 000000000000..05dc333b319b --- /dev/null +++ b/.changeset/rare-pears-whisper.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +feat: add $effect.root rune diff --git a/.changeset/rich-sheep-burn.md b/.changeset/rich-sheep-burn.md new file mode 100644 index 000000000000..4a2128d6aa56 --- /dev/null +++ b/.changeset/rich-sheep-burn.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: add top level snippets to instance scope diff --git a/.changeset/rotten-buckets-develop.md b/.changeset/rotten-buckets-develop.md new file mode 100644 index 000000000000..4664f34eaf3d --- /dev/null +++ b/.changeset/rotten-buckets-develop.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +breaking: svelte 5 alpha diff --git a/.changeset/selfish-tools-hide.md b/.changeset/selfish-tools-hide.md new file mode 100644 index 000000000000..194a2439d6c4 --- /dev/null +++ b/.changeset/selfish-tools-hide.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: ensure computed props are cached with derived diff --git a/.changeset/serious-socks-cover.md b/.changeset/serious-socks-cover.md new file mode 100644 index 000000000000..709bb95beb07 --- /dev/null +++ b/.changeset/serious-socks-cover.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: ensure event handlers containing arguments are not hoisted diff --git a/.changeset/serious-zebras-scream.md b/.changeset/serious-zebras-scream.md new file mode 100644 index 000000000000..9efd62e5b5a9 --- /dev/null +++ b/.changeset/serious-zebras-scream.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: ensure snippets have correct scope diff --git a/.changeset/seven-deers-jam.md b/.changeset/seven-deers-jam.md new file mode 100644 index 000000000000..cdb0c8d16b9d --- /dev/null +++ b/.changeset/seven-deers-jam.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: better attribute casing logic diff --git a/.changeset/seven-ravens-check.md b/.changeset/seven-ravens-check.md new file mode 100644 index 000000000000..0bbfad1b227d --- /dev/null +++ b/.changeset/seven-ravens-check.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +feat: support type definition in {@const} diff --git a/.changeset/sharp-gorillas-impress.md b/.changeset/sharp-gorillas-impress.md new file mode 100644 index 000000000000..37c74aafa649 --- /dev/null +++ b/.changeset/sharp-gorillas-impress.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: only treat instance context exports as accessors diff --git a/.changeset/shiny-baboons-play.md b/.changeset/shiny-baboons-play.md new file mode 100644 index 000000000000..dad945f3dbfe --- /dev/null +++ b/.changeset/shiny-baboons-play.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +feat: add Snippet type diff --git a/.changeset/shiny-shrimps-march.md b/.changeset/shiny-shrimps-march.md new file mode 100644 index 000000000000..a6920fae3e29 --- /dev/null +++ b/.changeset/shiny-shrimps-march.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: do not propagate global intro transitions diff --git a/.changeset/slimy-clouds-talk.md b/.changeset/slimy-clouds-talk.md new file mode 100644 index 000000000000..6ff121904504 --- /dev/null +++ b/.changeset/slimy-clouds-talk.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +feat: ignore `src`, `srcset`, and `href` attributes when hydrating diff --git a/.changeset/small-papayas-laugh.md b/.changeset/small-papayas-laugh.md new file mode 100644 index 000000000000..43475946cb58 --- /dev/null +++ b/.changeset/small-papayas-laugh.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +breaking: remove Component type, keep using SvelteComponent instead diff --git a/.changeset/soft-geese-learn.md b/.changeset/soft-geese-learn.md new file mode 100644 index 000000000000..15216a3b0928 --- /dev/null +++ b/.changeset/soft-geese-learn.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: allow setting files binding for `` diff --git a/.changeset/sour-forks-stare.md b/.changeset/sour-forks-stare.md new file mode 100644 index 000000000000..7bdd4433c4d8 --- /dev/null +++ b/.changeset/sour-forks-stare.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +chore: remove redundant hydration code diff --git a/.changeset/sour-rules-march.md b/.changeset/sour-rules-march.md new file mode 100644 index 000000000000..f948540af742 --- /dev/null +++ b/.changeset/sour-rules-march.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: only escape attribute values for elements, not components diff --git a/.changeset/stale-comics-look.md b/.changeset/stale-comics-look.md new file mode 100644 index 000000000000..b7f09bd0a699 --- /dev/null +++ b/.changeset/stale-comics-look.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +chore: bump esrap diff --git a/.changeset/strong-lemons-provide.md b/.changeset/strong-lemons-provide.md new file mode 100644 index 000000000000..1c8dc17a24be --- /dev/null +++ b/.changeset/strong-lemons-provide.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: handle event attribute spreading with event delegation diff --git a/.changeset/swift-ravens-hunt.md b/.changeset/swift-ravens-hunt.md new file mode 100644 index 000000000000..d62ff1ca51b5 --- /dev/null +++ b/.changeset/swift-ravens-hunt.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: improve template text node serialization diff --git a/.changeset/tall-shrimps-worry.md b/.changeset/tall-shrimps-worry.md new file mode 100644 index 000000000000..7f0931130156 --- /dev/null +++ b/.changeset/tall-shrimps-worry.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: add snippet marker symbol to children prop diff --git a/.changeset/tall-tigers-wait.md b/.changeset/tall-tigers-wait.md new file mode 100644 index 000000000000..a71fdef9ac47 --- /dev/null +++ b/.changeset/tall-tigers-wait.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: improve infinite loop capturing diff --git a/.changeset/ten-worms-reflect.md b/.changeset/ten-worms-reflect.md new file mode 100644 index 000000000000..a78d6b052f83 --- /dev/null +++ b/.changeset/ten-worms-reflect.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: remove constructor overload diff --git a/.changeset/thin-foxes-lick.md b/.changeset/thin-foxes-lick.md new file mode 100644 index 000000000000..904c84cc5cbe --- /dev/null +++ b/.changeset/thin-foxes-lick.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +chore: improve `` generated code diff --git a/.changeset/thirty-flowers-sit.md b/.changeset/thirty-flowers-sit.md new file mode 100644 index 000000000000..a3d0927788f5 --- /dev/null +++ b/.changeset/thirty-flowers-sit.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: support class exports diff --git a/.changeset/thirty-ghosts-fix.md b/.changeset/thirty-ghosts-fix.md new file mode 100644 index 000000000000..974c82a38be4 --- /dev/null +++ b/.changeset/thirty-ghosts-fix.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +chore: tweak signals for better runtime perf diff --git a/.changeset/thirty-impalas-repair.md b/.changeset/thirty-impalas-repair.md new file mode 100644 index 000000000000..9e909e9ed295 --- /dev/null +++ b/.changeset/thirty-impalas-repair.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: adjust event delegation heuristics diff --git a/.changeset/thirty-wombats-relax.md b/.changeset/thirty-wombats-relax.md new file mode 100644 index 000000000000..0ed0f40a7590 --- /dev/null +++ b/.changeset/thirty-wombats-relax.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: improve each block index handling diff --git a/.changeset/tiny-kings-whisper.md b/.changeset/tiny-kings-whisper.md new file mode 100644 index 000000000000..e1e5c3a01dba --- /dev/null +++ b/.changeset/tiny-kings-whisper.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: treat `slot` the same as other props diff --git a/.changeset/twelve-onions-juggle.md b/.changeset/twelve-onions-juggle.md new file mode 100644 index 000000000000..00018fce3885 --- /dev/null +++ b/.changeset/twelve-onions-juggle.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: handle ts expressions when dealing with runes diff --git a/.changeset/two-dragons-yell.md b/.changeset/two-dragons-yell.md new file mode 100644 index 000000000000..f6f7e17532d4 --- /dev/null +++ b/.changeset/two-dragons-yell.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: correctly inspect derived values diff --git a/.changeset/two-falcons-buy.md b/.changeset/two-falcons-buy.md new file mode 100644 index 000000000000..c1a8e069f6fb --- /dev/null +++ b/.changeset/two-falcons-buy.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +chore: remove unused code diff --git a/.changeset/wet-games-fly.md b/.changeset/wet-games-fly.md new file mode 100644 index 000000000000..9f03e2688229 --- /dev/null +++ b/.changeset/wet-games-fly.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: type-level back-compat for default slot and children prop diff --git a/.changeset/wicked-clouds-exercise.md b/.changeset/wicked-clouds-exercise.md new file mode 100644 index 000000000000..64c1c0c9b2f3 --- /dev/null +++ b/.changeset/wicked-clouds-exercise.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: adjust regex diff --git a/.changeset/wicked-doors-train.md b/.changeset/wicked-doors-train.md new file mode 100644 index 000000000000..28b3271046a4 --- /dev/null +++ b/.changeset/wicked-doors-train.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: add missing visitor for assignments during compilation diff --git a/.changeset/witty-camels-warn.md b/.changeset/witty-camels-warn.md new file mode 100644 index 000000000000..cdcccd6ac654 --- /dev/null +++ b/.changeset/witty-camels-warn.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +chore: prevent some unused variable creation diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 000000000000..fbab8fbc0d02 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,23 @@ +# NOTE: In general this should be kept in sync with .eslintignore + +**/dist/** +**/config/** +**/build/** +**/playgrounds/sandbox/** +**/npm/** +**/*.js.flow +**/*.d.ts +**/playwright*/** +**/vite.config.js +**/vite.prod.config.js +**/node_modules + +**/tests/** + +# documentation can contain invalid examples +documentation/** + +# contains a fork of the REPL which doesn't adhere to eslint rules +sites/svelte-5-preview/** +# Wasn't checked previously, reenable at some point +sites/svelte.dev/** diff --git a/.eslintrc.cjs b/.eslintrc.cjs new file mode 100644 index 000000000000..e161e50ef18d --- /dev/null +++ b/.eslintrc.cjs @@ -0,0 +1,54 @@ +module.exports = { + extends: ['@sveltejs'], + + // TODO: add runes to eslint-plugin-svelte + globals: { + $state: true, + $derived: true, + $effect: true, + $props: true + }, + + overrides: [ + { + // scripts and playground should be console logging so don't lint against them + files: ['playgrounds/**/*', 'scripts/**/*'], + rules: { + 'no-console': 'off' + } + }, + { + // the playgrounds can use public naming conventions since they're examples + files: ['playgrounds/**/*'], + rules: { + 'lube/svelte-naming-convention': 'off' + } + }, + { + files: ['packages/svelte/src/compiler/**/*'], + rules: { + 'no-var': 'error' + } + } + ], + + plugins: ['lube'], + + rules: { + 'no-console': 'error', + 'lube/svelte-naming-convention': ['error', { fixSameNames: true }], + // eslint isn't that well-versed with JSDoc to know that `foo: /** @type{..} */ (foo)` isn't a violation of this rule, so turn it off + 'object-shorthand': 'off', + 'no-var': 'off', + + // TODO: enable these rules and run `pnpm lint:fix` + // skipping that for now so as to avoid impacting real work + '@typescript-eslint/array-type': 'off', + '@typescript-eslint/no-namespace': 'off', + '@typescript-eslint/no-non-null-assertion': 'off', + '@typescript-eslint/no-unused-vars': 'off', + 'prefer-const': 'off', + 'svelte/valid-compile': 'off', + quotes: 'off' + } +}; diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 83e0b253b364..a4819f87baa5 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,3 +1,8 @@ +## Svelte 5 rewrite + +Please note that [the Svelte codebase is currently being rewritten for Svelte 5](https://svelte.dev/blog/runes). Changes should target Svelte 5, which lives on the default branch (`main`). + +If your PR concerns Svelte 4 (including updates to [svelte.dev.docs](https://svelte.dev/docs)), please ensure the base branch is `svelte-4` and not `main`. ### Before submitting the PR, please make sure you do the following diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b8e948b3a43d..08820f0ed3ef 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,7 +1,7 @@ name: CI on: push: - branches: [master] + branches: [main] pull_request: permissions: contents: read # to fetch code (actions/checkout) @@ -17,16 +17,17 @@ jobs: strategy: matrix: include: - - node-version: 16 - os: ubuntu-latest - - node-version: 16 + - node-version: 18 os: windows-latest - - node-version: 16 + - node-version: 18 os: macOS-latest - node-version: 18 os: ubuntu-latest - node-version: 20 os: ubuntu-latest + - node-version: 21 + os: ubuntu-latest + steps: - uses: actions/checkout@v3 - uses: pnpm/action-setup@v2.2.4 @@ -47,6 +48,6 @@ jobs: - uses: pnpm/action-setup@v2.2.4 - uses: actions/setup-node@v3 with: - node-version: 16 + node-version: 18 cache: pnpm - run: 'pnpm i && pnpm check && pnpm lint' diff --git a/.github/workflows/ecosystem-ci-trigger.yml b/.github/workflows/ecosystem-ci-trigger.yml index 952f83a861f8..ce7bf04136ac 100644 --- a/.github/workflows/ecosystem-ci-trigger.yml +++ b/.github/workflows/ecosystem-ci-trigger.yml @@ -61,11 +61,11 @@ jobs: repo: pr.head.repo.full_name } - id: generate-token - uses: tibdex/github-app-token@b62528385c34dbc9f38e5f4225ac829252d1ea92 #keep pinned for security reasons, currently 1.8.0 + uses: tibdex/github-app-token@b62528385c34dbc9f38e5f4225ac829252d1ea92 #keep pinned for security reasons, currently 1.8.0 with: app_id: ${{ secrets.ECOSYSTEM_CI_GITHUB_APP_ID }} private_key: ${{ secrets.ECOSYSTEM_CI_GITHUB_APP_PRIVATE_KEY }} - repository: "${{ github.repository_owner }}/svelte-ecosystem-ci" + repository: '${{ github.repository_owner }}/svelte-ecosystem-ci' - uses: actions/github-script@v6 id: trigger env: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bd590aff5fca..24b1229b4296 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,7 +3,7 @@ name: Release on: push: branches: - - master + - main permissions: {} jobs: diff --git a/.gitignore b/.gitignore index cc2e05ea5f5e..16cac3b27f51 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,25 @@ +# Dependency directories +node_modules/ + +# IDE related .idea -.DS_Store -.vscode/* -!.vscode/launch.json -node_modules + +# Test coverage +coverage +*.lcov + +# Optional eslint cache .eslintcache + +# dotenv environment variables file +.env +.env.test + +# build output +dist +.vercel + +# OS-specific +.DS_Store + +tmp diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 000000000000..45e12c6e3fbc --- /dev/null +++ b/.prettierignore @@ -0,0 +1,43 @@ +# NOTE: In general this should be kept in sync with .eslintignore + +packages/**/dist/*.js +packages/**/build/*.js +packages/**/npm/**/* +packages/**/config/*.js +packages/svelte/tests/**/*.svelte +packages/svelte/tests/**/_expected* +packages/svelte/tests/**/_actual* +packages/svelte/tests/**/expected* +packages/svelte/tests/**/_output +packages/svelte/tests/**/shards/*.test.js +packages/svelte/tests/hydration/samples/*/_before.html +packages/svelte/tests/hydration/samples/*/_before_head.html +packages/svelte/tests/hydration/samples/*/_after.html +packages/svelte/tests/hydration/samples/*/_after_head.html +packages/svelte/types +packages/svelte/compiler.cjs +playgrounds/demo/src +playgrounds/sandbox/input/**.svelte +playgrounds/sandbox/output + +sites/svelte.dev/static/svelte-app.json +sites/svelte.dev/scripts/svelte-app/ +sites/svelte.dev/src/routes/_components/Supporters/contributors.jpg +sites/svelte.dev/src/routes/_components/Supporters/contributors.js +sites/svelte.dev/src/routes/_components/Supporters/donors.jpg +sites/svelte.dev/src/routes/_components/Supporters/donors.js +sites/svelte.dev/src/lib/generated + +**/node_modules +**/.svelte-kit +**/.vercel +.github/CODEOWNERS +.prettierignore +.eslintignore +.changeset +pnpm-lock.yaml +pnpm-workspace.yaml + +# Temporarily ignore this file to avoid merge conflicts. +# see: https://github.com/sveltejs/svelte/pull/9609 +documentation/docs/05-misc/03-typescript.md diff --git a/.prettierrc b/.prettierrc index 0ea7a0b1e9fe..c4fd5d9f2f73 100644 --- a/.prettierrc +++ b/.prettierrc @@ -17,7 +17,12 @@ "useTabs": false, "tabWidth": 2 } + }, + { + "files": ["sites/svelte-5-preview/src/routes/docs/content/**/*.md"], + "options": { + "printWidth": 60 + } } - ], - "pluginSearchDirs": ["."] + ] } diff --git a/.vscode/launch.json b/.vscode/launch.json index 2e22a5ab9b7e..41d8017ce29f 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -14,8 +14,14 @@ "name": "Playground: Server", "outputCapture": "std", "program": "start.js", - "cwd": "${workspaceFolder}/packages/playground", + "cwd": "${workspaceFolder}/playgrounds/demo", "cascadeTerminateToConfigurations": ["Playground: Browser"] + }, + { + "type": "node", + "request": "launch", + "name": "Run sandbox", + "program": "${workspaceFolder}/playgrounds/sandbox/run.js" } ], "compounds": [ diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000000..3446d68abecb --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "search.exclude": { + "sites/svelte-5-preview/static/*": true + } +} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8c66b30ebf4f..167a62646e38 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -43,7 +43,7 @@ The maintainers meet on the final Saturday of each month. While these meetings a ### Prioritization -We do our best to review PRs and RFCs as they are sent, but it is difficult to keep up. We welcome help in reviewing PRs, RFC, and issues. If an item aligns with the current priority on our [roadmap](https://svelte.dev/roadmap), it is more likely to be reviewed quickly. PRs to the most important and active ones repositories get reviewed more quickly while PRs to smaller inactive repos may sit for a bit before we periodically come by and review the pending PRs in a batch. +We do our best to review PRs and RFCs as they are sent, but it is difficult to keep up. We welcome help in reviewing PRs, RFCs, and issues. If an item aligns with the current priority on our [roadmap](https://svelte.dev/roadmap), it is more likely to be reviewed quickly. PRs to the most important and active ones repositories get reviewed more quickly while PRs to smaller inactive repos may sit for a bit before we periodically come by and review the pending PRs in a batch. ## Bugs @@ -74,14 +74,15 @@ Small pull requests are much easier to review and more likely to get merged. ### Installation -1. Ensure you have [pnpm](https://pnpm.io/installation) installed -1. After cloning the repository, run `pnpm install`. You can do this in the root directory or in the `svelte` project -1. Move into the `svelte` directory with `cd packages/svelte` -1. To compile in watch mode, run `pnpm dev` +Ensure you have [pnpm](https://pnpm.io/installation) installed. After cloning the repository, run `pnpm install`. + +### Developing + +To build the UMD version of `svelte/compiler` (this is only necessary for CommonJS consumers, or in-browser use), run `pnpm build` inside `packages/svelte`. To rebuild whenever source files change, run `pnpm dev`. ### Creating a branch -Fork [the repository](https://github.com/sveltejs/svelte) and create your branch from `master`. If you've never sent a GitHub pull request before, you can learn how from [this free video series](https://egghead.io/courses/how-to-contribute-to-an-open-source-project-on-github). +Fork [the repository](https://github.com/sveltejs/svelte) and create your branch from `main`. If you've never sent a GitHub pull request before, you can learn how from [this free video series](https://egghead.io/courses/how-to-contribute-to-an-open-source-project-on-github). ### Testing @@ -100,18 +101,28 @@ Test samples are kept in `/test/xxx/samples` folder. > PREREQUISITE: Install chromium via playwright by running `pnpm playwright install chromium` 1. To run test, run `pnpm test`. -1. To run test for a specific feature, you can use the `-g` (aka `--grep`) option. For example, to only run test involving transitions, run `pnpm test -- -g transition`. +1. To run a particular test suite, use `pnpm test `, for example: + + ```bash + pnpm test validator + ``` -##### Running solo test +1. To filter tests _within_ a test suite, use `pnpm test -- -t `, for example: -1. To run only one test, rename the test sample folder to end with `.solo`. For example, to run the `test/js/samples/action` only, rename it to `test/js/samples/action.solo`. -1. To run only one test suite, rename the test suite folder to end with `.solo`. For example, to run the `test/js` test suite only, rename it to `test/js.solo`. -1. Remember to rename the test folder back. The CI will fail if there's a solo test. + ```bash + pnpm test validator -- -t a11y-alt-text + ``` + + (You can also do `FILTER= pnpm test ` which removes other tests rather than simply skipping them — this will result in faster and more compact test results, but it's non-idiomatic. Choose your fighter.) ##### Updating `.expected` files -1. Tests suites like `css`, `js`, `server-side-rendering` asserts that the generated output has to match the content in the `.expected` file. For example, in the `js` test suites, the generated js code is compared against the content in `expected.js`. -1. To update the content of the `.expected` file, run the test with `--update` flag. (`pnpm test --update`) +1. Tests suites like `snapshot` and `parser` assert that the generated output matches the existing snapshot. +1. To update these snapshots, run `UPDATE_SNAPSHOTS=true pnpm test`. + +### Typechecking + +To typecheck the codebase, run `pnpm check` inside `packages/svelte`. To typecheck in watch mode, run `pnpm check:watch`. ### Style guide @@ -130,7 +141,7 @@ Please make sure the following is done when submitting a pull request: 1. Make sure your code lints (`pnpm lint`). 1. Make sure your tests pass (`pnpm test`). -All pull requests should be opened against the `master` branch. Make sure the PR does only one thing, otherwise please split it. +All pull requests should be opened against the `main` branch. Make sure the PR does only one thing, otherwise please split it. #### Breaking changes @@ -147,7 +158,7 @@ When adding a new breaking change, follow this template in your pull request: ## License -By contributing to Svelte, you agree that your contributions will be licensed under its [MIT license](https://github.com/sveltejs/svelte/blob/master/LICENSE). +By contributing to Svelte, you agree that your contributions will be licensed under its [MIT license](https://github.com/sveltejs/svelte/blob/master/LICENSE.md). ## Questions diff --git a/README.md b/README.md index 4dbfee3823f8..65a180924f10 100644 --- a/README.md +++ b/README.md @@ -22,47 +22,7 @@ You may view [our roadmap](https://svelte.dev/roadmap) if you'd like to see what ## Contributing -Please see the [Contributing Guide](CONTRIBUTING.md) and [svelte package](packages/svelte) for contributing to Svelte. - -### Development - -Pull requests are encouraged and always welcome. [Pick an issue](https://github.com/sveltejs/svelte/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc) and help us out! - -To install and work on Svelte locally: - -```bash -git clone https://github.com/sveltejs/svelte.git -cd svelte -pnpm install -``` - -> Do not use Yarn to install the dependencies, as the specific package versions in `pnpm-lock.json` are used to build and test Svelte. - -To build the compiler and all the other modules included in the package: - -```bash -pnpm build -``` - -To watch for changes and continually rebuild the package (this is useful if you're using [`pnpm link`](https://pnpm.io/cli/link) to test out changes in a project locally): - -```bash -pnpm dev -``` - -The compiler is written in JavaScript and uses [JSDoc](https://jsdoc.app/index.html) comments for type-checking. - -### Running Tests - -```bash -pnpm test -``` - -To filter tests, use `-g` (aka `--grep`). For example, to only run tests involving transitions: - -```bash -pnpm test -- -g transition -``` +Please see the [Contributing Guide](CONTRIBUTING.md) and the [`svelte`](packages/svelte) package for information on contributing to Svelte. ### svelte.dev diff --git a/documentation/blog/2023-06-22-svelte-4.md b/documentation/blog/2023-06-22-svelte-4.md index f063c47c00fe..7eb2bd834270 100644 --- a/documentation/blog/2023-06-22-svelte-4.md +++ b/documentation/blog/2023-06-22-svelte-4.md @@ -1,5 +1,5 @@ --- -title: "Announcing Svelte 4" +title: 'Announcing Svelte 4' description: 'Updated performance, developer experience, and site' author: The Svelte team authorURL: https://svelte.dev/ diff --git a/documentation/blog/2023-06-29-svelte-dev-overhaul.md b/documentation/blog/2023-06-29-svelte-dev-overhaul.md index b7782abcc272..a3ffd739bf1e 100644 --- a/documentation/blog/2023-06-29-svelte-dev-overhaul.md +++ b/documentation/blog/2023-06-29-svelte-dev-overhaul.md @@ -31,7 +31,7 @@ We've also taken extra care to ensure that all the links from the old website wi The lack of search functionality could make finding stuff a nuisance as Ctrl+F only returns results in order of occurrence and not order of importance. While Ctrl+F did have its benefits such as not requiring JS, now that the site has multiple pages, it's not an option anymore. -And for that, the new website comes with a search bar, which searches through the docs and the API surface. Hit Ctrl+K (or CMD+F for Mac users) and start searching — it even works without JavaScript! +And for that, the new website comes with a search bar, which searches through the docs and the API surface. Hit Ctrl+K (or CMD+K for Mac users) and start searching — it even works without JavaScript! ## Lights, TypeScript, Action! diff --git a/documentation/blog/2023-07-01-whats-new-in-svelte-july-2023.md b/documentation/blog/2023-07-01-whats-new-in-svelte-july-2023.md index afb39a553992..a9134ed5d9c5 100644 --- a/documentation/blog/2023-07-01-whats-new-in-svelte-july-2023.md +++ b/documentation/blog/2023-07-01-whats-new-in-svelte-july-2023.md @@ -1,6 +1,6 @@ --- title: "What's new in Svelte: July 2023" -description: "Svelte 4.0, new website and a tour around the community" +description: 'Svelte 4.0, new website and a tour around the community' author: Dani Sandoval authorURL: https://dreamindani.com --- @@ -8,6 +8,7 @@ authorURL: https://dreamindani.com Svelte 4 is out and folks have been building! There's a bunch of new showcases, libraries and tutorials to share. So let's get right into it... ## What's new in Svelte + The big news this month was the release of Svelte 4.0! You can read all about it in the [Announcing Svelte 4 post](https://svelte.dev/blog/svelte-4). From performance fixes and developer experience improvements to [a brand new site, docs and tutorial](https://svelte.dev/blog/svelte-dev-overhaul)... this new release sets the stage for Svelte 5 with minimal breaking changes. If you're already on Node.js 16, it's possible you won't see any breaking changes in your project. But be sure to read the [migration guide](https://svelte.dev/docs/v4-migration-guide) for all the details. @@ -15,7 +16,9 @@ If you're already on Node.js 16, it's possible you won't see any breaking change For a full list of all the changes to the Svelte compiler, including unreleased changes, check out the [CHANGELOG](https://github.com/sveltejs/svelte/blob/master/packages/svelte/CHANGELOG.md). ## What's new in SvelteKit + This month there were lots of awesome [bug fixes](https://github.com/sveltejs/kit/blob/master/packages/kit/CHANGELOG.md), so be sure to upgrade to the latest version! There are also a few new features to mention: + - The new `event.isSubRequest` boolean indicates whether this is a same-origin fetch request to one of the app's own APIs during a server request (**1.21.0**, [Docs](https://kit.svelte.dev/docs/types#public-types-requestevent), [#10170](https://github.com/sveltejs/kit/pull/10170)) - A new config option, `config.kit.env.privatePrefix` will set a private prefix on environment variables. This defaults to `''` (**1.21.0**, [Docs](https://kit.svelte.dev/docs/configuration), [#9996](https://github.com/sveltejs/kit/pull/9996)) - `VERSION` is now exported and accessible via `@sveltejs/kit`. This can be used for feature detection or anything else that requires knowledge of the current version of SvelteKit (**1.21.0**, [Docs](https://kit.svelte.dev/docs/modules#sveltejs-kit-version), [#9969](https://github.com/sveltejs/kit/pull/9969)) @@ -27,6 +30,7 @@ For adapter-specific changes, check out the CHANGELOGs in each of [the `adapter` ## Community Showcase **Apps & Sites built with Svelte** + - [Heerdle](https://github.com/DreaminDani/heerdle) is a remake of Spotify's now-defunct Heardle - the daily music guessing game - [Meoweler](https://meoweler.com/) is a travel site filled with cats and helpful facts about popular destinations - [A tech lead from IKEA](https://www.reddit.com/r/sveltejs/comments/13w4zg3/comment/jmaxial/?utm_source=share&utm_medium=web2x&context=3) gave a few more details on the way they build pages (and page template) using Svelte @@ -39,10 +43,12 @@ For adapter-specific changes, check out the CHANGELOGs in each of [the `adapter` - [YABin](https://github.com/Yureien/YABin) is Yet Another Pastebin with some very specific features **Learning Resources** + - [Announcing Svelte 4 post](https://svelte.dev/blog/svelte-4) - [svelte.dev: A complete overhaul](https://svelte.dev/blog/svelte-dev-overhaul) _Featuring Svelte Contributors and Ambassadors_ + - [Dev Vlog: June 2023](https://www.youtube.com/watch?v=AOXq89h8saI) - Svelte 4.0 with Rich Harris - [PodRocket: Svelte 4](https://podrocket.logrocket.com/svelte-4) with Geoff - [This Dot Media: Svelte 4 Launch Party](https://www.youtube.com/watch?v=-9gy_leMmcQ) with Simon, Ben, Geoff, and Puru @@ -60,12 +66,13 @@ _Featuring Svelte Contributors and Ambassadors_ - [Svelte Society - London June 2023](https://www.youtube.com/watch?v=EkH0aMgeIKw) - [Using The Svelte Context API With Stores](https://www.youtube.com/watch?v=dp-7NvLDrK4), [Impossible FLIP Layout Animations With Svelte And GSAP](https://www.youtube.com/watch?v=ecP8RwpkiQw) and [Create Beautiful Presentations With Svelte](https://www.youtube.com/watch?v=67lqa5kTQkA) by Joy of Code - _To Watch_ + - [Server-side filtered, paginated and sorted Table in SvelteKit](https://www.youtube.com/watch?v=VgCU0cVWgJE) by hartenfellerdev - [Best Icon Library for Svelte and SvelteKit in 2023](https://www.youtube.com/watch?v=qJP6hC4YIhk) by SvelteRust _To Read_ + - [From Zero to Production with SvelteKit](https://www.okupter.com/events/from-zero-to-production-with-sveltekit) by Justin Ahinon - [Thoughts on Svelte(Kit), one year and 3 billion requests later](https://claudioholanda.ch/en/blog/svelte-kit-after-3-billion-requests/) by Claudio Holanda - [How I published a gratitude journaling app for iOS and Android using SvelteKit and Capacitor](https://khromov.se/how-i-published-a-gratitude-journaling-app-for-ios-and-android-using-sveltekit-and-capacitor/) by Stanislav Khromov @@ -77,8 +84,8 @@ _To Read_ - [Svelte Real‑time Multiplayer Game: User Presence](https://rodneylab.com/svelte-realtime-multiplayer-game/) and [SvelteKit PostCSS Tutorial: use Future CSS Today](https://rodneylab.com/sveltekit-postcss-tutorial/) by Rodney Lab - [SvelteKit’s World of Routing: Unleash power of your app using Dynamic Routes and Parameters](https://www.inow.dev/sveltekits-world-of-routing-unleash-power-of-your-app-using-dynamic-routes-and-parameters/) by Igor Nowosad - **Libraries, Tools & Components** + - [The Vercel AI SDK](https://vercel.com/blog/introducing-the-vercel-ai-sdk) is an interoperable, streaming-enabled, edge-ready software development kit for AI apps built with React and Svelte - [Superforms 1.0](https://superforms.rocks/) has been released. Check out the [migration guide](https://superforms.rocks/migration) and [new feature list](https://superforms.rocks/whats-new-v1) for more details - [Panda CSS](https://panda-css.com/docs/getting-started/svelte) is CSS-in-JS with build time generated styles, RSC compatibility and multi-variant support diff --git a/documentation/blog/2023-08-01-whats-new-in-svelte-august-2023.md b/documentation/blog/2023-08-01-whats-new-in-svelte-august-2023.md index e7b27d65f779..34a482b266d9 100644 --- a/documentation/blog/2023-08-01-whats-new-in-svelte-august-2023.md +++ b/documentation/blog/2023-08-01-whats-new-in-svelte-august-2023.md @@ -1,6 +1,6 @@ --- title: "What's new in Svelte: August 2023" -description: "Extending Custom Element Classes and new +server exports" +description: 'Extending Custom Element Classes and new +server exports' author: Dani Sandoval authorURL: https://dreamindani.com --- @@ -10,6 +10,7 @@ Some sweet new features have dropped in both Svelte and SvelteKit, this month. I More on all that down below... ## What's new in Svelte & Language Tools + There's been a bunch of minor bugfixes since the Svelte 4 release. You can find them in the [CHANGELOG](https://github.com/sveltejs/svelte/blob/master/packages/svelte/CHANGELOG.md). The **4.1.0 release** added the ability to further customize the custom element class that wraps the underlying Svelte component. Check out the [Custom Elements API docs](https://svelte.dev/docs/custom-elements-api) or the [PR](https://github.com/sveltejs/svelte/pull/8991) for more info! @@ -17,6 +18,7 @@ The **4.1.0 release** added the ability to further customize the custom element In addition to supporting SvelteKit's new `HEAD` server method, Svelte's language tools now support Prettier v3 (**extensions-107.9.0**) and workspace trust settings are now used to support all settings in workspace (**extensions-107.8.0**). ## What's new in SvelteKit + - The `HEAD` server method is now available in API routes (**1.22.0**, [Docs](https://kit.svelte.dev/docs/routing#server), [#9753](https://github.com/sveltejs/kit/pull/9753)) - Responses with `Vary` headers are now cached, too (except for `Vary: *`) (**1.22.0**, [Docs](https://kit.svelte.dev/docs/routing#server-content-negotiation), [#9993](https://github.com/sveltejs/kit/pull/9993)) - There's now a more helpful error for preview if SvelteKit's build output doesn't exist (**1.22.2**, [#10337](https://github.com/sveltejs/kit/pull/10337)) @@ -28,6 +30,7 @@ For all the patches and performance updates from this month, check out the [Svel ## Community Showcase **Apps & Sites built with Svelte** + - [GitLight](https://github.com/ColinLienard/gitlight) brings GitHub & GitLab notifications to your desktop - [Days](https://github.com/paprikka/days) is paprikka's life in days, inspired by Buster Benson's Life in Weeks - [Mofi](https://mofi.loud.red/) is a content-aware fill and trim for music @@ -37,14 +40,14 @@ For all the patches and performance updates from this month, check out the [Svel - [Maktaba](https://www.maktaba.digital/) is a bookmark manager that "you will actually use" - [Whispering](https://github.com/braden-w/whispering-extension) is a Chrome extension that lets you access OpenAI's Whisper API for fast transcription in the browser (including ChatGPT) - [DocuTalk](https://docutalk.co/) is an AI Customer Support chatbot for your website -- [Krello](https://github.com/iamrishupatel/trello-clone) is a Trello clone built with Svelte, Appwrite and Flowbite +- [Krello](https://github.com/iamrishupatel/trello-clone) is a Trello clone built with Svelte, Appwrite and Flowbite - [Been](https://beeneverywhere.net/) is a map builder with travel stats like visited countries, extreme visited points, etc. - [image-to-social-media-thumbnail](https://brody.fyi/tools/image-to-social-media-thumbnail) lets you convert any image to a social media thumbnail - [Svelte Capacitor Store](https://github.com/sdekna/svelte-capacitor-store) is a persistent store that uses capacitor (preferences) storage on native devices, and localStorage otherwise, making it ideal for multi-platform projects - **Learning Resources** _Featuring Svelte Contributors and Ambassadors_ + - [Exploring Svelte 4 w/ Kevin AK: Performance, Compatibility, & Web Component Support | Modern Web Pod](https://www.youtube.com/watch?v=YOL0HGGVib4) by This Dot Media - [Svelte Sirens Stream Design Systems: Lessons Learned](https://www.youtube.com/live/YHZaiIGSqsE?feature=share) featuring Eric Liu, creator of Carbon Components Svelte and the `sveld` docgen library - This Week in Svelte: @@ -52,8 +55,8 @@ _Featuring Svelte Contributors and Ambassadors_ - [2023 July 7](https://www.youtube.com/watch?v=0tq1ph4DDFA) - Svelte 4.0.5, Kit 1.22.1, Svelte 5, local storage and markdown - [2023 July 21](https://www.youtube.com/watch?v=AG4_3kon3zU) - Svelte 4.1.1, SvelteKit 1.22.3, Progressive enhancement - _To Watch/Hear_ + - [What is The Transitional Web? with Chris Ferdinandi](https://www.smashingmagazine.com/2023/07/smashing-podcast-episode-63/?ref=dailydevbytes.com) by Smashing Podcast - [SvelteKit in 100 seconds](https://www.youtube.com/watch?v=H1eEFfAkIik) by Fireship - [Primo V2 Introduction](https://www.youtube.com/watch?v=ThInVXgxJ1Q) by Primo (a [visual CMS](https://primocms.org/) based on Svelte) @@ -62,8 +65,8 @@ _To Watch/Hear_ - [Markdown in SvelteKit with custom Components: mdsvex](https://www.youtube.com/watch?v=VJFkyGd0FEA) by hartenfellerdev - [How To Add Confetti for Svelte and Sveltekit 🎉](https://www.youtube.com/watch?v=gXtWSb94704) and [Make Your SvelteKit Code 10x Faster With Rust and WebAssembly](https://www.youtube.com/watch?v=Vn2bIv_J_UE) by SvelteRust - _To Read_ + - [SvelteJS: My ecosystem is bigger than yours](https://hackmd.io/@roguegpu/r1RKQMdt3) by roguegpu - [Avoid shared state on the server in SvelteKit](https://blog.aakashgoplani.in/avoid-shared-state-on-the-server-in-sveltekit) by Aakash Goplani - [SvelteKit Fontaine: Reduce Custom Font CLS](https://rodneylab.com/sveltekit-fontaine/) by Rodney Lab @@ -74,8 +77,8 @@ _To Read_ - [Deploying Sveltekit on IIS](https://dev.to/nnutnonn/deploying-sveltekit-on-iis--5gf6) by Nutchapon Makelai - [Streamlined Authentication and Secrets Management](https://eman.hashnode.dev/streamlined-authentication-and-secrets-management) by Eman - **Libraries, Tools & Components** + - [Melt UI](https://github.com/melt-ui/melt-ui) is a set of headless, accessible component builders for Svelte - [MDsveX](https://github.com/pngwn/MDsveX/releases/tag/mdsvex%400.11.0) has been updated to work with Svelte 4 - [Svelte Sonner](https://github.com/wobsoriano/svelte-sonner) is an opinionated toast component for Svelte @@ -85,7 +88,7 @@ _To Read_ - [better-svelte-writable](https://github.com/tnthung/better-svelte-writable) provides a type-safe writable which gives you more control over the container - [Svetch.ts](https://github.com/Bewinxed/svetch#readme) is a client/types/schema/docs generator for your API endpoints - [sveltekit-localize-url](https://github.com/rinart73/sveltekit-localize-url) handles URL localization and routing -- [elegua](https://github.com/howesteve/elegua) is a small, reactive PWA router for Svelte +- [elegua](https://github.com/howesteve/elegua) is a small, reactive PWA router for Svelte - [Molly](https://github.com/renefournier/molly/tree/main) is a bash script and npm module that helps you clean up unused Svelte components in your project - [sveltekit-bot](https://github.com/begoon/sveltekit-bot) is a Telegram bot made with SvelteKit and Vercel diff --git a/documentation/blog/2023-08-31-view-transitions.md b/documentation/blog/2023-08-31-view-transitions.md new file mode 100644 index 000000000000..3366955ea458 --- /dev/null +++ b/documentation/blog/2023-08-31-view-transitions.md @@ -0,0 +1,265 @@ +--- +title: Unlocking view transitions in SvelteKit 1.24 +description: Streamlined page transitions with onNavigate +author: Geoff Rich +authorURL: https://geoffrich.net +--- + +The [view transitions API](https://developer.chrome.com/docs/web-platform/view-transitions/) has been sweeping the web development world lately, and for good reason. It streamlines the process of animating between two page states, which is especially useful for page transitions. + +However, until now, you couldn’t easily use this API in a SvelteKit app, since it was difficult to slot into the right place in the navigation lifecycle. SvelteKit 1.24 brought a new [`onNavigate`](https://kit.svelte.dev/docs/modules#$app-navigation-onnavigate) lifecycle hook to make view transitions integration much easier – let’s dive in. + +## How view transitions work + +You can trigger a view transition by calling `document.startViewTransition` and passing a callback that updates the DOM somehow. For our purposes today, SvelteKit will update the DOM as the user navigates. Once the callback finishes, the browser will transition to the new page state — by default, it does a crossfade between the old and the new states. + +```js +// @errors: 2339 +const domUpdate = async () => {}; +// ---cut--- +document.startViewTransition(async () => { + await domUpdate(); // mock function for demonstration purposes +}); +``` + +Behind the scenes, the browser does something really clever. When the transition starts, it captures the current state of the page and takes a screenshot. It then holds that screenshot in place while the DOM is updating. Once the DOM has finished updating, it captures the new state, and animates between the two states. + +While it’s only implemented in Chrome (and other Chromium-based browsers) for now, [WebKit is also in favor](https://github.com/WebKit/standards-positions/issues/48#issuecomment-1679760489) of it. Even if you’re on an unsupported browser, it’s a perfect candidate for progressive enhancement since we can always fall back to a non-animated navigation. + +It’s important to note that view transitions is a browser API, not a SvelteKit one. `onNavigate` is the only SvelteKit-specific API we’ll use today. Everything else can be used wherever you write for the web! For more on the view transitions API, I highly recommend the [Chrome explainer](https://developer.chrome.com/docs/web-platform/view-transitions/) by Jake Archibald. + +## How `onNavigate` works + +Before learning how to write view transitions, let's highlight the function that makes it all possible: [`onNavigate`](https://kit.svelte.dev/docs/modules#$app-navigation-onnavigate). + +Until recently, SvelteKit had two navigation lifecycle functions: [`beforeNavigate`](https://kit.svelte.dev/docs/modules#$app-navigation-beforenavigate), which fires before a navigation starts, and [`afterNavigate`](https://kit.svelte.dev/docs/modules#$app-navigation-afternavigate), which fires after the page has been updated following a navigation. SvelteKit 1.24 introduces a third: `onNavigate`, which will fire on every navigation, immediately before the new page is rendered. Importantly, it will run _after_ any data loading for the page has completed – since starting a view transition prevents any interaction with the page, we want to start it as late as possible. + +You can also return a promise from `onNavigate`, which will suspend the navigation until it resolves. This will let us wait to complete the navigation until the view transition has started. + +```js +// @errors: 2304 7006 +function delayNavigation() { + return new Promise((res) => setTimeout(res, 100)); +} + +onNavigate(async (navigation) => { + // do some work immediately before the navigation completes + + // optionally return a promise to delay navigation until it resolves + return delayNavigation(); +}); +``` + +With that out of the way, let's see how you can use view transitions in your SvelteKit app. + +## Getting started with view transitions + +The best way to see view transitions in action is to try it yourself. You can spin up the SvelteKit demo app by running `npm create svelte@latest` in your local terminal, or in your browser on [StackBlitz](https://sveltekit.new). Make sure to use a browser that supports the view transitions API. Once you have the app running, add the following to the script block in `src/routes/+layout.svelte`. + +```js +// @errors: 2305 7006 2339 2810 +import { onNavigate } from '$app/navigation'; + +onNavigate((navigation) => { + if (!document.startViewTransition) return; + + return new Promise((resolve) => { + document.startViewTransition(async () => { + resolve(); + await navigation.complete; + }); + }); +}); +``` + +With that, every navigation that occurs will trigger a view transition. You can already see this in action – by default, the browser will crossfade between the old and new pages. + + + +
+How the code works + +This code may look a bit intimidating – if you're curious, I can break it down line-by-line, but for now it’s enough to know that adding it will allow you to interact with the view transitions API during navigation. + +As mentioned above, the `onNavigate` callback will run immediately before the new page is rendered after a navigation. Inside the callback, we check if `document.startViewTransition` exists. If it doesn’t (i.e. the browser doesn’t support it), we exit early. + +We then return a promise to delay completing the navigation until the view transition has started. We use a [promise constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/Promise) so that we can control when the promise resolves. + +```js +// @errors: 1108 +return new Promise((resolve) => { + document.startViewTransition(async () => { + resolve(); + await navigation.complete; + }); +}); +``` + +Inside the promise constructor, we start the view transition. Inside the view transition callback we resolve the promise we just returned, which indicates to SvelteKit that it should finish the navigation. It’s important that the navigation waits to finish until _after_ we start the view transition – the browser needs to snapshot the old state so it can transition to the new state. + +Finally, inside the view transition callback we wait for SvelteKit to finish the navigation by awaiting `navigation.complete`. Once `navigation.complete` resolves, the new page has been loaded into the DOM and the browser can animate between the two states. + +It’s a bit of a mouthful, but by not abstracting it we allow you to interact with the view transition directly and make any customizations you require. + +
+ +## Customizing the transition with CSS + +We can also customize this page transition using CSS animation. In the style block of your `+layout.svelte`, add the following CSS rules. + +```css +@keyframes fade-in { + from { + opacity: 0; + } +} + +@keyframes fade-out { + to { + opacity: 0; + } +} + +@keyframes slide-from-right { + from { + transform: translateX(30px); + } +} + +@keyframes slide-to-left { + to { + transform: translateX(-30px); + } +} + +:root::view-transition-old(root) { + animation: + 90ms cubic-bezier(0.4, 0, 1, 1) both fade-out, + 300ms cubic-bezier(0.4, 0, 0.2, 1) both slide-to-left; +} + +:root::view-transition-new(root) { + animation: + 210ms cubic-bezier(0, 0, 0.2, 1) 90ms both fade-in, + 300ms cubic-bezier(0.4, 0, 0.2, 1) both slide-from-right; +} +``` + +Now when you navigate between pages, the old page will fade out and slide to the left, and the new page will fade in and slide from the right. These particular animation styles come from Jake Archibald’s excellent [Chrome Developers article on view transitions](https://developer.chrome.com/docs/web-platform/view-transitions/), which is well worth a read if you want to understand everything you can do with this API. + +Note that we have to add `:root` before the `::view-transition` pseudoelements – these elements are only on the root of the document, so we don’t want Svelte to [scope them](/docs/svelte-components#style) to the component. + +You might have noticed that the entire page slides in and out, even though the header is the same on both the old and new page. To make for a smoother transition, we can give the header a unique `view-transition-name` so that it is animated separately from the rest of the page. In `src/routes/Header.svelte`, find the `header` CSS selector in the style block and add a view transition name. + +```css +header { + display: flex; + justify-content: space-between; + view-transition-name: header; +} +``` + +Now, the header will not transition in and out on navigation, but the rest of the page will. + + + +
+Fixing the types + +Since `startViewTransition` is not supported by all browsers, your IDE may not know that it exists. To make the errors go away and get the correct typings, add the following to your `app.d.ts`: + +```ts +declare global { + // preserve any customizations you have here + namespace App { + // interface Error {} + // interface Locals {} + // interface PageData {} + // interface Platform {} + } + + // add these lines + interface ViewTransition { + updateCallbackDone: Promise; + ready: Promise; + finished: Promise; + skipTransition: () => void; + } + + interface Document { + startViewTransition(updateCallback: () => Promise): ViewTransition; + } +} + +export {}; +``` + +
+ +## Transitioning individual elements + +We just saw how giving an element a `view-transition-name` separates it out from the rest of the page's animation. Setting a `view-transition-name` also instructs the browser to smoothly animate it to its new position after the transition completes. The `view-transition-name` acts as a unique identifier so the browser can identify matching elements from the old and new states. + +Let’s see what that looks like – our demo app’s navigation has a small triangle indicating the active page. Right now, it abruptly appears in the new position after we navigate. Let’s give it a `view-transition-name` so the browser animates it to its new position instead. + +Inside `src/routes/Header.svelte`, find the CSS rule creating the active page indicator and give it a `view-transition-name`: + +```css +li[aria-current='page']::before { + /* other existing rules */ + view-transition-name: active-page; +} +``` + +By adding that single line, the indicator will now smoothly slide to its new position instead of jumping. + + + +(It might be easy to miss the difference – look at the small moving triangle indicator at the top of the screen!) + +## Reduced motion + +It’s important to respect our users’ [motion preferences](https://web.dev/prefers-reduced-motion/) while implementing animation on the web. Just because you can implement an extreme page transition doesn’t mean you should. To disable all page transitions for users who prefer reduced motion, you can add the following to the global `styles.css`: + +```css +@media (prefers-reduced-motion) { + ::view-transition-group(*), + ::view-transition-old(*), + ::view-transition-new(*) { + animation: none !important; + } +} +``` + +While this may be the safest option, reduced motion does not necessarily mean no animation. Instead, you could consider your view transitions on a case-by-case basis. For instance, maybe we disable the sliding animation, but leave the default crossfade (which doesn’t involve motion). You can do so by wrapping the `::view-transition` rules you want to disable in a `prefers-reduced-motion: no-preference` media-query: + +```css +@media (prefers-reduced-motion: no-preference) { + :root::view-transition-old(root) { + animation: + 90ms cubic-bezier(0.4, 0, 1, 1) both fade-out, + 300ms cubic-bezier(0.4, 0, 0.2, 1) both slide-to-left; + } + + :root::view-transition-new(root) { + animation: + 210ms cubic-bezier(0, 0, 0.2, 1) 90ms both fade-in, + 300ms cubic-bezier(0.4, 0, 0.2, 1) both slide-from-right; + } +} +``` + +## What’s next? + +As you can see, SvelteKit doesn’t abstract a whole lot about _how_ view transitions work – you’re interacting directly with the browser’s built-in `document.startViewTransition` and `::view-transition` APIs, rather than framework abstractions like those found in Nuxt and Astro. We’re eager to see how people end up using view transitions in SvelteKit apps, and whether it makes sense to add higher level abstractions of our own in future. + +## Resources + +You can find the demo code from this post [on GitHub](https://github.com/geoffrich/sveltekit-onnavigate-demo) and the live version [deployed to Vercel](https://sveltekit-onnavigate-demo.vercel.app/). Here are some other view transitions resources you may find helpful: + +- [MDN view transitions docs](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API) +- [Chrome view transitions API explainer](https://developer.chrome.com/docs/web-platform/view-transitions/) +- [Rich Harris demoing view transitions with onNavigate](https://www.youtube.com/shorts/weOCWOD2UIo) +- [My Svelte Summit video showing how to use view transitions for FLIP animations](https://youtu.be/K95TQ-Yh7Cw) +- [Fruit list demo](https://sveltekit-shared-element-transitions-codelab.vercel.app/fruits) ([source](https://github.com/geoffrich/sveltekit-view-transitions)) +- [Svelte Summit video list demo](https://http-203-svelte.vercel.app/) (based on a [Jake Archibald demo](https://http203-playlist.netlify.app/)) ([source](https://github.com/geoffrich/http-203-svelte)) diff --git a/documentation/blog/2023-09-01-whats-new-in-svelte-september-2023.md b/documentation/blog/2023-09-01-whats-new-in-svelte-september-2023.md new file mode 100644 index 000000000000..f68241735fff --- /dev/null +++ b/documentation/blog/2023-09-01-whats-new-in-svelte-september-2023.md @@ -0,0 +1,98 @@ +--- +title: "What's new in Svelte: September 2023" +description: "New parameters in SvelteKit's redirect and an onNavigate lifecycle function come to life" +author: Dani Sandoval +authorURL: https://dreamindani.com +--- + +Happy September y'all! With all the [sneak peeks at what's coming soon in Svelte 5](https://twitter.com/Rich_Harris/status/1688581184018583558), we thought it'd be best to look back at the last month to see what's shipped and what the community is building with Svelte. + +Before we jump in, a warm welcome to the new Svelte Ambassadors: [@cainux](https://github.com/cainux) and [@grischaerbe](https://github.com/grischaerbe)! Welcome to the crew ⛴️ + +## What's new in Svelte & Language Tools + +- `svelteHTML` has moved from language-tools into Svelte core so that `svelte/element` types will now load correctly (**4.2.0** in Svelte, **107.10.0** in Language Tools) + +## What's new in SvelteKit + +- `URL` is now accepted in the `redirect` function (**1.23.0**, [Docs](https://kit.svelte.dev/docs/modules#sveltejs-kit-redirect), [#10570](https://github.com/sveltejs/kit/pull/10570)) +- Mistyped route filenames will now throw a warning (**1.23.0**, [#10558](https://github.com/sveltejs/kit/pull/10558)) +- The new `onNavigate` lifecycle function enables view transitions - Check out the [blog post](https://svelte.dev/blog/view-transitions) for more info (**1.24.0**, [Docs](https://kit.svelte.dev/docs/modules#app-navigation-onnavigate), [#9605](https://github.com/sveltejs/kit/pull/9605)) + +But that's just the new features! For all the patches and performance updates from this month, check out the [SvelteKit CHANGELOG](https://github.com/sveltejs/kit/blob/master/packages/kit/CHANGELOG.md). You can also find adapter-specific CHANGELOGs in each of [the `adapter` directories](https://github.com/sveltejs/kit/tree/master/packages). + +--- + +## Community Showcase + +**Apps & Sites built with Svelte** + +- [Planet Of The Bugs](https://planetofthebugs.xyz/) allows developers to practice and hone their skill-sets by exposing them to an endless supply of unique, curated issues and bugs from popular open-source projects on Github +- [Minesweeper](https://github.com/ProductionPanic/minesweeper/tree/main) is an Android game built with SvelteKit, Capacitor, TailwindCSS and DaisyUI (check it out on the [Google Play Store](https://play.google.com/store/apps/details?id=com.production.panic.minesweeper&pli=1)) +- [Pendor](https://www.pendor.ai/) is an AI component generator for Svelte +- [Avatars Pro](https://senja.io/testimonial-widgets/avatars-pro) is a social proof widget made for the web +- [Pomodoro Focus](https://github.com/con-dog/pomodoro-focus) is a pomodoro timer browser extension +- [memegen](https://github.com/bhupeshpr25/memegen) is a Firefox web extension that allows users to generate memes using various templates +- [Resgen](https://resgen.app/) is a Chrome extension that tailors resumes based on job descriptions and your experiences +- [Icono Search](https://www.icono-search.com) is an AI-powered video search engine +- [digital-paper](https://github.com/danferns/digital-paper) is a writing app with no backspace or undo +- [Ubuntu 22.04 in Svelte](https://github.com/manhhungpc/ubuntu2204-svelte) aims to replicate the Ubuntu 22.04 desktop experience on the web +- [My Queue](https://www.myqueue.so/) creates a playlist of written articles by turning them into audio stories + +**Learning Resources** +_Featuring Svelte Contributors and Ambassadors_ + +- [Svelte Society - London August 2023](https://www.youtube.com/watch?v=90Psdk5rAnU) +- [Building a Blog using SvelteKit and Nostr as a CMS (Part 1](https://kevinak.se/blog/building-a-blog-using-sveltekit-and-nostr-as-a-cms-part-1-1690807337563)) by Kev +- [Mastering SvelteKit with Geoff Rich | JS Drops](https://www.youtube.com/watch?v=MaF8kRbHbi0) by This Dot Media +- [Using GitHub Contributions To Flex On The Normies](https://youtu.be/f9fd1L1FEts?si=3hbihW-X5-GKSJxN), [Learn Svelte By Making A Matching Game](https://www.youtube.com/watch?v=w2q9caYXgkg) and [Who Needs API Permission When You Can Use Web Scraping](https://www.youtube.com/watch?v=T-lBPpeokfY) by Joy of Code +- [The missing guide to understanding adapter-static in SvelteKit](https://khromov.se/the-missing-guide-to-understanding-adapter-static-in-sveltekit/) by Stanislav Khromov +- This Week in Svelte: + - [2023 July 28](https://www.youtube.com/watch?v=mvTEQ_C0qRQ) - Screen reader market share, Svelte to plain JS, Web Components + - [2023 Aug 4](https://www.youtube.com/watch?v=Ye8cCJyPZjg) - Svelte 4.1.2, SvelteKit 1.22.4, ES Modules, Types in markup + - [2023 August 11](https://www.youtube.com/watch?v=A8XUaiCVkCI) - Svelte 4.2.0, SvelteKit 1.22.5, How to create Toggle Switches + - [2023 August 18](https://www.youtube.com/watch?v=nJ5Wf3uL7dM) - SvelteKit 1.22.6, accessible form error summaries + - [2023 August 25](https://www.youtube.com/watch?v=JoPzvlBKXXE) - SvelteKit 1.23.0, Bun and SvelteKit, Enhanced search +- Svienna (Svelte Society Vienna) Sessions + - [Ermin Celikovic - You might not need a slider library](https://www.youtube.com/watch?v=dSUmtijkFOc) + - [Lukas Stracke - How to use sentry.io in your SvelteKit App](https://www.youtube.com/watch?v=u41-MtPGH04) + - [Jean-Yves Couet - SvelteKit & Remult... fullstack apps in minutes!](https://www.youtube.com/watch?v=N8d290fTzq8) +- Sirens Sessions + - [Prismic Slice Machines & SvelteKit](https://www.youtube.com/watch?v=19Meb-yMsAg) with Sam Littlefair + - [Medusa and SvelteKit E-Commerce Stack](https://www.youtube.com/watch?v=rVVHxows9dY) with Lacey Pevey + - [Design Systems: Lessons Learned](https://www.youtube.com/watch?v=YHZaiIGSqsE) with Eric Liu + +_To Watch_ + +- [Image optimization in SvelteKit with vite-imagetools](https://www.youtube.com/watch?v=285vSLe9LQ8) by hartenfellerdev +- [Building a Todo App with Rust and SvelteKit: Complete Tutorial](https://www.youtube.com/watch?v=w7is2bCTUg0) and [Stripe Payment In SvelteKit With Dynamic Pricing](https://www.youtube.com/watch?v=o8gvCLgz1vs) by SvelteRust +- [Leaflet maps in SvelteKit like it's 2023 (HowTo)](https://www.youtube.com/watch?v=JFctWXEzFZw) + ShipBit + +_To Read_ + +- [Internationalization in SvelteKit (Series)](https://blog.aakashgoplani.in/series/i18n-in-sveltekit) by Aakash Goplani +- [The easiest Chatbot you will ever build](https://simon-prammer.vercel.app/blog/post/sveltekit-langchain) and [Intro to LangSmith🦜️🛠️](https://simon-prammer.vercel.app/blog/post/langsmith) by Simon Prammer +- [SvelteKit: How to make code-based router, instead of file-based router [August 2023]](https://dev.to/maxcore/sveltekit-how-to-make-code-based-router-instead-of-file-based-router-august-2023-5f9) by Max Core +- [SvelteKit Hydration Gotcha](https://www.captaincodeman.com/sveltekit-hydration-gotcha) by Captain Codeman +- [Automatically generate sitemap.xml in SvelteKit](https://alex-schnabl.medium.com/automatically-generate-sitemap-xml-in-sveltekit-910bd09d17e7) by Alex Schnabl +- [Discovering Svelte: Things I Learned While Using Svelte](https://www.tronic247.com/discovering-svelte-things-i-learned-while-using-svelte/) by Posandu Mapa +- [Typed fetch with Sveltekit and Hono using RPC](https://dev.to/subhendupsingh/typed-fetch-with-sveltekit-and-hono-using-rpc-2clf) by Subhendu Pratap Singh +- [Svelte Context Module Scripts Explained](https://raqueebuddinaziz.com/blog/svelte-context-module-scripts-explained) by raqueebuddin aziz +- [Building with GPT4 and Svelte](https://kvak.io/meoweler) by levmiseri +- [Type-safe User Authentication in SvelteKit with Lucia, Planetscale, and Upstash Redis](https://upstash.com/blog/lucia-sveltekit) by Chris Jayden +- [Document Svelte Projects with HTML and JSDoc Comments](https://blog.robino.dev/posts/doc-comments-svelte) by Ross Robino + +**Libraries, Tools & Components** + +- [Carta](https://github.com/BearToCode/carta-md) is a lightweight, fast and extensible Svelte Markdown editor and viewer, based on Marked +- [Threlte](https://threlte.xyz/), the 3D framework built from Svelte and Three.js has released version 6 +- [vite-plugin-web-extension](https://vite-plugin-web-extension.aklinker1.io/guide/frontend-frameworks.html#svelte-integration) works great with Svelte to make building browser extensions easier +- [Salvia-kit Svelte Dashboards](https://github.com/salvia-kit/svelte-dashboards) contains 10 free dashboard templates for SvelteKit +- [drab](https://github.com/rossrobino/drab) is an Unstyled Svelte component library +- [svelte-img-previewer](https://www.npmjs.com/package/svelte-img-previewer?activeTab=readme) is a tool for displaying images from input file types in Svelte +- [sveltekit-search-params](https://github.com/paoloricciuti/sveltekit-search-params) describes itself as the fastest way to read AND write from query search params in SvelteKit + +That's it for this month! Feel free to let us know if we missed anything on [Reddit](https://www.reddit.com/r/sveltejs/) or [Discord](https://discord.gg/svelte). + +Until next time 👋 diff --git a/documentation/blog/2023-09-20-runes.md b/documentation/blog/2023-09-20-runes.md new file mode 100644 index 000000000000..cb72feda067a --- /dev/null +++ b/documentation/blog/2023-09-20-runes.md @@ -0,0 +1,223 @@ +--- +title: Introducing runes +description: "Rethinking 'rethinking reactivity'" +author: The Svelte team +authorURL: / +--- + +In 2019, Svelte 3 turned JavaScript into a [reactive language](/blog/svelte-3-rethinking-reactivity). Svelte is a web UI framework that uses a compiler to turn declarative component code like this... + +```svelte + + + +``` + +...into tightly optimized JavaScript that updates the document when state like `count` changes. Because the compiler can 'see' where `count` is referenced, the generated code is [highly efficient](/blog/virtual-dom-is-pure-overhead), and because we're hijacking syntax like `let` and `=` instead of using cumbersome APIs, you can [write less code](/blog/write-less-code). + +A common piece of feedback we get is 'I wish I could write all my JavaScript like this'. When you're used to things inside components magically updating, going back to boring old procedural code feels like going from colour to black-and-white. + +Svelte 5 changes all that with _runes_, which unlock _universal, fine-grained reactivity_. + +
+
+
+ +
+ +
Introducing runes
+
+
+ +## Before we begin + +Even though we're changing how things work under the hood, Svelte 5 should be a drop-in replacement for almost everyone. The new features are opt-in — your existing components will continue to work. + +We don't yet have a release date for Svelte 5. What we're showing you here is a work-in-progress that is likely to change! + +## What are runes? + +> **rune** /ro͞on/ _noun_ +> +> A letter or mark used as a mystical or magic symbol. + +Runes are symbols that influence the Svelte compiler. Whereas Svelte today uses `let`, `=`, the [`export`](https://learn.svelte.dev/tutorial/declaring-props) keyword and the [`$:`](https://learn.svelte.dev/tutorial/reactive-declarations) label to mean specific things, runes use _function syntax_ to achieve the same things and more. + +For example, to declare a piece of reactive state, we can use the `$state` rune: + +```diff + + + +``` + +At first glance, this might seem like a step back — perhaps even [un-Svelte-like](https://twitter.com/stolinski/status/1438173489479958536). Isn't it better if `let count` is reactive by default? + +Well, no. The reality is that as applications grow in complexity, figuring out which values are reactive and which aren't can get tricky. And the heuristic only works for `let` declarations at the top level of a component, which can cause confusion. Having code behave one way inside `.svelte` files and another inside `.js` can make it hard to refactor code, for example if you need to turn something into a [store](https://learn.svelte.dev/tutorial/writable-stores) so that you can use it in multiple places. + +## Beyond components + +With runes, reactivity extends beyond the boundaries of your `.svelte` files. Suppose we wanted to encapsulate our counter logic in a way that could be reused between components. Today, you would use a [custom store](https://learn.svelte.dev/tutorial/custom-stores) in a `.js` or `.ts` file: + +```js +import { writable } from 'svelte/store'; + +export function createCounter() { + const { subscribe, update } = writable(0); + + return { + subscribe, + increment: () => update((n) => n + 1) + }; +} +``` + +Because this implements the _store contract_ — the returned value has a `subscribe` method — we can reference the store value by prefixing the store name with `$`: + +```diff + + +- +``` + +This works, but it's pretty weird! We've found that the store API can get rather unwieldy when you start doing more complex things. + +With runes, things get much simpler: + +```diff +-import { writable } from 'svelte/store'; + +export function createCounter() { +- const { subscribe, update } = writable(0); ++ let count = $state(0); + + return { +- subscribe, +- increment: () => update((n) => n + 1) ++ get count() { return count }, ++ increment: () => count += 1 + }; +} +``` + +```diff + + + +``` + +Note that we're using a [get property](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get) in the returned object, so that `counter.count` always refers to the current value rather than the value at the time the function was called. + +## Runtime reactivity + +Today, Svelte uses _compile-time reactivity_. This means that if you have some code that uses the `$:` label to re-run automatically when dependencies change, those dependencies are determined when Svelte compiles your component: + +```svelte + +``` + +This works well... until it doesn't. Suppose we refactored the code above: + +```js +// @errors: 7006 2304 +const multiplyByHeight = (width) => width * height; +$: area = multiplyByHeight(width); +``` + +Because the `$: area = ...` declaration can only 'see' `width`, it won't be recalculated when `height` changes. As a result, code is hard to refactor, and understanding the intricacies of when Svelte chooses to update which values can become rather tricky beyond a certain level of complexity. + +Svelte 5 introduces the `$derived` and `$effect` runes, which instead determine the dependencies of their expressions when they are evaluated: + +```svelte + +``` + +As with `$state`, `$derived` and `$effect` can also be used in your `.js` and `.ts` files. + +## Signal boost + +Like every other framework, we've come to the realisation that [Knockout](https://knockoutjs.com/) was right all along. + +Svelte 5's reactivity is powered by _signals_, which are essentially [what Knockout was doing in 2010](https://dev.to/this-is-learning/the-evolution-of-signals-in-javascript-8ob). More recently, signals have been popularised by [Solid](https://www.solidjs.com/) and adopted by a multitude of other frameworks. + +We're doing things a bit differently though. In Svelte 5, signals are an under-the-hood implementation detail rather than something you interact with directly. As such, we don't have the same API design constraints, and can maximise both efficiency _and_ ergonomics. For example, we avoid the type narrowing issues that arise when values are accessed by function call, and when compiling in server-side rendering mode we can ditch the signals altogether, since on the server they're nothing but overhead. + +Signals unlock _fine-grained reactivity_, meaning that (for example) changes to a value inside a large list needn't invalidate all the _other_ members of the list. As such, Svelte 5 is ridonkulously fast. + +## Simpler times ahead + +Runes are an additive feature, but they make a whole bunch of existing concepts obsolete: + +- the difference between `let` at the top level of a component and everywhere else +- `export let` +- `$:`, with all its attendant quirks +- different behaviour between ` - + - + ``` Listening for component events looks the same as listening for DOM events: @@ -44,6 +40,7 @@ As with DOM events, if the `on:` directive is used without a value, the event wi ## --style-props ```svelte + --style-props="anycssvalue" ``` @@ -78,7 +75,6 @@ For SVG namespace, the example above desugars into using `` instead: Svelte's CSS Variables support allows for easily themeable components: ```svelte - diff --git a/documentation/examples/21-miscellaneous/02-immutable-data/MutableTodo.svelte b/documentation/examples/21-miscellaneous/02-immutable-data/MutableTodo.svelte index f92468ab79f7..fb960ead91bd 100644 --- a/documentation/examples/21-miscellaneous/02-immutable-data/MutableTodo.svelte +++ b/documentation/examples/21-miscellaneous/02-immutable-data/MutableTodo.svelte @@ -21,8 +21,8 @@ diff --git a/documentation/tutorial/02-reactivity/01-reactive-assignments/app-a/App.svelte b/documentation/tutorial/02-reactivity/01-reactive-assignments/app-a/App.svelte index 8b1569bffb29..76483b567a9c 100644 --- a/documentation/tutorial/02-reactivity/01-reactive-assignments/app-a/App.svelte +++ b/documentation/tutorial/02-reactivity/01-reactive-assignments/app-a/App.svelte @@ -13,6 +13,6 @@ diff --git a/documentation/tutorial/02-reactivity/01-reactive-assignments/app-b/App.svelte b/documentation/tutorial/02-reactivity/01-reactive-assignments/app-b/App.svelte index d51ca2e06829..17e7c07312c4 100644 --- a/documentation/tutorial/02-reactivity/01-reactive-assignments/app-b/App.svelte +++ b/documentation/tutorial/02-reactivity/01-reactive-assignments/app-b/App.svelte @@ -13,6 +13,6 @@ diff --git a/documentation/tutorial/04-logic/03-else-if-blocks/app-a/App.svelte b/documentation/tutorial/04-logic/03-else-if-blocks/app-a/App.svelte index 2b740dbf9b57..fb41a894f9d2 100644 --- a/documentation/tutorial/04-logic/03-else-if-blocks/app-a/App.svelte +++ b/documentation/tutorial/04-logic/03-else-if-blocks/app-a/App.svelte @@ -4,8 +4,6 @@ {#if x > 10}

{x} is greater than 10

-{:else if 5 > x} -

{x} is less than 5

{:else} -

{x} is between 5 and 10

+

{x} is between 0 and 10

{/if} diff --git a/documentation/tutorial/04-logic/05-keyed-each-blocks/app-a/Thing.svelte b/documentation/tutorial/04-logic/05-keyed-each-blocks/app-a/Thing.svelte index eb3a6f076dc7..e1b0bd43e742 100644 --- a/documentation/tutorial/04-logic/05-keyed-each-blocks/app-a/Thing.svelte +++ b/documentation/tutorial/04-logic/05-keyed-each-blocks/app-a/Thing.svelte @@ -34,7 +34,7 @@ padding: 0.2em 1em 0.3em; text-align: center; border-radius: 0.2em; - color:#333333; + color: #333333; background-color: #ffdfd3; } diff --git a/documentation/tutorial/04-logic/05-keyed-each-blocks/app-b/Thing.svelte b/documentation/tutorial/04-logic/05-keyed-each-blocks/app-b/Thing.svelte index eb3a6f076dc7..e1b0bd43e742 100644 --- a/documentation/tutorial/04-logic/05-keyed-each-blocks/app-b/Thing.svelte +++ b/documentation/tutorial/04-logic/05-keyed-each-blocks/app-b/Thing.svelte @@ -34,7 +34,7 @@ padding: 0.2em 1em 0.3em; text-align: center; border-radius: 0.2em; - color:#333333; + color: #333333; background-color: #ffdfd3; } diff --git a/documentation/tutorial/07-lifecycle/03-update/app-a/App.svelte b/documentation/tutorial/07-lifecycle/03-update/app-a/App.svelte index 1677825de4ab..235b53889f29 100644 --- a/documentation/tutorial/07-lifecycle/03-update/app-a/App.svelte +++ b/documentation/tutorial/07-lifecycle/03-update/app-a/App.svelte @@ -31,22 +31,28 @@ const reply = eliza.transform(text); - setTimeout(() => { - comments = comments.concat({ - author: 'eliza', - text: '...', - placeholder: true - }); - - setTimeout(() => { - comments = comments - .filter((comment) => !comment.placeholder) - .concat({ - author: 'eliza', - text: reply - }); - }, 500 + Math.random() * 500); - }, 200 + Math.random() * 200); + setTimeout( + () => { + comments = comments.concat({ + author: 'eliza', + text: '...', + placeholder: true + }); + + setTimeout( + () => { + comments = comments + .filter((comment) => !comment.placeholder) + .concat({ + author: 'eliza', + text: reply + }); + }, + 500 + Math.random() * 500 + ); + }, + 200 + Math.random() * 200 + ); } } diff --git a/documentation/tutorial/07-lifecycle/03-update/app-b/App.svelte b/documentation/tutorial/07-lifecycle/03-update/app-b/App.svelte index 644810a35eb5..7afb5eb42776 100644 --- a/documentation/tutorial/07-lifecycle/03-update/app-b/App.svelte +++ b/documentation/tutorial/07-lifecycle/03-update/app-b/App.svelte @@ -31,22 +31,28 @@ const reply = eliza.transform(text); - setTimeout(() => { - comments = comments.concat({ - author: 'eliza', - text: '...', - placeholder: true - }); - - setTimeout(() => { - comments = comments - .filter((comment) => !comment.placeholder) - .concat({ - author: 'eliza', - text: reply - }); - }, 500 + Math.random() * 500); - }, 200 + Math.random() * 200); + setTimeout( + () => { + comments = comments.concat({ + author: 'eliza', + text: '...', + placeholder: true + }); + + setTimeout( + () => { + comments = comments + .filter((comment) => !comment.placeholder) + .concat({ + author: 'eliza', + text: reply + }); + }, + 500 + Math.random() * 500 + ); + }, + 200 + Math.random() * 200 + ); } } diff --git a/documentation/tutorial/10-transitions/09-key-blocks/text.md b/documentation/tutorial/10-transitions/09-key-blocks/text.md index 0c3c2995a5f0..4154ce5eb676 100644 --- a/documentation/tutorial/10-transitions/09-key-blocks/text.md +++ b/documentation/tutorial/10-transitions/09-key-blocks/text.md @@ -6,9 +6,9 @@ Key blocks destroy and recreate their contents when the value of an expression c ```svelte {#key number} - - {number} - + + {number} + {/key} ``` diff --git a/documentation/tutorial/14-composition/05-slot-props/app-a/App.svelte b/documentation/tutorial/14-composition/05-slot-props/app-a/App.svelte index 9985963d8370..dcf0dacae517 100644 --- a/documentation/tutorial/14-composition/05-slot-props/app-a/App.svelte +++ b/documentation/tutorial/14-composition/05-slot-props/app-a/App.svelte @@ -17,7 +17,7 @@ padding: 1em; margin: 0 0 1em 0; background-color: #eee; - color: black; + color: black; } .active { diff --git a/documentation/tutorial/14-composition/05-slot-props/app-b/App.svelte b/documentation/tutorial/14-composition/05-slot-props/app-b/App.svelte index 4364e013fad0..024de304dcfc 100644 --- a/documentation/tutorial/14-composition/05-slot-props/app-b/App.svelte +++ b/documentation/tutorial/14-composition/05-slot-props/app-b/App.svelte @@ -37,7 +37,7 @@ padding: 1em; margin: 0 0 1em 0; background-color: #eee; - color: black; + color: black; } .active { diff --git a/package.json b/package.json index 4d22d9642a55..9a15be62e658 100644 --- a/package.json +++ b/package.json @@ -4,31 +4,43 @@ "description": "monorepo for svelte and friends", "private": true, "type": "module", + "license": "MIT", + "packageManager": "pnpm@8.6.12", + "engines": { + "pnpm": "^8.0.0" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/sveltejs/svelte.git" + }, "scripts": { - "test": "pnpm test -r --filter=./packages/*", "build": "pnpm -r --filter=./packages/* build", "build:sites": "pnpm -r --filter=./sites/* build", + "preview-site": "npm run build --prefix sites/svelte-5-preview", "check": "cd packages/svelte && pnpm build && cd ../../ && pnpm -r check", - "lint": "cd packages/svelte && pnpm build && cd ../../ && pnpm -r lint", - "format": "pnpm -r format", + "format": "prettier --write --plugin prettier-plugin-svelte .", + "lint": "prettier --check --plugin prettier-plugin-svelte . && eslint ./", + "test": "vitest run --coverage", + "test-output": "vitest run --reporter=json --outputFile=sites/svelte-5-preview/src/routes/status/results.json", "changeset:version": "changeset version && pnpm -r generate:version && git add --all", "changeset:publish": "changeset publish" }, - "repository": { - "type": "git", - "url": "git+https://github.com/sveltejs/svelte.git" - }, - "license": "MIT", "devDependencies": { "@changesets/cli": "^2.26.1", "@svitejs/changesets-changelog-github-compact": "^1.1.0", - "@typescript-eslint/eslint-plugin": "^5.60.0", - "eslint": "^8.44.0", - "eslint-plugin-svelte": "^2.32.2", - "eslint-plugin-unicorn": "^47.0.0", + "@sveltejs/eslint-config": "^6.0.4", + "@types/node": "^18.18.8", + "@typescript-eslint/eslint-plugin": "^5.22.0", + "@vitest/coverage-v8": "^0.34.6", + "concurrently": "^8.2.0", + "cross-env": "^7.0.3", + "eslint": "^8.49.0", + "eslint-plugin-lube": "^0.1.7", + "jsdom": "22.0.0", "playwright": "^1.35.1", - "prettier": "^2.8.8", - "prettier-plugin-svelte": "^2.10.1" - }, - "packageManager": "pnpm@8.6.3" + "prettier": "^3.0.1", + "prettier-plugin-svelte": "^3.0.3", + "typescript": "^5.2.2", + "vitest": "^0.34.6" + } } diff --git a/packages/playground/.gitignore b/packages/playground/.gitignore deleted file mode 100644 index 0212d8b6cea4..000000000000 --- a/packages/playground/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -dist -dist-ssr -*.local diff --git a/packages/playground/README.md b/packages/playground/README.md deleted file mode 100644 index e86c6b2da034..000000000000 --- a/packages/playground/README.md +++ /dev/null @@ -1,9 +0,0 @@ -You may use this package to experiment with your changes to Svelte. - -To prevent any changes you make in this directory from being accidentally committed, run `git update-index --skip-worktree ./**/*.*` in this directory. - -If you would actually like to make some changes to the files here for everyone then run `git update-index --no-skip-worktree ./**/*.*` before committing. - -If you're using VS Code, you can use the "Playground: Full" launch configuration to run the playground and attach the debugger to both the compiler and the browser. This will SSR the component and then also hydrate it on the client side using rollup to bundle any other imports. - -You can also just compile the `App.svelte` file by running `node compile.js` if you'd like to check some compiler behaviour in isolation. diff --git a/packages/playground/compile.js b/packages/playground/compile.js deleted file mode 100644 index 8b6dac9f1a7f..000000000000 --- a/packages/playground/compile.js +++ /dev/null @@ -1,6 +0,0 @@ -import { readFileSync } from 'node:fs'; -import { compile } from '../svelte/src/compiler/index.js'; - -const code = readFileSync('src/App.svelte', 'utf8'); - -console.log(compile(code)); diff --git a/packages/playground/jsconfig.json b/packages/playground/jsconfig.json deleted file mode 100644 index ba142a7d31d6..000000000000 --- a/packages/playground/jsconfig.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "compilerOptions": { - "moduleResolution": "Node", - "target": "ESNext", - "module": "ESNext", - /** - * svelte-preprocess cannot figure out whether you have - * a value or a type, so tell TypeScript to enforce using - * `import type` instead of `import` for Types. - */ - "verbatimModuleSyntax": true, - "isolatedModules": true, - "resolveJsonModule": true, - /** - * To have warnings / errors of the Svelte compiler at the - * correct position, enable source maps by default. - */ - "sourceMap": true, - "esModuleInterop": true, - "skipLibCheck": true, - "forceConsistentCasingInFileNames": true, - /** - * Typecheck JS in `.svelte` and `.js` files by default. - * Disable this if you'd like to use dynamic types. - */ - "checkJs": true - }, - /** - * Use global.d.ts instead of compilerOptions.types - * to avoid limiting type declarations. - */ - "include": ["src/**/*.d.ts", "src/**/*.js", "src/**/*.svelte"] -} diff --git a/packages/playground/package.json b/packages/playground/package.json deleted file mode 100644 index d90d5298cb01..000000000000 --- a/packages/playground/package.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "playground", - "private": true, - "version": "0.0.0", - "type": "module", - "scripts": { - "dev": "node --watch start.js" - }, - "devDependencies": { - "rollup": "^3.25.1", - "rollup-plugin-serve": "^2.0.2", - "svelte": "workspace:*" - } -} diff --git a/packages/playground/src/App.svelte b/packages/playground/src/App.svelte deleted file mode 100644 index b3c16eec67ce..000000000000 --- a/packages/playground/src/App.svelte +++ /dev/null @@ -1,7 +0,0 @@ - - -
- Hello world! -
\ No newline at end of file diff --git a/packages/playground/src/entry-client.js b/packages/playground/src/entry-client.js deleted file mode 100644 index e62bbf2eb783..000000000000 --- a/packages/playground/src/entry-client.js +++ /dev/null @@ -1,24 +0,0 @@ -import App from './App.svelte'; - -new App({ - target: document.getElementById('app'), - hydrate: true -}); - -function get_version() { - return fetch('/version.json').then((r) => r.json()); -} - -let prev = await get_version(); - -// Mom: We have live reloading at home -// Live reloading at home: -while (true) { - await new Promise((r) => setTimeout(r, 2500)); - try { - const version = await get_version(); - if (prev !== version) { - window.location.reload(); - } - } catch {} -} diff --git a/packages/playground/src/entry-server.js b/packages/playground/src/entry-server.js deleted file mode 100644 index 7402e1e9add2..000000000000 --- a/packages/playground/src/entry-server.js +++ /dev/null @@ -1,6 +0,0 @@ -import App from './App.svelte'; - -export function render() { - // @ts-ignore - return App.render(); -} diff --git a/packages/playground/src/lib/Counter.svelte b/packages/playground/src/lib/Counter.svelte deleted file mode 100644 index e45f90310979..000000000000 --- a/packages/playground/src/lib/Counter.svelte +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/packages/playground/src/template.html b/packages/playground/src/template.html deleted file mode 100644 index 2cc688066ff3..000000000000 --- a/packages/playground/src/template.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - <!--app-title--> - - - -
- - - diff --git a/packages/playground/start.js b/packages/playground/start.js deleted file mode 100644 index af37a40e2607..000000000000 --- a/packages/playground/start.js +++ /dev/null @@ -1,101 +0,0 @@ -import { readFileSync, writeFileSync } from 'node:fs'; -import path from 'node:path'; -import { fileURLToPath } from 'node:url'; -import { watch } from 'rollup'; -import serve from 'rollup-plugin-serve'; -import * as svelte from '../svelte/src/compiler/index.js'; - -const __dirname = fileURLToPath(new URL('.', import.meta.url)); - -/** @returns {import('rollup').Plugin}*/ -function create_plugin(ssr = false) { - return { - name: 'custom-svelte-ssr-' + ssr, - resolveId(id) { - if (id === 'svelte') { - return path.resolve( - __dirname, - ssr ? '../svelte/src/runtime/ssr.js' : '../svelte/src/runtime/index.js' - ); - } else if (id.startsWith('svelte/')) { - return path.resolve(__dirname, `../svelte/src/runtime/${id.slice(7)}/index.js`); - } - }, - transform(code, id) { - code = code.replaceAll('import.meta.env.SSR', ssr); - - if (!id.endsWith('.svelte')) { - return { - code, - map: null - }; - } - - const compiled = svelte.compile(code, { - filename: id, - generate: ssr ? 'ssr' : 'dom', - hydratable: true, - css: 'injected' - }); - - return compiled.js; - } - }; -} - -const client_plugin = create_plugin(); -const ssr_plugin = create_plugin(true); - -const watcher = watch([ - { - input: 'src/entry-client.js', - output: { - dir: 'dist', - format: 'esm', - sourcemap: true - }, - plugins: [client_plugin, serve('dist')] - }, - { - input: 'src/entry-server.js', - output: { - dir: 'dist-ssr', - format: 'iife', - indent: false - }, - plugins: [ - ssr_plugin, - { - async generateBundle(_, bundle) { - const result = bundle['entry-server.js']; - const mod = (0, eval)(result.code); - const { html } = mod.render(); - - writeFileSync( - 'dist/index.html', - readFileSync('src/template.html', 'utf-8') - .replace('', html) - .replace('', svelte.VERSION) - ); - writeFileSync('dist/version.json', Date.now().toString()); - } - } - ], - onwarn(warning, handler) { - if (warning.code === 'MISSING_NAME_OPTION_FOR_IIFE_EXPORT') return; - handler(warning); - } - } -]); - -watcher - .on('change', (id) => { - console.log(`changed ${id}`); - }) - .on('event', (event) => { - if (event.code === 'ERROR') { - console.error(event.error); - } else if (event.code === 'BUNDLE_END') { - console.log(`Generated ${event.output} in ${event.duration}ms`); - } - }); diff --git a/packages/svelte/.eslintignore b/packages/svelte/.eslintignore deleted file mode 100644 index 67a89ff12c6d..000000000000 --- a/packages/svelte/.eslintignore +++ /dev/null @@ -1,17 +0,0 @@ -**/_actual.js -**/expected.js -_output -test/*/samples/*/output.js - -# automatically generated -internal_exports.js - -# output files -animate/*.js -esing/*.js -internal/*.js -motion/*.js -store/*.js -transition/*.js -index.js -compiler.js diff --git a/packages/svelte/.eslintrc.cjs b/packages/svelte/.eslintrc.cjs deleted file mode 100644 index e504664b8a61..000000000000 --- a/packages/svelte/.eslintrc.cjs +++ /dev/null @@ -1,7 +0,0 @@ -module.exports = { - root: true, - extends: ['@sveltejs'], - rules: { - '@typescript-eslint/no-non-null-assertion': 'off' - } -}; diff --git a/packages/svelte/.gitignore b/packages/svelte/.gitignore index 2f5d67e7ded7..faa8892951fb 100644 --- a/packages/svelte/.gitignore +++ b/packages/svelte/.gitignore @@ -1,18 +1,12 @@ -*.map -/src/compiler/compile/internal_exports.js -/compiler.cjs -/scratch/ -/test/*/samples/_ -/test/runtime/shards -_actual*.* -_output /types +/compiler.cjs -action.d.ts -animate.d.ts -compiler.d.ts -easing.d.ts -index.d.ts -motion.d.ts -store.d.ts -transition.d.ts +/action.d.ts +/animate.d.ts +/compiler.d.ts +/easing.d.ts +/index.d.ts +/legacy.d.ts +/motion.d.ts +/store.d.ts +/transition.d.ts diff --git a/packages/svelte/.prettierignore b/packages/svelte/.prettierignore deleted file mode 100644 index fef52b1e8f7e..000000000000 --- a/packages/svelte/.prettierignore +++ /dev/null @@ -1,22 +0,0 @@ -/* -!/elements -!/scripts -!/src -src/compiler/compile/internal_exports.js -src/shared/version.js -!/test -!documentation -!sites -sites/svelte.dev/src/lib/generated/*.js -sites/svelte.dev/.svelte-kit -sites/svelte.dev/.vercel -/test/**/*.svelte -/test/**/_expected* -/test/**/_actual* -/test/**/expected* -/test/**/_output -/test/**/shards/*.test.js -/test/hydration/samples/raw-repair/_after.html -/types -!rollup.config.js -!vitest.config.js diff --git a/packages/svelte/CHANGELOG-pre-5.md b/packages/svelte/CHANGELOG-pre-5.md new file mode 100644 index 000000000000..07edffc2b741 --- /dev/null +++ b/packages/svelte/CHANGELOG-pre-5.md @@ -0,0 +1,2926 @@ +# svelte + +## 4.2.3 + +### Patch Changes + +- fix: improve a11y-click-events-have-key-events message ([#9358](https://github.com/sveltejs/svelte/pull/9358)) + +- fix: more robust hydration of html tag ([#9184](https://github.com/sveltejs/svelte/pull/9184)) + +## 4.2.2 + +### Patch Changes + +- fix: support camelCase properties on custom elements ([#9328](https://github.com/sveltejs/svelte/pull/9328)) + +- fix: add missing plaintext-only value to contenteditable type ([#9242](https://github.com/sveltejs/svelte/pull/9242)) + +- chore: upgrade magic-string to 0.30.4 ([#9292](https://github.com/sveltejs/svelte/pull/9292)) + +- fix: ignore trailing comments when comparing nodes ([#9197](https://github.com/sveltejs/svelte/pull/9197)) + +## 4.2.1 + +### Patch Changes + +- fix: update style directive when style attribute is present and is updated via an object prop ([#9187](https://github.com/sveltejs/svelte/pull/9187)) + +- fix: css sourcemap generation with unicode filenames ([#9120](https://github.com/sveltejs/svelte/pull/9120)) + +- fix: do not add module declared variables as dependencies ([#9122](https://github.com/sveltejs/svelte/pull/9122)) + +- fix: handle `svelte:element` with dynamic this and spread attributes ([#9112](https://github.com/sveltejs/svelte/pull/9112)) + +- fix: silence false positive reactive component warning ([#9094](https://github.com/sveltejs/svelte/pull/9094)) + +- fix: head duplication when binding is present ([#9124](https://github.com/sveltejs/svelte/pull/9124)) + +- fix: take custom attribute name into account when reflecting property ([#9140](https://github.com/sveltejs/svelte/pull/9140)) + +- fix: add `indeterminate` to the list of HTMLAttributes ([#9180](https://github.com/sveltejs/svelte/pull/9180)) + +- fix: recognize option value on spread attribute ([#9125](https://github.com/sveltejs/svelte/pull/9125)) + +## 4.2.0 + +### Minor Changes + +- feat: move `svelteHTML` from language-tools into core to load the correct `svelte/element` types ([#9070](https://github.com/sveltejs/svelte/pull/9070)) + +## 4.1.2 + +### Patch Changes + +- fix: allow child element with slot attribute within svelte:element ([#9038](https://github.com/sveltejs/svelte/pull/9038)) + +- fix: Add data-\* to svg attributes ([#9036](https://github.com/sveltejs/svelte/pull/9036)) + +## 4.1.1 + +### Patch Changes + +- fix: `svelte:component` spread props change not picked up ([#9006](https://github.com/sveltejs/svelte/pull/9006)) + +## 4.1.0 + +### Minor Changes + +- feat: add ability to extend custom element class ([#8991](https://github.com/sveltejs/svelte/pull/8991)) + +### Patch Changes + +- fix: ensure `svelte:component` evaluates props once ([#8946](https://github.com/sveltejs/svelte/pull/8946)) + +- fix: remove `let:variable` slot bindings from select binding dependencies ([#8969](https://github.com/sveltejs/svelte/pull/8969)) + +- fix: handle destructured primitive literals ([#8871](https://github.com/sveltejs/svelte/pull/8871)) + +- perf: optimize imports that are not mutated or reassigned ([#8948](https://github.com/sveltejs/svelte/pull/8948)) + +- fix: don't add accessor twice ([#8996](https://github.com/sveltejs/svelte/pull/8996)) + +## 4.0.5 + +### Patch Changes + +- fix: generate type definition with nullable types ([#8924](https://github.com/sveltejs/svelte/pull/8924)) + +## 4.0.4 + +### Patch Changes + +- fix: claim svg tags in raw mustache tags correctly ([#8910](https://github.com/sveltejs/svelte/pull/8910)) + +- fix: repair invalid raw html content during hydration ([#8912](https://github.com/sveltejs/svelte/pull/8912)) + +## 4.0.3 + +### Patch Changes + +- fix: handle falsy srcset values ([#8901](https://github.com/sveltejs/svelte/pull/8901)) + +## 4.0.2 + +### Patch Changes + +- fix: reflect all custom element prop updates back to attribute ([#8898](https://github.com/sveltejs/svelte/pull/8898)) + +- fix: shrink custom element baseline a bit ([#8858](https://github.com/sveltejs/svelte/pull/8858)) + +- fix: use non-destructive hydration for all `@html` tags ([#8880](https://github.com/sveltejs/svelte/pull/8880)) + +- fix: align `disclose-version` exports specification ([#8874](https://github.com/sveltejs/svelte/pull/8874)) + +- fix: check srcset when hydrating to prevent needless requests ([#8868](https://github.com/sveltejs/svelte/pull/8868)) + +## 4.0.1 + +### Patch Changes + +- fix: ensure identifiers in destructuring contexts don't clash with existing ones ([#8840](https://github.com/sveltejs/svelte/pull/8840)) + +- fix: ensure `createEventDispatcher` and `ActionReturn` work with types from generic function parameters ([#8872](https://github.com/sveltejs/svelte/pull/8872)) + +- fix: apply transition to `` with local transition ([#8865](https://github.com/sveltejs/svelte/pull/8865)) + +- fix: relax a11y "no redundant role" rule for li, ul, ol ([#8867](https://github.com/sveltejs/svelte/pull/8867)) + +- fix: remove tsconfig.json from published package ([#8859](https://github.com/sveltejs/svelte/pull/8859)) + +## 4.0.0 + +### Major Changes + +- breaking: Minimum supported Node version is now Node 16 ([#8566](https://github.com/sveltejs/svelte/pull/8566)) + +- breaking: Minimum supported webpack version is now webpack 5 ([#8515](https://github.com/sveltejs/svelte/pull/8515)) + +- breaking: Bundlers must specify the `browser` condition when building a frontend bundle for the browser ([#8516](https://github.com/sveltejs/svelte/pull/8516)) + +- breaking: Minimum supported vite-plugin-svelte version is now 2.4.1. SvelteKit users can upgrade to 1.20.0 or newer to ensure a compatible version ([#8516](https://github.com/sveltejs/svelte/pull/8516)) + +- breaking: Minimum supported `rollup-plugin-svelte` version is now 7.1.5 ([198dbcf](https://github.com/sveltejs/svelte/commit/198dbcf)) + +- breaking: Minimum supported `svelte-loader` is now 3.1.8 ([198dbcf](https://github.com/sveltejs/svelte/commit/198dbcf)) + +- breaking: Minimum supported TypeScript version is now TypeScript 5 (it will likely work with lower versions, but we make no guarantees about that) ([#8488](https://github.com/sveltejs/svelte/pull/8488)) + +- breaking: Remove `svelte/register` hook, CJS runtime version and CJS compiler output ([#8613](https://github.com/sveltejs/svelte/pull/8613)) + +- breaking: Stricter types for `createEventDispatcher` (see PR for migration instructions) ([#7224](https://github.com/sveltejs/svelte/pull/7224)) + +- breaking: Stricter types for `Action` and `ActionReturn` (see PR for migration instructions) ([#7442](https://github.com/sveltejs/svelte/pull/7442)) + +- breaking: Stricter types for `onMount` - now throws a type error when returning a function asynchronously to catch potential mistakes around callback functions + (see PR for migration instructions) ([#8136](https://github.com/sveltejs/svelte/pull/8136)) + +- breaking: Overhaul and drastically improve creating custom elements with Svelte (see PR for list of changes and migration instructions) ([#8457](https://github.com/sveltejs/svelte/pull/8457)) + +- breaking: Deprecate `SvelteComponentTyped` in favor of `SvelteComponent` ([#8512](https://github.com/sveltejs/svelte/pull/8512)) + +- breaking: Make transitions local by default to prevent confusion around page navigations ([#6686](https://github.com/sveltejs/svelte/issues/6686)) + +- breaking: Error on falsy values instead of stores passed to `derived` ([#7947](https://github.com/sveltejs/svelte/pull/7947)) + +- breaking: Custom store implementers now need to pass an `update` function additionally to the `set` function ([#6750](https://github.com/sveltejs/svelte/pull/6750)) + +- breaking: Do not expose default slot bindings to named slots and vice versa ([#6049](https://github.com/sveltejs/svelte/pull/6049)) + +- breaking: Change order in which preprocessors are applied ([#8618](https://github.com/sveltejs/svelte/pull/8618)) + +- breaking: The runtime now makes use of `classList.toggle(name, boolean)` which does not work in very old browsers ([#8629](https://github.com/sveltejs/svelte/pull/8629)) + +- breaking: apply `inert` to outroing elements ([#8628](https://github.com/sveltejs/svelte/pull/8628)) + +- breaking: use `CustomEvent` constructor instead of deprecated `createEvent` method ([#8775](https://github.com/sveltejs/svelte/pull/8775)) + +### Minor Changes + +- Add a way to modify attributes for script/style preprocessors ([#8618](https://github.com/sveltejs/svelte/pull/8618)) + +- Improve hydration speed by adding `data-svelte-h` attribute to detect unchanged HTML elements ([#7426](https://github.com/sveltejs/svelte/pull/7426)) + +- Add `a11y no-noninteractive-element-interactions` rule ([#8391](https://github.com/sveltejs/svelte/pull/8391)) + +- Add `a11y-no-static-element-interactions`rule ([#8251](https://github.com/sveltejs/svelte/pull/8251)) + +- Allow `#each` to iterate over iterables like `Set`, `Map` etc ([#7425](https://github.com/sveltejs/svelte/issues/7425)) + +- Improve duplicate key error for keyed `each` blocks ([#8411](https://github.com/sveltejs/svelte/pull/8411)) + +- Warn about `:` in attributes and props to prevent ambiguity with Svelte directives ([#6823](https://github.com/sveltejs/svelte/issues/6823)) + +- feat: add version info to `window`. You can opt out by setting `discloseVersion` to `false` in the compiler options ([#8761](https://github.com/sveltejs/svelte/pull/8761)) + +- feat: smaller minified output for destructor chunks ([#8763](https://github.com/sveltejs/svelte/pull/8763)) + +### Patch Changes + +- Bind `null` option and input values consistently ([#8312](https://github.com/sveltejs/svelte/issues/8312)) + +- Allow `$store` to be used with changing values including nullish values ([#7555](https://github.com/sveltejs/svelte/issues/7555)) + +- Initialize stylesheet with `/* empty */` to enable setting CSP directive that also works in Safari ([#7800](https://github.com/sveltejs/svelte/pull/7800)) + +- Treat slots as if they don't exist when using CSS adjacent and general sibling combinators ([#8284](https://github.com/sveltejs/svelte/issues/8284)) + +- Fix transitions so that they don't require a `style-src 'unsafe-inline'` Content Security Policy (CSP) ([#6662](https://github.com/sveltejs/svelte/issues/6662)). + +- Explicitly disallow `var` declarations extending the reactive statement scope ([#6800](https://github.com/sveltejs/svelte/pull/6800)) + +- Improve error message when trying to use `animate:` directives on inline components ([#8641](https://github.com/sveltejs/svelte/issues/8641)) + +- fix: export ComponentType from `svelte` entrypoint ([#8578](https://github.com/sveltejs/svelte/pull/8578)) + +- fix: never use html optimization for mustache tags in hydration mode ([#8744](https://github.com/sveltejs/svelte/pull/8744)) + +- fix: derived store types ([#8578](https://github.com/sveltejs/svelte/pull/8578)) + +- Generate type declarations with dts-buddy ([#8578](https://github.com/sveltejs/svelte/pull/8578)) + +- fix: ensure types are loaded with all TS settings ([#8721](https://github.com/sveltejs/svelte/pull/8721)) + +- fix: account for preprocessor source maps when calculating meta info ([#8778](https://github.com/sveltejs/svelte/pull/8778)) + +- chore: deindent cjs output for compiler ([#8785](https://github.com/sveltejs/svelte/pull/8785)) + +- warn on boolean compilerOptions.css ([#8710](https://github.com/sveltejs/svelte/pull/8710)) + +- fix: export correct SvelteComponent type ([#8721](https://github.com/sveltejs/svelte/pull/8721)) + +## 4.0.0-next.3 + +### Patch Changes + +- feat: smaller minified output for destructor chunks ([#8763](https://github.com/sveltejs/svelte/pull/8763)) + +- breaking: use `CustomEvent` constructor instead of deprecated `createEvent` method ([#8775](https://github.com/sveltejs/svelte/pull/8775)) + +- fix: account for preprocessor source maps when calculating meta info ([#8778](https://github.com/sveltejs/svelte/pull/8778)) + +- chore: deindent cjs output for compiler ([#8785](https://github.com/sveltejs/svelte/pull/8785)) + +- feat: add version info to `window`. You can opt out by setting `discloseVersion` to `false` in the compiler options ([#8761](https://github.com/sveltejs/svelte/pull/8761)) + +## 4.0.0-next.2 + +### Patch Changes + +- fix: never use html optimization for mustache tags in hydration mode ([#8744](https://github.com/sveltejs/svelte/pull/8744)) + +- fix: ensure types are loaded with all TS settings ([#8721](https://github.com/sveltejs/svelte/pull/8721)) + +- warn on boolean compilerOptions.css ([#8710](https://github.com/sveltejs/svelte/pull/8710)) + +- fix: export correct SvelteComponent type ([#8721](https://github.com/sveltejs/svelte/pull/8721)) + +## 4.0.0-next.1 + +### Patch Changes + +- fix: export ComponentType from `svelte` entrypoint ([#8694](https://github.com/sveltejs/svelte/pull/8694)) + +- fix: derived store types ([#8700](https://github.com/sveltejs/svelte/pull/8700)) + +- Generate type declarations with dts-buddy ([#8702](https://github.com/sveltejs/svelte/pull/8702)) + +## 4.0.0-next.0 + +### Major Changes + +- breaking: Minimum supported Node version is now Node 16 ([#8566](https://github.com/sveltejs/svelte/pull/8566)) +- breaking: Minimum supported webpack version is now webpack 5 ([#8515](https://github.com/sveltejs/svelte/pull/8515)) +- breaking: Bundlers must specify the `browser` condition when building a frontend bundle for the browser ([#8516](https://github.com/sveltejs/svelte/pull/8516)) +- breaking: Minimum supported vite-plugin-svelte version is now 2.4.1. SvelteKit users can upgrade to 1.20.0 or newer to ensure a compatible version ([#8516](https://github.com/sveltejs/svelte/pull/8516)) +- breaking: Minimum supported `rollup-plugin-svelte` version is now 7.1.5 ([198dbcf](https://github.com/sveltejs/svelte/commit/198dbcf)) +- breaking: Minimum supported `svelte-loader` is now 3.1.8 ([198dbcf](https://github.com/sveltejs/svelte/commit/198dbcf)) +- breaking: Minimum supported TypeScript version is now TypeScript 5 (it will likely work with lower versions, but we make no guarantees about that) ([#8488](https://github.com/sveltejs/svelte/pull/8488)) +- breaking: Remove `svelte/register` hook, CJS runtime version and CJS compiler output ([#8613](https://github.com/sveltejs/svelte/pull/8613)) +- breaking: Stricter types for `createEventDispatcher` (see PR for migration instructions) ([#7224](https://github.com/sveltejs/svelte/pull/7224)) +- breaking: Stricter types for `Action` and `ActionReturn` (see PR for migration instructions) ([#7442](https://github.com/sveltejs/svelte/pull/7442)) +- breaking: Stricter types for `onMount` - now throws a type error when returning a function asynchronously to catch potential mistakes around callback functions (see PR for migration instructions) ([#8136](https://github.com/sveltejs/svelte/pull/8136)) +- breaking: Overhaul and drastically improve creating custom elements with Svelte (see PR for list of changes and migration instructions) ([#8457](https://github.com/sveltejs/svelte/pull/8457)) +- breaking: Deprecate `SvelteComponentTyped` in favor of `SvelteComponent` ([#8512](https://github.com/sveltejs/svelte/pull/8512)) +- breaking: Make transitions local by default to prevent confusion around page navigations ([#6686](https://github.com/sveltejs/svelte/issues/6686)) +- breaking: Error on falsy values instead of stores passed to `derived` ([#7947](https://github.com/sveltejs/svelte/pull/7947)) +- breaking: Custom store implementers now need to pass an `update` function additionally to the `set` function ([#6750](https://github.com/sveltejs/svelte/pull/6750)) +- breaking: Do not expose default slot bindings to named slots and vice versa ([#6049](https://github.com/sveltejs/svelte/pull/6049)) +- breaking: Change order in which preprocessors are applied ([#8618](https://github.com/sveltejs/svelte/pull/8618)) +- breaking: The runtime now makes use of `classList.toggle(name, boolean)` which does not work in very old browsers ([#8629](https://github.com/sveltejs/svelte/pull/8629)) +- breaking: apply `inert` to outroing elements ([#8627](https://github.com/sveltejs/svelte/pull/8627)) + +### Minor Changes + +- Add a way to modify attributes for script/style preprocessors ([#8618](https://github.com/sveltejs/svelte/pull/8618)) +- Improve hydration speed by adding `data-svelte-h` attribute to detect unchanged HTML elements ([#7426](https://github.com/sveltejs/svelte/pull/7426)) +- Add `a11y no-noninteractive-element-interactions` rule ([#8391](https://github.com/sveltejs/svelte/pull/8391)) +- Add `a11y-no-static-element-interactions`rule ([#8251](https://github.com/sveltejs/svelte/pull/8251)) +- Allow `#each` to iterate over iterables like `Set`, `Map` etc ([#7425](https://github.com/sveltejs/svelte/issues/7425)) +- Improve duplicate key error for keyed `each` blocks ([#8411](https://github.com/sveltejs/svelte/pull/8411)) +- Warn about `:` in attributes and props to prevent ambiguity with Svelte directives ([#6823](https://github.com/sveltejs/svelte/issues/6823)) + +### Patch Changes + +- Bind `null` option and input values consistently ([#8312](https://github.com/sveltejs/svelte/issues/8312)) +- Allow `$store` to be used with changing values including nullish values ([#7555](https://github.com/sveltejs/svelte/issues/7555)) +- Initialize stylesheet with `/* empty */` to enable setting CSP directive that also works in Safari ([#7800](https://github.com/sveltejs/svelte/pull/7800)) +- Treat slots as if they don't exist when using CSS adjacent and general sibling combinators ([#8284](https://github.com/sveltejs/svelte/issues/8284)) +- Fix transitions so that they don't require a `style-src 'unsafe-inline'` Content Security Policy (CSP) ([#6662](https://github.com/sveltejs/svelte/issues/6662)). +- Explicitly disallow `var` declarations extending the reactive statement scope ([#6800](https://github.com/sveltejs/svelte/pull/6800)) +- Improve error message when trying to use `animate:` directives on inline components ([#8641](https://github.com/sveltejs/svelte/issues/8641)) + +## 3.59.2 + +- Fix escaping `', - test({ assert, target }) { - const textarea = target.querySelector('textarea'); - assert.ok(textarea.readOnly === false); - } -}; diff --git a/packages/svelte/test/runtime/samples/attribute-boolean-hidden/_config.js b/packages/svelte/test/runtime/samples/attribute-boolean-hidden/_config.js deleted file mode 100644 index 5a6d28c08a5c..000000000000 --- a/packages/svelte/test/runtime/samples/attribute-boolean-hidden/_config.js +++ /dev/null @@ -1,10 +0,0 @@ -export default { - get props() { - return { hidden: true }; - }, - html: '