Skip to content

Commit 32d57a2

Browse files
committed
merge master
2 parents e24d677 + 3173fdd commit 32d57a2

File tree

17 files changed

+1271
-605
lines changed

17 files changed

+1271
-605
lines changed

.changeset/twelve-suits-drive.md

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
---
2+
title: "What's new in Svelte: August 2023"
3+
description: "Extending Custom Element Classes and new +server exports"
4+
author: Dani Sandoval
5+
authorURL: https://dreamindani.com
6+
---
7+
8+
Some sweet new features have dropped in both Svelte and SvelteKit, this month. It's also great to see how many products and side projects have launched using Svelte as their core technology!
9+
10+
More on all that down below...
11+
12+
## What's new in Svelte & Language Tools
13+
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).
14+
15+
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!
16+
17+
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**).
18+
19+
## What's new in SvelteKit
20+
- 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))
21+
- 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))
22+
- 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))
23+
24+
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).
25+
26+
---
27+
28+
## Community Showcase
29+
30+
**Apps & Sites built with Svelte**
31+
- [GitLight](https://github.com/ColinLienard/gitlight) brings GitHub & GitLab notifications to your desktop
32+
- [Days](https://github.com/paprikka/days) is paprikka's life in days, inspired by Buster Benson's Life in Weeks
33+
- [Mofi](https://mofi.loud.red/) is a content-aware fill and trim for music
34+
- [JSON Bucket](https://github.com/Nico-Mayer/json-bucket) stores your JSON data so you can access it anywhere through generated API routes
35+
- [Soggy Planet](https://www.cosmicplayground.org/soggy-planet) is an interactive map of Earth where sea levels rise and fall and the lights of civilization shine through the night ([Source](https://github.com/ryanatkn/cosmicplayground))
36+
- [PaperClip](https://www.paperclipapp.xyz/) is a Chrome extension that makes it easy to memorize details from papers in machine learning, computer vision, and natural language processing.
37+
- [Maktaba](https://www.maktaba.digital/) is a bookmark manager that "you will actually use"
38+
- [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)
39+
- [DocuTalk](https://docutalk.co/) is an AI Customer Support chatbot for your website
40+
- [Krello](https://github.com/iamrishupatel/trello-clone) is a Trello clone built with Svelte, Appwrite and Flowbite
41+
- [Been](https://beeneverywhere.net/) is a map builder with travel stats like visited countries, extreme visited points, etc.
42+
- [image-to-social-media-thumbnail](https://brody.fyi/tools/image-to-social-media-thumbnail) lets you convert any image to a social media thumbnail
43+
- [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
44+
45+
46+
**Learning Resources**
47+
_Featuring Svelte Contributors and Ambassadors_
48+
- [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
49+
- [Svelte Sirens Stream Design Systems: Lessons Learned](https://www.youtube.com/live/YHZaiIGSqsE?feature=share) featuring Eric Liu creator of Carbon Components Svelte and Svelde the docgen library
50+
- This Week in Svelte:
51+
- [2023 June 30](https://www.youtube.com/watch?v=sDz4_BLoYQ4) - Svelte 4.0.1, SK 1.21, lists, screen readers, loading
52+
- [2023 July 7](https://www.youtube.com/watch?v=0tq1ph4DDFA) - Svelte 4.0.5, Kit 1.22.1, Svelte 5, local storage and markdown
53+
- [2023 July 21](https://www.youtube.com/watch?v=AG4_3kon3zU) - Svelte 4.1.1, SvelteKit 1.22.3, Progressive enhancement
54+
55+
56+
_To Watch/Hear_
57+
- [What is The Transitional Web? with Chris Ferdinandi](https://www.smashingmagazine.com/2023/07/smashing-podcast-episode-63/?ref=dailydevbytes.com) by Smashing Podcast
58+
- [SvelteKit in 100 seconds](https://www.youtube.com/watch?v=H1eEFfAkIik) by Fireship
59+
- [Primo V2 Introduction](https://www.youtube.com/watch?v=ThInVXgxJ1Q) by Primo (a [visual CMS](https://primocms.org/) based on Svelte)
60+
- [Understanding Svelte (vs React)](https://www.youtube.com/watch?v=lYYGhm7p74Q) by Kodaps Academy
61+
- [Is it thàt simple? - Mastering SvelteKit](https://www.youtube.com/watch?v=6Vrc1VO8pgs) by Threeveloper
62+
- [Markdown in SvelteKit with custom Components: mdsvex](https://www.youtube.com/watch?v=VJFkyGd0FEA) by hartenfellerdev
63+
- [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
64+
65+
66+
_To Read_
67+
- [SvelteJS: My ecosystem is bigger than yours](https://hackmd.io/@roguegpu/r1RKQMdt3) by roguegpu
68+
- [Avoid shared state on the server in SvelteKit](https://blog.aakashgoplani.in/avoid-shared-state-on-the-server-in-sveltekit) by Aakash Goplani
69+
- [SvelteKit Fontaine: Reduce Custom Font CLS](https://rodneylab.com/sveltekit-fontaine/) by Rodney Lab
70+
- [A Simple Guide to Redirects in Svelte Kit](https://rgbstudios.org/blog/redirects-in-svelte-kit) by Justin Golden
71+
- [React vs Svelte (Q3 2023)](https://gee-astro-personal.vercel.app/blog/post2) by Gee
72+
- [SvelteKit Page Reaction Component with Upstash Redis](https://scottspence.com/posts/sveltekit-page-reaction-component-with-upstash-redis) by Scott Spence
73+
- [Building a privacy-friendly, self-hosted application architecture with SvelteKit](https://khromov.se/building-a-privacy-friendly-self-hosted-application-architecture-with-sveltekit/) and [Building a privacy-friendly, self-hosted application architecture with SvelteKit](https://khromov.se/building-a-privacy-friendly-self-hosted-application-architecture-with-sveltekit/) by Stanislav Khromov
74+
- [Deploying Sveltekit on IIS](https://dev.to/nnutnonn/deploying-sveltekit-on-iis--5gf6) by Nutchapon Makelai
75+
- [Streamlined Authentication and Secrets Management](https://eman.hashnode.dev/streamlined-authentication-and-secrets-management) by Eman
76+
77+
78+
**Libraries, Tools & Components**
79+
- [Melt UI](https://github.com/melt-ui/melt-ui) is a set of headless, accessible component builders for Svelte
80+
- [MDsveX](https://github.com/pngwn/MDsveX/releases/tag/mdsvex%400.11.0) has been updated to work with Svelte 4
81+
- [Svelte Sonner](https://github.com/wobsoriano/svelte-sonner) is an opinionated toast component for Svelte
82+
- [WebExtensionTemplate](https://github.com/kyle-n/WebExtensionTemplate) lets you skip the boilerplate and write a Web Extension with TypeScript and Svelte or React
83+
- [svelte-rust](https://github.com/Hugo-Dz/svelte-rust) lets you run Rust code in your Svelte app
84+
- [SvelteKit SSE](https://github.com/tncrazvan/sveltekit-sse) provides an easy way to produce and consume server sent events
85+
- [better-svelte-writable](https://github.com/tnthung/better-svelte-writable) provides a type-safe writable which gives you more control over the container
86+
- [Svetch.ts](https://github.com/Bewinxed/svetch#readme) is a client/types/schema/docs generator for your API endpoints
87+
- [sveltekit-localize-url](https://github.com/rinart73/sveltekit-localize-url) handles URL localization and routing
88+
- [elegua](https://github.com/howesteve/elegua) is a small, reactive PWA router for Svelte
89+
- [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
90+
- [sveltekit-bot](https://github.com/begoon/sveltekit-bot) is a Telegram bot made with SvelteKit and Vercel
91+
92+
Thanks for reading! As always, feel free to let us know if we missed anything on [Reddit](https://www.reddit.com/r/sveltejs/) or [Discord](https://discord.gg/svelte).
93+
94+
Until next time 👋

documentation/docs/02-template-syntax/02-basic-markup.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,13 @@ An element or component can have multiple spread attributes, interspersed with r
8585
<Widget {...things} />
8686
```
8787

88-
`$$props` references all props that are passed to a component, including ones that are not declared with `export`. It is not generally recommended, as it is difficult for Svelte to optimise. But it can be useful in rare cases – for example, when you don't know at compile time what props might be passed to a component.
88+
`$$props` references all props that are passed to a component, including ones that are not declared with `export`. Using `$$props` will not perform as well as references to a specific prop because changes to any prop will cause Svelte to recheck all usages of `$$props`. But it can be useful in some cases – for example, when you don't know at compile time what props might be passed to a component.
8989

9090
```svelte
9191
<Widget {...$$props} />
9292
```
9393

94-
`$$restProps` contains only the props which are _not_ declared with `export`. It can be used to pass down other unknown attributes to an element in a component. It shares the same optimisation problems as `$$props`, and is likewise not recommended.
94+
`$$restProps` contains only the props which are _not_ declared with `export`. It can be used to pass down other unknown attributes to an element in a component. It shares the same performance characteristics compared to specific property access as `$$props`.
9595

9696
```svelte
9797
<input {...$$restProps} />

documentation/docs/02-template-syntax/05-element-directives.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ DOMRect {
738738

739739
An animation is triggered when the contents of a [keyed each block](/docs/logic-blocks#each) are re-ordered. Animations do not run when an element is added or removed, only when the index of an existing data item within the each block changes. Animate directives must be on an element that is an _immediate_ child of a keyed each block.
740740

741-
Animations can be used with Svelte's [built-in animation functions](/docs/svelte-animate) or [custom animation functions](/docs/element-directives#custom-transition-functions).
741+
Animations can be used with Svelte's [built-in animation functions](/docs/svelte-animate) or [custom animation functions](/docs/element-directives#custom-animation-functions).
742742

743743
```svelte
744744
<!-- When `list` is reordered the animation will run-->

documentation/docs/02-template-syntax/06-component-directives.md

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,34 @@ title: Component directives
88
on:eventname={handler}
99
```
1010

11-
Components can emit events using [createEventDispatcher](/docs/svelte#createeventdispatcher), or by forwarding DOM events. Listening for component events looks the same as listening for DOM events:
11+
Components can emit events using [`createEventDispatcher`](/docs/svelte#createeventdispatcher) or by forwarding DOM events.
12+
13+
```svelte
14+
<!-- SomeComponent.svelte -->
15+
<script>
16+
import { createEventDispatcher } from 'svelte';
17+
18+
const dispatch = createEventDispatcher();
19+
</script>
20+
21+
<!-- programmatic dispatching -->
22+
<button on:click={() => dispatch('hello')}>
23+
one
24+
</button>
25+
26+
<!-- declarative event forwarding -->
27+
<button on:click>
28+
two
29+
</button>
30+
```
31+
32+
Listening for component events looks the same as listening for DOM events:
1233

1334
```svelte
1435
<SomeComponent on:whatever={handler} />
1536
```
1637

17-
As with DOM events, if the `on:` directive is used without a value, the component will _forward_ the event, meaning that a consumer of the component can listen for it.
38+
As with DOM events, if the `on:` directive is used without a value, the event will be forwarded, meaning that a consumer can listen for it.
1839

1940
```svelte
2041
<SomeComponent on:whatever />
@@ -92,6 +113,8 @@ You can bind to component props using the same syntax as for elements.
92113
<Keypad bind:value={pin} />
93114
```
94115

116+
While Svelte props are reactive without binding, that reactivity only flows downward into the component by default. Using `bind:property` allows changes to the property from within the component to flow back up out of the component.
117+
95118
## bind:this
96119

97120
```svelte
@@ -100,10 +123,10 @@ bind:this={component_instance}
100123

101124
Components also support `bind:this`, allowing you to interact with component instances programmatically.
102125

103-
> Note that we can't do `{cart.empty}` since `cart` is `undefined` when the button is first rendered and throws an error.
104-
105126
```svelte
106127
<ShoppingCart bind:this={cart} />
107128
108129
<button on:click={() => cart.empty()}> Empty shopping cart </button>
109130
```
131+
132+
> Note that we can't do `{cart.empty}` since `cart` is `undefined` when the button is first rendered and throws an error.

packages/svelte/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# svelte
22

3+
## 4.1.2
4+
5+
### Patch Changes
6+
7+
- fix: allow child element with slot attribute within svelte:element ([#9038](https://github.com/sveltejs/svelte/pull/9038))
8+
9+
- fix: Add data-\* to svg attributes ([#9036](https://github.com/sveltejs/svelte/pull/9036))
10+
311
## 4.1.1
412

513
### Patch Changes

packages/svelte/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "svelte",
3-
"version": "4.1.1",
3+
"version": "4.1.2",
44
"description": "Cybernetically enhanced web apps",
55
"type": "module",
66
"module": "src/runtime/index.js",

packages/svelte/src/compiler/compile/nodes/Element.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,6 @@ export default class Element extends Node {
530530
this.name === 'option' ||
531531
this.is_dynamic_element ||
532532
this.tag_expr.dynamic_dependencies().length ||
533-
this.is_dynamic_element ||
534533
component.compile_options.dev
535534
) {
536535
this.parent.cannot_use_innerhtml(); // need to use add_location
@@ -1414,7 +1413,9 @@ const regex_minus_sign = /-/;
14141413
function within_custom_element(parent) {
14151414
while (parent) {
14161415
if (parent.type === 'InlineComponent') return false;
1417-
if (parent.type === 'Element' && regex_minus_sign.test(parent.name)) return true;
1416+
if (parent.type === 'Element') {
1417+
if (regex_minus_sign.test(parent.name) || parent.is_dynamic_element) return true;
1418+
}
14181419
parent = parent.parent;
14191420
}
14201421
return false;

packages/svelte/src/compiler/utils/fuzzymatch.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,7 @@ function _distance(str1, str2) {
2626
str1 = String(str1);
2727
str2 = String(str2);
2828
const distance = levenshtein(str1, str2);
29-
if (str1.length > str2.length) {
30-
return 1 - distance / str1.length;
31-
} else {
32-
return 1 - distance / str2.length;
33-
}
29+
return 1 - distance / Math.max(str1.length, str2.length);
3430
}
3531

3632
// helper functions

packages/svelte/src/shared/version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
* https://svelte.dev/docs/svelte-compiler#svelte-version
77
* @type {string}
88
*/
9-
export const VERSION = '4.1.1';
9+
export const VERSION = '4.1.2';
1010
export const PUBLIC_VERSION = '4';

0 commit comments

Comments
 (0)