mirror of
https://github.com/sveltejs/svelte.git
synced 2024-11-24 00:07:30 +01:00
feat(site-2): Update links, move blog out of SK folder to content (#8289)
* Update links * Move blog to site/content * Update site/content/docs/02-component-format.md * Fix docs links * Add global prettierrc * Auto format * Fix git merge artifact * Fix errors * Update html to svelte(remaining ones) * Add 2 blog posts * Modify prettierrc * Minor design fix * Switch package lock to spaces, prettier ignore * Regenerate package lock * prettier format * Update deps * Hack the build into working * add missing blog post --------- Co-authored-by: Rich Harris <richard.a.harris@gmail.com> Co-authored-by: Rich Harris <git@rich-harris.dev>
This commit is contained in:
parent
f4edb381bf
commit
db2d07f236
9
.github/ISSUE_TEMPLATE.md
vendored
9
.github/ISSUE_TEMPLATE.md
vendored
@ -1,7 +1,7 @@
|
||||
------
|
||||
---
|
||||
Before filing an issue we'd appreciate it if you could take a moment to ensure
|
||||
there isn't already an open issue or pull-request.
|
||||
-----
|
||||
---
|
||||
|
||||
If there's an existing issue, please add a :+1: reaction to the description of
|
||||
the issue. One way we prioritize issues is by the number of :+1: reactions on
|
||||
@ -23,7 +23,6 @@ as you can including the following.
|
||||
- Svelte version (Please check you can reproduce the issue with the latest release!)
|
||||
- Whether your project uses Webpack or Rollup
|
||||
|
||||
- *Repeatable steps to reproduce the issue*
|
||||
- _Repeatable steps to reproduce the issue_
|
||||
|
||||
Thanks for being part of Svelte!
|
||||
-------
|
||||
## Thanks for being part of Svelte!
|
||||
|
4
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
4
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
@ -1,6 +1,6 @@
|
||||
name: "\U0001F41E Bug report"
|
||||
description: Report an issue with Svelte
|
||||
labels: ["triage: bug"]
|
||||
labels: ['triage: bug']
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
@ -26,7 +26,7 @@ body:
|
||||
id: logs
|
||||
attributes:
|
||||
label: Logs
|
||||
description: "Please include browser console and server logs around the time this bug occurred. Optional if provided reproduction. Please try not to insert an image but copy paste the log text."
|
||||
description: 'Please include browser console and server logs around the time this bug occurred. Optional if provided reproduction. Please try not to insert an image but copy paste the log text.'
|
||||
render: shell
|
||||
- type: textarea
|
||||
id: system-info
|
||||
|
2
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
2
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
@ -1,4 +1,4 @@
|
||||
name: "Feature Request"
|
||||
name: 'Feature Request'
|
||||
description: Request a new Svelte feature
|
||||
labels: [enhancement]
|
||||
body:
|
||||
|
4
.github/PULL_REQUEST_TEMPLATE.md
vendored
4
.github/PULL_REQUEST_TEMPLATE.md
vendored
@ -1,8 +1,10 @@
|
||||
### Before submitting the PR, please make sure you do the following
|
||||
|
||||
- [ ] It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
|
||||
- [ ] Prefix your PR title with `feat:`, `fix:`, `chore:`, or `docs:`.
|
||||
- [ ] This message body should clearly illustrate what problems it solves.
|
||||
- [ ] Ideally, include a test that fails without this PR but passes with it.
|
||||
|
||||
### Tests
|
||||
- [ ] Run the tests with `npm test` and lint the project with `npm run lint`
|
||||
|
||||
- [ ] Run the tests with `npm test` and lint the project with `npm run lint`
|
||||
|
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@ -1,7 +1,7 @@
|
||||
name: CI
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
branches: [master]
|
||||
pull_request:
|
||||
permissions:
|
||||
contents: read # to fetch code (actions/checkout)
|
||||
|
11
.prettierignore
Normal file
11
.prettierignore
Normal file
@ -0,0 +1,11 @@
|
||||
/*.js
|
||||
/*.mjs
|
||||
/package.json
|
||||
package-lock.json
|
||||
elements/*
|
||||
scripts/*
|
||||
/src
|
||||
/test
|
||||
.svelte-kit
|
||||
types
|
||||
.vercel
|
8
.prettierrc
Normal file
8
.prettierrc
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"singleQuote": true,
|
||||
"printWidth": 100,
|
||||
"useTabs": true,
|
||||
"tabWidth": 2,
|
||||
"trailingComma": "none",
|
||||
"plugins": ["prettier-plugin-svelte"]
|
||||
}
|
2844
CHANGELOG.md
2844
CHANGELOG.md
File diff suppressed because it is too large
Load Diff
@ -4,8 +4,8 @@ Svelte is a new way to build web applications. It's a compiler that takes your d
|
||||
|
||||
The [Open Source Guides](https://opensource.guide/) website has a collection of resources for individuals, communities, and companies. These resources help people who want to learn how to run and contribute to open source projects. Contributors and people new to open source alike will find the following guides especially useful:
|
||||
|
||||
* [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/)
|
||||
* [Building Welcoming Communities](https://opensource.guide/building-community/)
|
||||
- [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/)
|
||||
- [Building Welcoming Communities](https://opensource.guide/building-community/)
|
||||
|
||||
## Get involved
|
||||
|
||||
|
@ -1,16 +1,13 @@
|
||||
[![Cybernetically enhanced web apps: Svelte](https://sveltejs.github.io/assets/banner.png)](https://svelte.dev)
|
||||
|
||||
|
||||
[![npm version](https://img.shields.io/npm/v/svelte.svg)](https://www.npmjs.com/package/svelte) [![license](https://img.shields.io/npm/l/svelte.svg)](LICENSE.md) [![Chat](https://img.shields.io/discord/457912077277855764?label=chat&logo=discord)](https://svelte.dev/chat)
|
||||
|
||||
|
||||
## What is Svelte?
|
||||
|
||||
Svelte is a new way to build web applications. It's a compiler that takes your declarative components and converts them into efficient JavaScript that surgically updates the DOM.
|
||||
|
||||
Learn more at the [Svelte website](https://svelte.dev), or stop by the [Discord chatroom](https://svelte.dev/chat).
|
||||
|
||||
|
||||
## Supporting Svelte
|
||||
|
||||
Svelte is an MIT-licensed open source project with its ongoing development made possible entirely by fantastic volunteers. If you'd like to support their efforts, please consider:
|
||||
@ -19,12 +16,10 @@ Svelte is an MIT-licensed open source project with its ongoing development made
|
||||
|
||||
Funds donated via Open Collective will be used for compensating expenses related to Svelte's development such as hosting costs. If sufficient donations are received, funds may also be used to support Svelte's development more directly.
|
||||
|
||||
|
||||
## Roadmap
|
||||
|
||||
You may view [our roadmap](https://svelte.dev/roadmap) if you'd like to see what we're currently working on.
|
||||
|
||||
|
||||
## 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!
|
||||
@ -53,7 +48,6 @@ npm run dev
|
||||
|
||||
The compiler is written in [TypeScript](https://www.typescriptlang.org/), but don't let that put you off — it's basically just JavaScript with type annotations. You'll pick it up in no time. If you're using an editor other than [Visual Studio Code](https://code.visualstudio.com/), you may need to install a plugin in order to get syntax highlighting and code hints, etc.
|
||||
|
||||
|
||||
### Running Tests
|
||||
|
||||
```bash
|
||||
@ -66,7 +60,6 @@ To filter tests, use `-g` (aka `--grep`). For example, to only run tests involvi
|
||||
npm run test -- -g transition
|
||||
```
|
||||
|
||||
|
||||
## svelte.dev
|
||||
|
||||
The source code for https://svelte.dev lives in the [sites](https://github.com/sveltejs/sites) repository, with all the documentation in the [site/content](site/content) directory. The site is built with [SvelteKit](https://kit.svelte.dev).
|
||||
|
41
package-lock.json
generated
41
package-lock.json
generated
@ -41,6 +41,7 @@
|
||||
"magic-string": "^0.30.0",
|
||||
"mocha": "^7.0.0",
|
||||
"periscopic": "^3.1.0",
|
||||
"prettier-plugin-svelte": "^2.10.0",
|
||||
"puppeteer": "^2.0.0",
|
||||
"rollup": "^1.27.14",
|
||||
"source-map": "^0.7.4",
|
||||
@ -4200,6 +4201,32 @@
|
||||
"node": ">= 0.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/prettier": {
|
||||
"version": "2.8.7",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.7.tgz",
|
||||
"integrity": "sha512-yPngTo3aXUUmyuTjeTUT75txrf+aMh9FiD7q9ZE/i6r0bPb22g4FsE6Y338PQX1bmfy08i9QQCB7/rcUAVntfw==",
|
||||
"dev": true,
|
||||
"peer": true,
|
||||
"bin": {
|
||||
"prettier": "bin-prettier.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.13.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/prettier/prettier?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/prettier-plugin-svelte": {
|
||||
"version": "2.10.0",
|
||||
"resolved": "https://registry.npmjs.org/prettier-plugin-svelte/-/prettier-plugin-svelte-2.10.0.tgz",
|
||||
"integrity": "sha512-GXMY6t86thctyCvQq+jqElO+MKdB09BkL3hexyGP3Oi8XLKRFaJP1ud/xlWCZ9ZIa2BxHka32zhHfcuU+XsRQg==",
|
||||
"dev": true,
|
||||
"peerDependencies": {
|
||||
"prettier": "^1.16.4 || ^2.0.0",
|
||||
"svelte": "^3.2.0"
|
||||
}
|
||||
},
|
||||
"node_modules/process-nextick-args": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
|
||||
@ -8537,6 +8564,20 @@
|
||||
"integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=",
|
||||
"dev": true
|
||||
},
|
||||
"prettier": {
|
||||
"version": "2.8.7",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.7.tgz",
|
||||
"integrity": "sha512-yPngTo3aXUUmyuTjeTUT75txrf+aMh9FiD7q9ZE/i6r0bPb22g4FsE6Y338PQX1bmfy08i9QQCB7/rcUAVntfw==",
|
||||
"dev": true,
|
||||
"peer": true
|
||||
},
|
||||
"prettier-plugin-svelte": {
|
||||
"version": "2.10.0",
|
||||
"resolved": "https://registry.npmjs.org/prettier-plugin-svelte/-/prettier-plugin-svelte-2.10.0.tgz",
|
||||
"integrity": "sha512-GXMY6t86thctyCvQq+jqElO+MKdB09BkL3hexyGP3Oi8XLKRFaJP1ud/xlWCZ9ZIa2BxHka32zhHfcuU+XsRQg==",
|
||||
"dev": true,
|
||||
"requires": {}
|
||||
},
|
||||
"process-nextick-args": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
|
||||
|
@ -151,6 +151,7 @@
|
||||
"magic-string": "^0.30.0",
|
||||
"mocha": "^7.0.0",
|
||||
"periscopic": "^3.1.0",
|
||||
"prettier-plugin-svelte": "^2.10.0",
|
||||
"puppeteer": "^2.0.0",
|
||||
"rollup": "^1.27.14",
|
||||
"source-map": "^0.7.4",
|
||||
|
@ -5,10 +5,10 @@ author: Rich Harris
|
||||
authorURL: https://twitter.com/Rich_Harris
|
||||
---
|
||||
|
||||
> Wait, this new framework has a *runtime*? Ugh. Thanks, I'll pass.
|
||||
> Wait, this new framework has a _runtime_? Ugh. Thanks, I'll pass.
|
||||
> **– front end developers in 2018**
|
||||
|
||||
We're shipping too much code to our users. Like a lot of front end developers, I've been in denial about that fact, thinking that it was fine to serve 100kb of JavaScript on page load – just use [one less .jpg!](https://twitter.com/miketaylr/status/227056824275333120) – and that what *really* mattered was performance once your app was already interactive.
|
||||
We're shipping too much code to our users. Like a lot of front end developers, I've been in denial about that fact, thinking that it was fine to serve 100kb of JavaScript on page load – just use [one less .jpg!](https://twitter.com/miketaylr/status/227056824275333120) – and that what _really_ mattered was performance once your app was already interactive.
|
||||
|
||||
But I was wrong. 100kb of .js isn't equivalent to 100kb of .jpg. It's not just the network time that'll kill your app's startup performance, but the time spent parsing and evaluating your script, during which time the browser becomes completely unresponsive. On mobile, those milliseconds rack up very quickly.
|
||||
|
||||
@ -16,37 +16,33 @@ If you're not convinced that this is a problem, follow [Alex Russell](https://tw
|
||||
|
||||
Perhaps we need to rethink the whole thing.
|
||||
|
||||
## What problem do frameworks _really_ solve?
|
||||
|
||||
## What problem do frameworks *really* solve?
|
||||
The common view is that frameworks make it easier to manage the complexity of your code: the framework abstracts away all the fussy implementation details with techniques like virtual DOM diffing. But that's not really true. At best, frameworks _move the complexity around_, away from code that you had to write and into code you didn't.
|
||||
|
||||
The common view is that frameworks make it easier to manage the complexity of your code: the framework abstracts away all the fussy implementation details with techniques like virtual DOM diffing. But that's not really true. At best, frameworks *move the complexity around*, away from code that you had to write and into code you didn't.
|
||||
|
||||
Instead, the reason that ideas like React are so wildly and deservedly successful is that they make it easier to manage the complexity of your *concepts*. Frameworks are primarily a tool for structuring your thoughts, not your code.
|
||||
|
||||
Given that, what if the framework *didn't actually run in the browser*? What if, instead, it converted your application into pure vanilla JavaScript, just like Babel converts ES2016+ to ES5? You'd pay no upfront cost of shipping a hefty runtime, and your app would get seriously fast, because there'd be no layers of abstraction between your app and the browser.
|
||||
Instead, the reason that ideas like React are so wildly and deservedly successful is that they make it easier to manage the complexity of your _concepts_. Frameworks are primarily a tool for structuring your thoughts, not your code.
|
||||
|
||||
Given that, what if the framework _didn't actually run in the browser_? What if, instead, it converted your application into pure vanilla JavaScript, just like Babel converts ES2016+ to ES5? You'd pay no upfront cost of shipping a hefty runtime, and your app would get seriously fast, because there'd be no layers of abstraction between your app and the browser.
|
||||
|
||||
## Introducing Svelte
|
||||
|
||||
Svelte is a new framework that does exactly that. You write your components using HTML, CSS and JavaScript (plus a few extra bits you can [learn in under 5 minutes](https://v2.svelte.dev/guide)), and during your build process Svelte compiles them into tiny standalone JavaScript modules. By statically analysing the component template, we can make sure that the browser does as little work as possible.
|
||||
|
||||
The [Svelte implementation of TodoMVC](https://svelte-todomvc.surge.sh/) weighs 3.6kb zipped. For comparison, React plus ReactDOM *without any app code* weighs about 45kb zipped. It takes about 10x as long for the browser just to evaluate React as it does for Svelte to be up and running with an interactive TodoMVC.
|
||||
The [Svelte implementation of TodoMVC](https://svelte-todomvc.surge.sh/) weighs 3.6kb zipped. For comparison, React plus ReactDOM _without any app code_ weighs about 45kb zipped. It takes about 10x as long for the browser just to evaluate React as it does for Svelte to be up and running with an interactive TodoMVC.
|
||||
|
||||
And once your app *is* up and running, according to [js-framework-benchmark](https://github.com/krausest/js-framework-benchmark) **Svelte is fast as heck**. It's faster than React. It's faster than Vue. It's faster than Angular, or Ember, or Ractive, or Preact, or Riot, or Mithril. It's competitive with Inferno, which is probably the fastest UI framework in the world, for now, because [Dominic Gannaway](https://twitter.com/trueadm) is a wizard. (Svelte is slower at removing elements. We're [working on it](https://github.com/sveltejs/svelte/issues/26).)
|
||||
|
||||
It's basically as fast as vanilla JS, which makes sense because it *is* vanilla JS – just vanilla JS that you didn't have to write.
|
||||
And once your app _is_ up and running, according to [js-framework-benchmark](https://github.com/krausest/js-framework-benchmark) **Svelte is fast as heck**. It's faster than React. It's faster than Vue. It's faster than Angular, or Ember, or Ractive, or Preact, or Riot, or Mithril. It's competitive with Inferno, which is probably the fastest UI framework in the world, for now, because [Dominic Gannaway](https://twitter.com/trueadm) is a wizard. (Svelte is slower at removing elements. We're [working on it](https://github.com/sveltejs/svelte/issues/26).)
|
||||
|
||||
It's basically as fast as vanilla JS, which makes sense because it _is_ vanilla JS – just vanilla JS that you didn't have to write.
|
||||
|
||||
## But that's not the important thing
|
||||
|
||||
Well, it *is* important – performance matters a great deal. What's really exciting about this approach, though, is that we can finally solve some of the thorniest problems in web development.
|
||||
Well, it _is_ important – performance matters a great deal. What's really exciting about this approach, though, is that we can finally solve some of the thorniest problems in web development.
|
||||
|
||||
Consider interoperability. Want to `npm install cool-calendar-widget` and use it in your app? Previously, you could only do that if you were already using (a correct version of) the framework that the widget was designed for – if `cool-calendar-widget` was built in React and you're using Angular then, well, hard cheese. But if the widget author used Svelte, apps that use it can be built using whatever technology you like. (On the TODO list: a way to convert Svelte components into web components.)
|
||||
|
||||
Or [code splitting](https://twitter.com/samccone/status/797528710085652480). It's a great idea (only load the code the user needs for the initial view, then get the rest later), but there's a problem – even if you only initially serve one React component instead of 100, *you still have to serve React itself*. With Svelte, code splitting can be much more effective, because the framework is embedded in the component, and the component is tiny.
|
||||
|
||||
Finally, something I've wrestled with a great deal as an open source maintainer: your users always want *their* features prioritised, and underestimate the cost of those features to people who don't need them. A framework author must always balance the long-term health of the project with the desire to meet their users' needs. That's incredibly difficult, because it's hard to anticipate – much less articulate – the consequences of incremental bloat, and it takes serious soft skills to tell people (who may have been enthusiastically evangelising your tool up to that point) that their feature isn't important enough. But with an approach like Svelte's, many features can be added with absolutely no cost to people who don't use them, because the code that implements those features just doesn't get generated by the compiler if it's unnecessary.
|
||||
Or [code splitting](https://twitter.com/samccone/status/797528710085652480). It's a great idea (only load the code the user needs for the initial view, then get the rest later), but there's a problem – even if you only initially serve one React component instead of 100, _you still have to serve React itself_. With Svelte, code splitting can be much more effective, because the framework is embedded in the component, and the component is tiny.
|
||||
|
||||
Finally, something I've wrestled with a great deal as an open source maintainer: your users always want _their_ features prioritised, and underestimate the cost of those features to people who don't need them. A framework author must always balance the long-term health of the project with the desire to meet their users' needs. That's incredibly difficult, because it's hard to anticipate – much less articulate – the consequences of incremental bloat, and it takes serious soft skills to tell people (who may have been enthusiastically evangelising your tool up to that point) that their feature isn't important enough. But with an approach like Svelte's, many features can be added with absolutely no cost to people who don't use them, because the code that implements those features just doesn't get generated by the compiler if it's unnecessary.
|
||||
|
||||
## We're just getting started
|
||||
|
@ -9,10 +9,9 @@ Svelte is a [new kind of framework](/blog/frameworks-without-the-framework). Rat
|
||||
|
||||
Because of that, getting started with it can be a little bit confusing at first. How, you might reasonably ask, do you make a Svelte app?
|
||||
|
||||
|
||||
## 1. Use the REPL
|
||||
|
||||
The [Svelte REPL](/repl) (Read-Eval-Print Loop) is the easiest way to begin. This is an interactive environment that allows you to modify code and instantly see the result.
|
||||
The [Svelte REPL](/repl) (Read-Eval-Print Loop) is the easiest way to begin. This is an interactive environment that allows you to modify code and instantly see the result.
|
||||
|
||||
You can choose from a list of [examples](/examples/), click the [REPL](/repl) link, and then tweak them until they do what you want.
|
||||
|
@ -5,24 +5,22 @@ author: Rich Harris
|
||||
authorURL: https://twitter.com/Rich_Harris
|
||||
---
|
||||
|
||||
It's fashionable to dislike CSS. There are lots of reasons why that's the case, but it boils down to this: CSS is *unpredictable*. If you've never had the experience of tweaking a style rule and accidentally breaking some layout that you thought was completely unrelated — usually when you're trying to ship — then you're either new at this or you're a much better programmer than the rest of us.
|
||||
It's fashionable to dislike CSS. There are lots of reasons why that's the case, but it boils down to this: CSS is _unpredictable_. If you've never had the experience of tweaking a style rule and accidentally breaking some layout that you thought was completely unrelated — usually when you're trying to ship — then you're either new at this or you're a much better programmer than the rest of us.
|
||||
|
||||
So the JavaScript community rolled up its sleeves and got to work. Over the last couple of years, there's been a Cambrian explosion of libraries aimed at making CSS behave, collectively referred to as *CSS-in-JS*.
|
||||
So the JavaScript community rolled up its sleeves and got to work. Over the last couple of years, there's been a Cambrian explosion of libraries aimed at making CSS behave, collectively referred to as _CSS-in-JS_.
|
||||
|
||||
What you might not realise is that **the biggest problems with CSS can be solved without CSS-in-JS**. Without those problems, writing CSS isn't just tolerable — it's enjoyable. And you don't have to find solutions to the additional problems that CSS-in-JS introduces.
|
||||
|
||||
This article isn't in any way intended as criticism of the hard work the CSS-in-JS community has done. It's one of the most active corners of the JS ecosystem, and new ideas are springing up every week. Instead, my purpose is to illustrate why an alternative approach — based on Single File Components with real CSS — is so damn delightful.
|
||||
|
||||
|
||||
## The biggest problem with CSS
|
||||
|
||||
Everything in CSS is global. Because of that, styles intended for one bit of markup often end up affecting another. Because of *that*, developers often resort to wild namespacing conventions (not 'rules', since they're very difficult to enforce) that mostly just increase your risk of RSI.
|
||||
Everything in CSS is global. Because of that, styles intended for one bit of markup often end up affecting another. Because of _that_, developers often resort to wild namespacing conventions (not 'rules', since they're very difficult to enforce) that mostly just increase your risk of RSI.
|
||||
|
||||
It gets worse when you're working on a team. No-one dares touch styles authored by someone else, because it's often unclear what they're doing, what markup they apply to, and what disasters will unfold if you remove them.
|
||||
|
||||
The consequence of all this is the **append-only stylesheet**. There's no way of knowing which code can safely be removed, so it's common to undo some existing style with another, more specific style — even on relatively small projects.
|
||||
|
||||
|
||||
## Single File Components change all that
|
||||
|
||||
The idea behind SFCs is simple: you write your components in an HTML file that (optionally) contains a `<style>` and `<script>` attribute describing the component's styles and behaviour. Svelte, Ractive, Vue and Polymer all follow this basic pattern.
|
||||
@ -35,9 +33,9 @@ The idea behind SFCs is simple: you write your components in an HTML file that (
|
||||
|
||||
Several wonderful things happen as a result:
|
||||
|
||||
* Your styles are *scoped to the component*. No more leakage, no more unpredictable cascade. And no more sesquipedalian classnames designed to prevent conflicts.
|
||||
* You don't need to go spelunking through your folder structure to find the rules that are breaking your stuff.
|
||||
* The compiler (in Svelte's case) can **identify and remove unused styles**. No more append-only stylesheets!
|
||||
- Your styles are _scoped to the component_. No more leakage, no more unpredictable cascade. And no more sesquipedalian classnames designed to prevent conflicts.
|
||||
- You don't need to go spelunking through your folder structure to find the rules that are breaking your stuff.
|
||||
- The compiler (in Svelte's case) can **identify and remove unused styles**. No more append-only stylesheets!
|
||||
|
||||
Let's see what that looks like in practice.
|
||||
|
||||
@ -46,33 +44,32 @@ Let's see what that looks like in practice.
|
||||
<source type='video/mp4' src='https://svelte-technology-assets.surge.sh/just-write-css.mp4'>
|
||||
</video>
|
||||
|
||||
<figcaption>
|
||||
Is this what they mean by 'use the platform'?
|
||||
</figcaption>
|
||||
<figcaption>
|
||||
Is this what they mean by 'use the platform'?
|
||||
</figcaption>
|
||||
|
||||
</figure>
|
||||
|
||||
Every code editor already knows about CSS, so there's a good chance that you'll get autocomplete, linting, syntax highlighting and so on — all without additional JS-fatigue-inducing tools.
|
||||
|
||||
And because it's real CSS, rather than some camelCased quotes-everywhere impostor, we can take advantage of the 'tweak in devtools, paste back into our source code' workflow, which I personally couldn't live without. Notice that we get CSS sourcemaps out of the box, so you can instantly pinpoint the lines in question. It's hard to overstate the importance of this: when you're in WYSIWYG mode, you're not thinking in terms of your component tree, so having a robust way to figure out *where these damn styles came from* is essential. Doubly so if someone else originally wrote the component. (I promise you, this is the single biggest productivity boost to your CSS workflow. If you're writing styles without sourcemaps, you are almost certainly wasting a lot of time. I know I was.)
|
||||
And because it's real CSS, rather than some camelCased quotes-everywhere impostor, we can take advantage of the 'tweak in devtools, paste back into our source code' workflow, which I personally couldn't live without. Notice that we get CSS sourcemaps out of the box, so you can instantly pinpoint the lines in question. It's hard to overstate the importance of this: when you're in WYSIWYG mode, you're not thinking in terms of your component tree, so having a robust way to figure out _where these damn styles came from_ is essential. Doubly so if someone else originally wrote the component. (I promise you, this is the single biggest productivity boost to your CSS workflow. If you're writing styles without sourcemaps, you are almost certainly wasting a lot of time. I know I was.)
|
||||
|
||||
Svelte transforms your selectors (using an attribute that's also applied to affected elements, though the exact mechanism is unimportant and subject to change) to achieve the scoping. It warns on and removes any unused rules, then it minifies the result and lets you write it out to a `.css` file. There's also an experimental new option to compile to web components, using shadow DOM to encapsulate the styles, if that's your jam.
|
||||
|
||||
This is all possible because your CSS is parsed (with [css-tree](https://github.com/csstree/csstree)) and statically analysed in the context of your markup. Static analysis opens the doors to all kinds of exciting future possibilities — smarter optimisations, a11y hints — that are much harder if your styles are computed dynamically at runtime. We're just getting started.
|
||||
|
||||
|
||||
## But we can add tools to do [x]!
|
||||
|
||||
If your reaction to the video was 'fine, but if we use TypeScript and write plugins for each editor then we can get all the autocomplete and syntax highlighting stuff' — in other words, if you believe that in order to achieve parity with CSS it makes sense to build, document, promote and maintain a fleet of ancillary projects — then, well, you and I may never see eye to eye!
|
||||
|
||||
|
||||
## We don't have all the answers — yet
|
||||
|
||||
Having said all that, CSS-in-JS does point to answers to some lingering questions:
|
||||
|
||||
* How can we install styles from npm?
|
||||
* How can we reuse constants that are defined in a single place?
|
||||
* How can we compose declarations?
|
||||
- How can we install styles from npm?
|
||||
- How can we reuse constants that are defined in a single place?
|
||||
- How can we compose declarations?
|
||||
|
||||
Personally, I haven't found these issues to outweigh the benefits of the approach outlined above. You may well have a different set of priorities, and they may be reason enough for you to abandon CSS.
|
||||
|
||||
But at the end of the day, you have to know CSS anyway. Love it or loathe it, you must at least *learn* it. As custodians of the web, we have a choice: create abstractions that steepen the web dev learning curve yet further, or work together to fix the bad parts of CSS. I know which I choose.
|
||||
But at the end of the day, you have to know CSS anyway. Love it or loathe it, you must at least _learn_ it. As custodians of the web, we have a choice: create abstractions that steepen the web dev learning curve yet further, or work together to fix the bad parts of CSS. I know which I choose.
|
@ -9,7 +9,6 @@ authorURL: https://twitter.com/Rich_Harris
|
||||
|
||||
Almost a year after we first started talking about version 2 on the Svelte issue tracker, it's finally time to make some breaking changes. This blog post will explain what changed, why it changed, and what you need to do to bring your apps up to date.
|
||||
|
||||
|
||||
## tl;dr
|
||||
|
||||
Each of these items is described in more depth below. If you get stuck, ask for help in our friendly [Discord chatroom](https://svelte.dev/chat).
|
||||
@ -21,18 +20,17 @@ Each of these items is described in more depth below. If you get stuck, ask for
|
||||
- Return `destroy` from your custom event handlers, rather than `teardown`
|
||||
- Make sure you're not passing numeric string props to components
|
||||
|
||||
|
||||
## New template syntax
|
||||
|
||||
The most visible change: we've made some improvements to the template syntax.
|
||||
|
||||
A common piece of feedback we heard was 'ewww, Mustache' or 'ewww, Handlebars'. A lot of people who used string-based templating systems in a previous era of web development *really* dislike them. Because Svelte adopted the `{{curlies}}` from those languages, a lot of people assumed that we somehow shared the limitations of those tools, such as weird scoping rules or an inability to use arbitrary JavaScript expressions.
|
||||
A common piece of feedback we heard was 'ewww, Mustache' or 'ewww, Handlebars'. A lot of people who used string-based templating systems in a previous era of web development _really_ dislike them. Because Svelte adopted the `{{curlies}}` from those languages, a lot of people assumed that we somehow shared the limitations of those tools, such as weird scoping rules or an inability to use arbitrary JavaScript expressions.
|
||||
|
||||
<aside>If you need to show an actual `{` character, it's as easy as `&#123;`</aside>
|
||||
|
||||
Beyond that, JSX proved that double curlies are unnecessary. So we've made our templates more... svelte, by adopting single curlies. The result feels much lighter to look at and is more pleasant to type:
|
||||
|
||||
```html
|
||||
```svelte
|
||||
<h1>Hello {name}!</h1>
|
||||
```
|
||||
|
||||
@ -46,7 +44,6 @@ This assumes any `.html` files in `src` are Svelte components. You can specify w
|
||||
|
||||
To see the full set of changes, consult the [svelte-upgrade README](https://github.com/sveltejs/svelte-upgrade#svelte-v2-syntax-changes).
|
||||
|
||||
|
||||
## Computed properties
|
||||
|
||||
Another thing that people often found confusing about Svelte is the way computed properties work. To recap, if you had a component with this...
|
||||
@ -54,19 +51,19 @@ Another thing that people often found confusing about Svelte is the way computed
|
||||
```js
|
||||
export default {
|
||||
computed: {
|
||||
d: (a, b, c) => a = b + c
|
||||
d: (a, b, c) => (a = b + c)
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
...then Svelte would first look at the function arguments to see which values `d` depended on, and then it would write code that updated `d` whenever those values changed, by injecting them into the function. That's cool, because it allows you to derive complex values from your component's inputs without worrying about when they need to recomputed, but it's also... *weird*. JavaScript doesn't work that way!
|
||||
...then Svelte would first look at the function arguments to see which values `d` depended on, and then it would write code that updated `d` whenever those values changed, by injecting them into the function. That's cool, because it allows you to derive complex values from your component's inputs without worrying about when they need to recomputed, but it's also... _weird_. JavaScript doesn't work that way!
|
||||
|
||||
In v2, we use [destructuring](http://www.jstips.co/en/javascript/use-destructuring-in-function-parameters/) instead:
|
||||
|
||||
```js
|
||||
export default {
|
||||
computed: {
|
||||
d: ({ a, b, c }) => a = b + c
|
||||
d: ({ a, b, c }) => (a = b + c)
|
||||
}
|
||||
};
|
||||
```
|
||||
@ -75,14 +72,12 @@ The Svelte compiler can still see which values `d` depends on, but it's no longe
|
||||
|
||||
Again, you don't need to make this change manually — just run svelte-upgrade on your components, as shown above.
|
||||
|
||||
|
||||
## Sorry, IE11. It's not you, it's... well actually, yeah. It's you
|
||||
|
||||
Svelte v1 was careful to only emit ES5 code, so that you wouldn't be forced to faff around with transpilers in order to use it. But it's 2018 now, and almost all browsers support modern JavaScript. By ditching the ES5 constraint, we can generate leaner code.
|
||||
|
||||
If you need to support IE11 and friends, you will need to use a transpiler like [Babel](https://babeljs.io/repl) or [Bublé](https://buble.surge.sh/).
|
||||
|
||||
|
||||
## New lifecycle hooks
|
||||
|
||||
In addition to `oncreate` and `ondestroy`, Svelte v2 adds two more [lifecycle hooks](https://v2.svelte.dev/guide#lifecycle-hooks) for responding to state changes:
|
||||
@ -110,7 +105,6 @@ component.on('state', ({ changed, current, previous }) => {
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
## component.observe
|
||||
|
||||
With the new lifecycle hooks, we no longer need the `component.observe(...)` method:
|
||||
@ -135,7 +129,7 @@ export default {
|
||||
};
|
||||
```
|
||||
|
||||
This shrinks the amount of code Svelte needs to generate, and gives you more flexibility. For example, it's now very easy to take action when any one of *several* properties have changed, such as redrawing a canvas without debouncing several observers.
|
||||
This shrinks the amount of code Svelte needs to generate, and gives you more flexibility. For example, it's now very easy to take action when any one of _several_ properties have changed, such as redrawing a canvas without debouncing several observers.
|
||||
|
||||
However, if you prefer to use `component.observe(...)`, then you can install it from [svelte-extras](https://github.com/sveltejs/svelte-extras):
|
||||
|
||||
@ -149,7 +143,6 @@ export default {
|
||||
};
|
||||
```
|
||||
|
||||
|
||||
## component.get
|
||||
|
||||
This method no longer takes an optional `key` argument — instead, it always returns the entire state object:
|
||||
@ -165,27 +158,24 @@ const { foo, bar } = this.get();
|
||||
|
||||
This change might seem annoying initially, but it's the right move: among other things, it's likely to play better with type systems as we explore that space more fully in future.
|
||||
|
||||
|
||||
## event_handler.destroy
|
||||
|
||||
If your app has [custom event handlers](https://v2.svelte.dev/guide#custom-event-handlers), they must return an object with a `destroy` method, *not* a `teardown` method (this aligns event handlers with the component API).
|
||||
|
||||
If your app has [custom event handlers](https://v2.svelte.dev/guide#custom-event-handlers), they must return an object with a `destroy` method, _not_ a `teardown` method (this aligns event handlers with the component API).
|
||||
|
||||
## No more type coercion
|
||||
|
||||
Previously, numeric values passed to components were treated as numbers:
|
||||
|
||||
```html
|
||||
<Counter start='1'/>
|
||||
```svelte
|
||||
<Counter start="1" />
|
||||
```
|
||||
|
||||
That causes unexpected behaviour, and has been changed: if you need to pass a literal number, do so as an expression:
|
||||
|
||||
```html
|
||||
<Counter start={1}/>
|
||||
```svelte
|
||||
<Counter start={1} />
|
||||
```
|
||||
|
||||
|
||||
## Compiler changes
|
||||
|
||||
In most cases you'll never need to deal with the compiler directly, so this shouldn't require any action on your part. It's worth noting anyway: the compiler API has changed. Instead of an object with a mish-mash of properties, the compiler now returns `js`, `css`, `ast` and `stats`:
|
||||
@ -198,7 +188,6 @@ const { js, css, ast, stats } = svelte.compile(source, options);
|
||||
|
||||
Before, there was a `svelte.validate` method which checked your component was valid. That's been removed — if you want to check a component without actually compiling it, just pass the `generate: false` option.
|
||||
|
||||
|
||||
## My app is broken! Help!
|
||||
|
||||
Hopefully this covers everything, and the update should be easier for you than it was for us. But if you find bugs, or discover things that aren't mentioned here, swing by [Discord chatroom](https://svelte.dev/chat) or raise an issue on the [tracker](https://github.com/sveltejs/svelte/issues).
|
@ -11,7 +11,6 @@ That's why Svelte allows you to add CSS in a component's `<style>` tag. Co-locat
|
||||
|
||||
But Svelte's style handling does have some limitations. It's too difficult to share styles between components, or apply app-level optimisations. These are areas we plan to address in future versions, but in the meantime if you need those things you can use any framework-agnostic CSS-in-JS library.
|
||||
|
||||
|
||||
## For example
|
||||
|
||||
Here, we're using [Emotion](https://emotion.sh) to generate scoped class names that can be used across multiple components:
|
@ -5,22 +5,17 @@ author: Rich Harris
|
||||
authorURL: https://twitter.com/Rich_Harris
|
||||
---
|
||||
|
||||
If you've used JavaScript frameworks in the last few years, you've probably heard the phrase 'the virtual DOM is fast', often said to mean that it's faster than the *real* DOM. It's a surprisingly resilient meme — for example people have asked how Svelte can be fast when it doesn't use a virtual DOM.
|
||||
If you've used JavaScript frameworks in the last few years, you've probably heard the phrase 'the virtual DOM is fast', often said to mean that it's faster than the _real_ DOM. It's a surprisingly resilient meme — for example people have asked how Svelte can be fast when it doesn't use a virtual DOM.
|
||||
|
||||
It's time to take a closer look.
|
||||
|
||||
|
||||
## What is the virtual DOM?
|
||||
|
||||
In many frameworks, you build an app by creating `render()` functions, like this simple [React](https://reactjs.org/) component:
|
||||
|
||||
```js
|
||||
function HelloMessage(props) {
|
||||
return (
|
||||
<div className="greeting">
|
||||
Hello {props.name}
|
||||
</div>
|
||||
);
|
||||
return <div className="greeting">Hello {props.name}</div>;
|
||||
}
|
||||
```
|
||||
|
||||
@ -28,17 +23,11 @@ You can do the same thing without JSX...
|
||||
|
||||
```js
|
||||
function HelloMessage(props) {
|
||||
return React.createElement(
|
||||
'div',
|
||||
{ className: 'greeting' },
|
||||
'Hello ',
|
||||
props.name
|
||||
);
|
||||
return React.createElement('div', { className: 'greeting' }, 'Hello ', props.name);
|
||||
}
|
||||
```
|
||||
|
||||
...but the result is the same — an object representing how the page should now look. That object is the virtual DOM. Every time your app's state updates (for example when the `name` prop changes), you create a new one. The framework's job is to *reconcile* the new one against the old one, to figure out what changes are necessary and apply them to the real DOM.
|
||||
|
||||
...but the result is the same — an object representing how the page should now look. That object is the virtual DOM. Every time your app's state updates (for example when the `name` prop changes), you create a new one. The framework's job is to _reconcile_ the new one against the old one, to figure out what changes are necessary and apply them to the real DOM.
|
||||
|
||||
## How did the meme start?
|
||||
|
||||
@ -51,7 +40,7 @@ Misunderstood claims about virtual DOM performance date back to the launch of Re
|
||||
<figcaption>Screenshot from <a href="https://www.youtube.com/watch?v=x7cQ3mrcKaY">Rethinking Best Practices</a> at JSConfEU 2013</figcaption>
|
||||
</figure>
|
||||
|
||||
But hang on a minute! The virtual DOM operations are *in addition to* the eventual operations on the real DOM. The only way it could be faster is if we were comparing it to a less efficient framework (there were plenty to go around back in 2013!), or arguing against a straw man — that the alternative is to do something no-one actually does:
|
||||
But hang on a minute! The virtual DOM operations are _in addition to_ the eventual operations on the real DOM. The only way it could be faster is if we were comparing it to a less efficient framework (there were plenty to go around back in 2013!), or arguing against a straw man — that the alternative is to do something no-one actually does:
|
||||
|
||||
```js
|
||||
onEveryStateChange(() => {
|
||||
@ -65,9 +54,7 @@ Pete clarifies soon after...
|
||||
|
||||
...but that's not the part that stuck.
|
||||
|
||||
|
||||
|
||||
## So... is the virtual DOM *slow*?
|
||||
## So... is the virtual DOM _slow_?
|
||||
|
||||
Not exactly. It's more like 'the virtual DOM is usually fast enough', but with certain caveats.
|
||||
|
||||
@ -75,7 +62,6 @@ The original promise of React was that you could re-render your entire app on ev
|
||||
|
||||
Even with `shouldComponentUpdate`, updating your entire app's virtual DOM in one go is a lot of work. A while back, the React team introduced something called React Fiber which allows the update to be broken into smaller chunks. This means (among other things) that updates don't block the main thread for long periods of time, though it doesn't reduce the total amount of work or the time an update takes.
|
||||
|
||||
|
||||
## Where does the overhead come from?
|
||||
|
||||
Most obviously, [diffing isn't free](https://twitter.com/pcwalton/status/1015694528857047040). You can't apply changes to the real DOM without first comparing the new virtual DOM with the previous snapshot. To take the earlier `HelloMessage` example, suppose the `name` prop changed from 'world' to 'everybody'.
|
||||
@ -92,8 +78,7 @@ if (changed.name) {
|
||||
}
|
||||
```
|
||||
|
||||
(This is almost exactly the update code that Svelte generates. Unlike traditional UI frameworks, Svelte is a compiler that knows at *build time* how things could change in your app, rather than waiting to do the work at *run time*.)
|
||||
|
||||
(This is almost exactly the update code that Svelte generates. Unlike traditional UI frameworks, Svelte is a compiler that knows at _build time_ how things could change in your app, rather than waiting to do the work at _run time_.)
|
||||
|
||||
## It's not just the diffing though
|
||||
|
||||
@ -103,9 +88,7 @@ The diffing algorithms used by React and other virtual DOM frameworks are fast.
|
||||
function StrawManComponent(props) {
|
||||
const value = expensivelyCalculateValue(props.foo);
|
||||
|
||||
return (
|
||||
<p>the value is {value}</p>
|
||||
);
|
||||
return <p>the value is {value}</p>;
|
||||
}
|
||||
```
|
||||
|
||||
@ -120,20 +103,18 @@ function MoreRealisticComponent(props) {
|
||||
<p>Selected {selected ? selected.name : 'nothing'}</p>
|
||||
|
||||
<ul>
|
||||
{props.items.map(item =>
|
||||
{props.items.map((item) => (
|
||||
<li>
|
||||
<button onClick={() => setSelected(item)}>
|
||||
{item.name}
|
||||
</button>
|
||||
<button onClick={() => setSelected(item)}>{item.name}</button>
|
||||
</li>
|
||||
)}
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
Here, we're generating a new array of virtual `<li>` elements — each with their own inline event handler — on every state change, regardless of whether `props.items` has changed. Unless you're unhealthily obsessed with performance, you're not going to optimise that. There's no point. It's plenty fast enough. But you know what would be even faster? *Not doing that.*
|
||||
Here, we're generating a new array of virtual `<li>` elements — each with their own inline event handler — on every state change, regardless of whether `props.items` has changed. Unless you're unhealthily obsessed with performance, you're not going to optimise that. There's no point. It's plenty fast enough. But you know what would be even faster? _Not doing that._
|
||||
|
||||
<aside><p><a href="https://reactjs.org/docs/hooks-intro.html">React Hooks</a> doubles down on defaulting to doing unnecessary work, with <a href="https://twitter.com/thekitze/status/1078582382201131008">predictable results</a>.</p></aside>
|
||||
|
||||
@ -141,9 +122,8 @@ The danger of defaulting to doing unnecessary work, even if that work is trivial
|
||||
|
||||
Svelte is explicitly designed to prevent you from ending up in that situation.
|
||||
|
||||
|
||||
## Why do frameworks use the virtual DOM then?
|
||||
|
||||
It's important to understand that virtual DOM *isn't a feature*. It's a means to an end, the end being declarative, state-driven UI development. Virtual DOM is valuable because it allows you to build apps without thinking about state transitions, with performance that is *generally good enough*. That means less buggy code, and more time spent on creative tasks instead of tedious ones.
|
||||
It's important to understand that virtual DOM _isn't a feature_. It's a means to an end, the end being declarative, state-driven UI development. Virtual DOM is valuable because it allows you to build apps without thinking about state transitions, with performance that is _generally good enough_. That means less buggy code, and more time spent on creative tasks instead of tedious ones.
|
||||
|
||||
But it turns out that we can achieve a similar programming model without using virtual DOM — and that's where Svelte comes in.
|
@ -7,14 +7,14 @@ authorURL: https://twitter.com/Rich_Harris
|
||||
|
||||
Earlier this month, I had the privilege of appearing on [The Changelog](https://changelog.com/podcast), a podcast about software development. We had a fun (for me) and wide-ranging conversation:
|
||||
|
||||
* life as a coder inside a newsroom
|
||||
* the big compilers-as-frameworks trend
|
||||
* scalability
|
||||
* the [Great Divide](https://css-tricks.com/the-great-divide/)
|
||||
- life as a coder inside a newsroom
|
||||
- the big compilers-as-frameworks trend
|
||||
- scalability
|
||||
- the [Great Divide](https://css-tricks.com/the-great-divide/)
|
||||
|
||||
...and, most importantly, Svelte 3.
|
||||
|
||||
Unless you hang out in our [Discord server](https://svelte.dev/chat) or follow [@sveltejs](https://twitter.com/sveltejs) on Twitter, you might not know that Svelte 3 is just around the corner, and it's going to be a huge release. We've rethought the developer experience from the ground up, and while it *will* be a nuisance if you need to upgrade a Svelte 2 app (more on that soon) we think you're going to love it.
|
||||
Unless you hang out in our [Discord server](https://svelte.dev/chat) or follow [@sveltejs](https://twitter.com/sveltejs) on Twitter, you might not know that Svelte 3 is just around the corner, and it's going to be a huge release. We've rethought the developer experience from the ground up, and while it _will_ be a nuisance if you need to upgrade a Svelte 2 app (more on that soon) we think you're going to love it.
|
||||
|
||||
On the podcast [Adam](https://twitter.com/adamstac), [Jerod](https://twitter.com/jerodsanto) and I talk about some of the changes and why we're making them. You can listen here or on the [podcast page](https://changelog.com/podcast/332).
|
||||
|
@ -6,17 +6,17 @@ authorURL: https://twitter.com/Rich_Harris
|
||||
draft: true
|
||||
---
|
||||
|
||||
*__Coming soon__*
|
||||
_**Coming soon**_
|
||||
|
||||
This post will walk you through setting up your editor so that it recognises Svelte files:
|
||||
|
||||
* eslint-plugin-svelte3
|
||||
* svelte-vscode
|
||||
* associating .svelte files with HTML in VSCode, Sublime, etc.
|
||||
- eslint-plugin-svelte3
|
||||
- svelte-vscode
|
||||
- associating .svelte files with HTML in VSCode, Sublime, etc.
|
||||
|
||||
## Atom
|
||||
|
||||
To treat `*.svelte` files as HTML, open *__Edit → Config...__* and add the following lines to your `core` section:
|
||||
To treat `*.svelte` files as HTML, open _**Edit → Config...**_ and add the following lines to your `core` section:
|
||||
|
||||
```cson
|
||||
"*":
|
||||
@ -62,4 +62,4 @@ The [Svelte Framework Integration](https://plugins.jetbrains.com/plugin/12375-sv
|
||||
|
||||
Open any `.svelte` file.
|
||||
|
||||
Go to *__View → Syntax → Open all with current extension as... → HTML__*.
|
||||
Go to _**View → Syntax → Open all with current extension as... → HTML**_.
|
@ -11,10 +11,9 @@ If there are things that don't make sense, or that we're glossing over, feel fre
|
||||
|
||||
If you get stuck at any point following this guide, the best place to ask for help is in the [chatroom](https://svelte.dev/chat).
|
||||
|
||||
|
||||
## First things first
|
||||
|
||||
You'll be using the *command line*, also known as the terminal. On Windows, you can access it by running **Command Prompt** from the Start menu; on a Mac, hit `Cmd` and `Space` together to bring up **Spotlight**, then start typing `Terminal.app`. On most Linux systems, `Ctrl-Alt-T` brings up the command line.
|
||||
You'll be using the _command line_, also known as the terminal. On Windows, you can access it by running **Command Prompt** from the Start menu; on a Mac, hit `Cmd` and `Space` together to bring up **Spotlight**, then start typing `Terminal.app`. On most Linux systems, `Ctrl-Alt-T` brings up the command line.
|
||||
|
||||
The command line is a way to interact with your computer (or another computer! but that's a topic for another time) with more power and control than the GUI (graphical user interface) that most people use day-to-day.
|
||||
|
||||
@ -33,10 +32,9 @@ cd svelte-projects
|
||||
|
||||
A full introduction to the command line is out of the scope of this guide, but here are a few more useful commands:
|
||||
|
||||
* `cd ..` — navigates to the parent of the current directory
|
||||
* `cat my-file.txt` — on Mac/Linux (`type my-file.txt` on Windows), lists the contents of `my-file.txt`
|
||||
* `open .` (or `start .` on Windows) — opens the current directory in Finder or File Explorer
|
||||
|
||||
- `cd ..` — navigates to the parent of the current directory
|
||||
- `cat my-file.txt` — on Mac/Linux (`type my-file.txt` on Windows), lists the contents of `my-file.txt`
|
||||
- `open .` (or `start .` on Windows) — opens the current directory in Finder or File Explorer
|
||||
|
||||
## Installing Node.js
|
||||
|
||||
@ -44,16 +42,14 @@ A full introduction to the command line is out of the scope of this guide, but h
|
||||
|
||||
Once installed, you'll have access to three new commands:
|
||||
|
||||
* `node my-file.js` — runs the JavaScript in `my-file.js`
|
||||
* `npm [subcommand]` — [npm](https://www.npmjs.com/) is a way to install 'packages' that your application depends on, such as the [svelte](https://www.npmjs.com/package/svelte) package
|
||||
* `npx [subcommand]` — a convenient way to run programs available on npm without permanently installing them
|
||||
|
||||
- `node my-file.js` — runs the JavaScript in `my-file.js`
|
||||
- `npm [subcommand]` — [npm](https://www.npmjs.com/) is a way to install 'packages' that your application depends on, such as the [svelte](https://www.npmjs.com/package/svelte) package
|
||||
- `npx [subcommand]` — a convenient way to run programs available on npm without permanently installing them
|
||||
|
||||
## Installing a text editor
|
||||
|
||||
To write code, you need a good editor. The most popular choice is [Visual Studio Code](https://code.visualstudio.com/) or VSCode, and justifiably so — it's well-designed and fully-featured, and has a wealth of extensions ([including one for Svelte](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode), which provides syntax highlighting and diagnostic messages when you're writing components).
|
||||
|
||||
|
||||
## Creating a project
|
||||
|
||||
We're going to use the [Svelte + Vite](https://github.com/vitejs/vite/tree/main/packages/create-vite/template-svelte) template. You don't have to use a project template, but it means you have to do a lot less setup work.
|
||||
@ -78,11 +74,10 @@ npm run dev
|
||||
|
||||
Running the `dev` script starts a program called [Vite](https://vitejs.dev/). Vite's job is to take your application's source files, pass them to other programs (including Svelte, in our case) and convert them into the code that will actually run when you open the application in a browser.
|
||||
|
||||
Speaking of which, open a browser and navigate to http://localhost:5173. This is your application running on a local *web server* (hence 'localhost') on port 5173.
|
||||
Speaking of which, open a browser and navigate to http://localhost:5173. This is your application running on a local _web server_ (hence 'localhost') on port 5173.
|
||||
|
||||
Try changing `src/App.svelte` and saving it. The application will update with your changes.
|
||||
|
||||
|
||||
## Building your app
|
||||
|
||||
In the last step, we were running the app in 'development mode'. In dev mode, Svelte adds extra code that helps with debugging, and Vite skips the final step where your app's JavaScript is compressed.
|
@ -9,14 +9,13 @@ All code is buggy. It stands to reason, therefore, that the more code you have t
|
||||
|
||||
Writing more code also takes more time, leaving less time for other things like optimisation, nice-to-have features, or being outdoors instead of hunched over a laptop.
|
||||
|
||||
In fact it's widely acknowledged that [project development time](https://blog.codinghorror.com/diseconomies-of-scale-and-lines-of-code/) and [bug count](https://www.mayerdan.com/ruby/2012/11/11/bugs-per-line-of-code-ratio) grow *quadratically*, not linearly, with the size of a codebase. That tracks with our intuitions: a ten-line pull request will get a level of scrutiny rarely applied to a 100-line one. And once a given module becomes too big to fit on a single screen, the cognitive effort required to understand it increases significantly. We compensate by refactoring and adding comments — activities that almost always result in *more* code. It's a vicious cycle.
|
||||
In fact it's widely acknowledged that [project development time](https://blog.codinghorror.com/diseconomies-of-scale-and-lines-of-code/) and [bug count](https://www.mayerdan.com/ruby/2012/11/11/bugs-per-line-of-code-ratio) grow _quadratically_, not linearly, with the size of a codebase. That tracks with our intuitions: a ten-line pull request will get a level of scrutiny rarely applied to a 100-line one. And once a given module becomes too big to fit on a single screen, the cognitive effort required to understand it increases significantly. We compensate by refactoring and adding comments — activities that almost always result in _more_ code. It's a vicious cycle.
|
||||
|
||||
Yet while we obsess — rightly! — over performance numbers, bundle size and anything else we can measure, we rarely pay attention to the amount of code we're writing.
|
||||
|
||||
|
||||
## Readability is important
|
||||
|
||||
I'm certainly not claiming that we should use clever tricks to scrunch our code into the most compact form possible at the expense of readability. Nor am I claiming that reducing *lines* of code is necessarily a worthwhile goal, since it encourages turning readable code like this...
|
||||
I'm certainly not claiming that we should use clever tricks to scrunch our code into the most compact form possible at the expense of readability. Nor am I claiming that reducing _lines_ of code is necessarily a worthwhile goal, since it encourages turning readable code like this...
|
||||
|
||||
```js
|
||||
for (let i = 0; i <= 100; i += 1) {
|
||||
@ -34,7 +33,6 @@ for (let i = 0; i <= 100; i += 1) if (i % 2 === 0) console.log(`${i} is even`);
|
||||
|
||||
Instead, I'm claiming that we should favour languages and patterns that allow us to naturally write less code.
|
||||
|
||||
|
||||
## Yes, I'm talking about Svelte
|
||||
|
||||
Reducing the amount of code you have to write is an explicit goal of Svelte. To illustrate, let's look at a very simple component implemented in React, Vue and Svelte. First, the Svelte version:
|
||||
@ -66,10 +64,12 @@ export default () => {
|
||||
|
||||
return (
|
||||
<div>
|
||||
<input type="number" value={a} onChange={handleChangeA}/>
|
||||
<input type="number" value={b} onChange={handleChangeB}/>
|
||||
<input type="number" value={a} onChange={handleChangeA} />
|
||||
<input type="number" value={b} onChange={handleChangeB} />
|
||||
|
||||
<p>{a} + {b} = {a + b}</p>
|
||||
<p>
|
||||
{a} + {b} = {a + b}
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@ -77,7 +77,7 @@ export default () => {
|
||||
|
||||
Here's an equivalent component in Vue:
|
||||
|
||||
```html
|
||||
```svelte
|
||||
<template>
|
||||
<div>
|
||||
<input type="number" v-model.number="a">
|
||||
@ -105,8 +105,7 @@ Here's an equivalent component in Vue:
|
||||
|
||||
In other words, it takes 442 characters in React, and 263 characters in Vue, to achieve something that takes 145 characters in Svelte. The React version is literally three times larger!
|
||||
|
||||
It's unusual for the difference to be *quite* so obvious — in my experience, a React component is typically around 40% larger than its Svelte equivalent. Let's look at the features of Svelte's design that enable you to express ideas more concisely:
|
||||
|
||||
It's unusual for the difference to be _quite_ so obvious — in my experience, a React component is typically around 40% larger than its Svelte equivalent. Let's look at the features of Svelte's design that enable you to express ideas more concisely:
|
||||
|
||||
### Top-level elements
|
||||
|
||||
@ -114,7 +113,6 @@ In Svelte, a component can have as many top-level elements as you like. In React
|
||||
|
||||
In Vue, your markup must be wrapped in a `<template>` element, which I'd argue is redundant.
|
||||
|
||||
|
||||
### Bindings
|
||||
|
||||
In React, we have to respond to input events ourselves:
|
||||
@ -129,7 +127,6 @@ This isn't just boring plumbing that takes up extra space on the screen, it's al
|
||||
|
||||
Like Svelte, Vue does have a way of expressing the binding — the `v-model` attribute, though again we have to be careful to use `v-model.number` even though it's a numeric input.
|
||||
|
||||
|
||||
### State
|
||||
|
||||
In Svelte, you update local component state with an assignment operator:
|
||||
@ -152,13 +149,12 @@ function increment() {
|
||||
}
|
||||
```
|
||||
|
||||
This is much *noisier* — it expresses the exact same concept but with over 60% more characters. As you're reading the code, you have to do that much more work to understand the author's intent.
|
||||
This is much _noisier_ — it expresses the exact same concept but with over 60% more characters. As you're reading the code, you have to do that much more work to understand the author's intent.
|
||||
|
||||
In Vue, meanwhile, we have a default export with a `data` function that returns an object literal with properties corresponding to our local state. Things like helper functions and child components can't simply be imported and used in the template, but must instead be 'registered' by attaching them to the correct part of the default export.
|
||||
|
||||
|
||||
## Death to boilerplate
|
||||
|
||||
These are just some of the ways that Svelte helps you build user interfaces with a minimum of fuss. There are plenty of others — for example, [reactive declarations](/tutorial/reactive-declarations) essentially do the work of React's `useMemo`, `useCallback` and `useEffect` without the boilerplate (or indeed the garbage collection overhead of creating inline functions and arrays on each state change).
|
||||
|
||||
How? By choosing a different set of constraints. Because [Svelte is a compiler](/blog/frameworks-without-the-framework), we're not bound to the peculiarities of JavaScript: we can *design* a component authoring experience, rather than having to fit it around the semantics of the language. Paradoxically, this results in *more* idiomatic code — for example using variables naturally rather than via proxies or hooks — while delivering significantly more performant apps.
|
||||
How? By choosing a different set of constraints. Because [Svelte is a compiler](/blog/frameworks-without-the-framework), we're not bound to the peculiarities of JavaScript: we can _design_ a component authoring experience, rather than having to fit it around the semantics of the language. Paradoxically, this results in _more_ idiomatic code — for example using variables naturally rather than via proxies or hooks — while delivering significantly more performant apps.
|
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: "Svelte 3: Rethinking reactivity"
|
||||
title: 'Svelte 3: Rethinking reactivity'
|
||||
description: It's finally here
|
||||
author: Rich Harris
|
||||
authorURL: https://twitter.com/Rich_Harris
|
||||
@ -9,16 +9,15 @@ After several months of being just days away, we are over the moon to announce t
|
||||
|
||||
We think you're going to love it.
|
||||
|
||||
|
||||
## What is Svelte?
|
||||
|
||||
Svelte is a component framework — like React or Vue — but with an important difference. Traditional frameworks allow you to write *declarative* state-driven code, but there's a penalty: the browser must do extra work to convert those declarative structures into DOM operations, using techniques like [virtual DOM diffing](/blog/virtual-dom-is-pure-overhead) that eat into your frame budget and tax the garbage collector.
|
||||
Svelte is a component framework — like React or Vue — but with an important difference. Traditional frameworks allow you to write _declarative_ state-driven code, but there's a penalty: the browser must do extra work to convert those declarative structures into DOM operations, using techniques like [virtual DOM diffing](/blog/virtual-dom-is-pure-overhead) that eat into your frame budget and tax the garbage collector.
|
||||
|
||||
Instead, Svelte runs at *build time*, converting your components into highly efficient *imperative* code that surgically updates the DOM. As a result, you're able to write ambitious applications with excellent performance characteristics.
|
||||
Instead, Svelte runs at _build time_, converting your components into highly efficient _imperative_ code that surgically updates the DOM. As a result, you're able to write ambitious applications with excellent performance characteristics.
|
||||
|
||||
The first version of Svelte was all about [testing a hypothesis](/blog/frameworks-without-the-framework) — that a purpose-built compiler could generate rock-solid code that delivered a great user experience. The second was a small upgrade that tidied things up a bit.
|
||||
|
||||
Version 3 is a significant overhaul. Our focus for the last five or six months has been on delivering an outstanding *developer* experience. It's now possible to write components with [significantly less boilerplate](/blog/write-less-code) than you'll find elsewhere. Try the brand new [tutorial](/tutorial) and see what we mean — if you're familiar with other frameworks we think you'll be pleasantly surprised.
|
||||
Version 3 is a significant overhaul. Our focus for the last five or six months has been on delivering an outstanding _developer_ experience. It's now possible to write components with [significantly less boilerplate](/blog/write-less-code) than you'll find elsewhere. Try the brand new [tutorial](/tutorial) and see what we mean — if you're familiar with other frameworks we think you'll be pleasantly surprised.
|
||||
|
||||
To make that possible we first needed to rethink the concept at the heart of modern UI frameworks: reactivity.
|
||||
|
||||
@ -32,7 +31,6 @@ To make that possible we first needed to rethink the concept at the heart of mod
|
||||
</figure>
|
||||
</div>
|
||||
|
||||
|
||||
## Moving reactivity into the language
|
||||
|
||||
In old Svelte, you would tell the computer that some state had changed by calling the `this.set` method:
|
||||
@ -44,7 +42,7 @@ this.set({
|
||||
});
|
||||
```
|
||||
|
||||
That would cause the component to *react*. Speaking of which, `this.set` is almost identical to the `this.setState` method used in classical (pre-hooks) React:
|
||||
That would cause the component to _react_. Speaking of which, `this.set` is almost identical to the `this.setState` method used in classical (pre-hooks) React:
|
||||
|
||||
```js
|
||||
const { count } = this.state;
|
||||
@ -61,7 +59,7 @@ There are some important technical differences (as I explain in the video above,
|
||||
|
||||
That all changed with the advent of [hooks](https://reactjs.org/docs/hooks-intro.html), which handle state in a very different fashion. Many frameworks started experimenting with their own implementations of hooks, but we quickly concluded it wasn't a direction we wanted to go in. Hooks have some intriguing properties, but they also involve some unnatural code and create unnecessary work for the garbage collector. For a framework that's used in [embedded devices](https://mobile.twitter.com/sveltejs/status/1088500539640418304) as well as animation-heavy interactives, that's no good.
|
||||
|
||||
So we took a step back and asked ourselves what kind of API would work for us... and realised that the best API is no API at all. We can just *use the language*. Updating some `count` value — and all the things that depend on it — should be as simple as this:
|
||||
So we took a step back and asked ourselves what kind of API would work for us... and realised that the best API is no API at all. We can just _use the language_. Updating some `count` value — and all the things that depend on it — should be as simple as this:
|
||||
|
||||
```js
|
||||
count += 1;
|
||||
@ -70,28 +68,26 @@ count += 1;
|
||||
Since we're a compiler, we can do that by instrumenting assignments behind the scenes:
|
||||
|
||||
```js
|
||||
count += 1; $$invalidate('count', count);
|
||||
count += 1;
|
||||
$$invalidate('count', count);
|
||||
```
|
||||
|
||||
Importantly, we can do all this without the overhead and complexity of using proxies or accessors. It's just a variable.
|
||||
|
||||
|
||||
## New look
|
||||
|
||||
Your components aren't the only thing that's getting a facelift. Svelte itself has a completely new look and feel, thanks to the amazing design work of [Achim Vedam](https://vedam.de/) who created our new logo and website, which has moved from [svelte.technology](https://svelte.technology) to [svelte.dev](https://svelte.dev).
|
||||
|
||||
We've also changed our tagline, from 'The magical disappearing UI framework' to 'Cybernetically enhanced web apps'. Svelte has many aspects — outstanding performance, small bundles, accessibility, built-in style encapsulation, declarative transitions, ease of use, the fact that it's a compiler, etc — that focusing on any one of them feels like an injustice to the others. 'Cybernetically enhanced' is designed to instead evoke Svelte's overarching philosophy that our tools should work as intelligent extensions of ourselves — hopefully with a retro, William Gibson-esque twist.
|
||||
|
||||
|
||||
## Upgrading from version 2
|
||||
|
||||
If you're an existing Svelte 2 user, I'm afraid there is going to be some manual upgrading involved. In the coming days we'll release a migration guide and an updated version of [svelte-upgrade](https://github.com/sveltejs/svelte-upgrade) which will do the best it can to automate the process, but this *is* a significant change and not everything can be handled automatically.
|
||||
If you're an existing Svelte 2 user, I'm afraid there is going to be some manual upgrading involved. In the coming days we'll release a migration guide and an updated version of [svelte-upgrade](https://github.com/sveltejs/svelte-upgrade) which will do the best it can to automate the process, but this _is_ a significant change and not everything can be handled automatically.
|
||||
|
||||
We don't take this lightly: hopefully once you've experienced Svelte 3 you'll understand why we felt it was necessary to break with the past.
|
||||
|
||||
|
||||
## Still to come
|
||||
|
||||
As grueling as this release has been, we're nowhere near finished. We have a ton of ideas for generating smarter, more compact code, and a long feature wish-list. [Sapper](https://sapper.svelte.dev), our Next.js-style app framework, is still in the middle of being updated to use Svelte 3. The [Svelte Native](https://svelte-native.technology/) community project, which allows you to write Android and iOS apps in Svelte, is making solid progress but deserves more complete support from core. We don't yet have the bounty of editor extensions, syntax highlighters, component kits, devtools and so on that other frameworks have, and we should fix that. We *really* want to add first-class TypeScript support.
|
||||
As grueling as this release has been, we're nowhere near finished. We have a ton of ideas for generating smarter, more compact code, and a long feature wish-list. [Sapper](https://sapper.svelte.dev), our Next.js-style app framework, is still in the middle of being updated to use Svelte 3. The [Svelte Native](https://svelte-native.technology/) community project, which allows you to write Android and iOS apps in Svelte, is making solid progress but deserves more complete support from core. We don't yet have the bounty of editor extensions, syntax highlighters, component kits, devtools and so on that other frameworks have, and we should fix that. We _really_ want to add first-class TypeScript support.
|
||||
|
||||
But in the meantime we think Svelte 3 is the best way to build web apps yet. Take an hour to go through the [tutorial](/tutorial) and we hope to convince you of the same. Either way, we'd love to see you in our [Discord chatroom](https://svelte.dev/chat) and on [GitHub](https://github.com/sveltejs/svelte) — everyone is welcome, especially you.
|
@ -14,7 +14,6 @@ We think it'll give you a much nicer development experience — one that also sc
|
||||
<figcaption>Image of TypeScript + Svelte in VS Code (theme is <a href="https://marketplace.visualstudio.com/items?itemName=karyfoundation.theme-karyfoundation-themes">Kary Pro</a>.)</figcaption>
|
||||
</figure>
|
||||
|
||||
|
||||
## Try it now
|
||||
|
||||
You can start a new Svelte TypeScript project using the [normal template](https://github.com/sveltejs/template) and by running `node scripts/setupTypeScript.js` before you do anything else:
|
||||
@ -36,10 +35,10 @@ A week before COVID was declared a pandemic, [I pitched a consolidation](https:/
|
||||
|
||||
When we say that Svelte now supports TypeScript, we mean a few different things:
|
||||
|
||||
* You can use TypeScript inside your `<script>` blocks — just add the `lang="ts"` attribute
|
||||
* Components with TypeScript can be type-checked with the `svelte-check` command
|
||||
* You get autocompletion hints and type-checking as you're writing components, even in expressions inside markup
|
||||
* TypeScript files understand the Svelte component API — no more red squiggles when you import a `.svelte` file into a `.ts` module
|
||||
- You can use TypeScript inside your `<script>` blocks — just add the `lang="ts"` attribute
|
||||
- Components with TypeScript can be type-checked with the `svelte-check` command
|
||||
- You get autocompletion hints and type-checking as you're writing components, even in expressions inside markup
|
||||
- TypeScript files understand the Svelte component API — no more red squiggles when you import a `.svelte` file into a `.ts` module
|
||||
|
||||
### How does it work?
|
||||
|
||||
@ -51,14 +50,12 @@ The Svelte compiler support for TypeScript is handled by [Christian Kaisermann](
|
||||
|
||||
For the editor level, we took inspiration from [Pine's](https://github.com/octref) work in the [Vue](https://vuejs.org) ecosystem via [Vetur](https://github.com/vuejs/vetur). Vetur provides an [LSP](https://github.com/vuejs/vetur/blob/master/server), a VS Code extension and a [CLI](https://github.com/vuejs/vetur/blob/master/vti). Svelte now also has an [LSP](https://github.com/sveltejs/language-tools/blob/master/packages/language-server), a [VS Code extension](https://github.com/sveltejs/language-tools/blob/master/packages/svelte-vscode) and a [CLI](https://github.com/sveltejs/language-tools/blob/master/packages/svelte-check).
|
||||
|
||||
|
||||
### `*.svelte` Introspection
|
||||
|
||||
For the official Svelte VS Code extension, we built off the foundations which [James Birtles](https://github.com/UnwrittenFun) has created in [`UnwrittenFun/svelte-vscode`](https://github.com/UnwrittenFun/svelte-vscode) and [`UnwrittenFun/svelte-language-server`](https://github.com/UnwrittenFun/svelte-language-server/).
|
||||
|
||||
[Simon Holthausen](https://github.com/dummdidumm) and [Lyu, Wei-Da](https://github.com/jasonlyu123) have done great work improving the JavaScript and TypeScript introspection, including integrating [@halfnelson](https://github.com/halfnelson)'s [svelte2tsx](https://github.com/sveltejs/language-tools/tree/master/packages/svelte2tsx#svelte2tsx) which powers understanding the props on components in your codebase.
|
||||
|
||||
|
||||
## Adding TypeScript to an existing project
|
||||
|
||||
Before getting started, add the dependencies:
|
||||
@ -94,10 +91,10 @@ To configure TypeScript, you will need to create a `tsconfig.json` in the root o
|
||||
|
||||
```json
|
||||
{
|
||||
"extends": "@tsconfig/svelte/tsconfig.json",
|
||||
"extends": "@tsconfig/svelte/tsconfig.json",
|
||||
|
||||
"include": ["src/**/*", "src/node_modules"],
|
||||
"exclude": ["node_modules/*", "__sapper__/*", "public/*"],
|
||||
"include": ["src/**/*", "src/node_modules"],
|
||||
"exclude": ["node_modules/*", "__sapper__/*", "public/*"]
|
||||
}
|
||||
```
|
||||
|
@ -8,6 +8,7 @@ authorURL: https://dreamindani.com
|
||||
Welcome to the first edition of our "What's new in Svelte" series! We'll try to make this a monthly blog post in which you'll find out about new features, bug fixes, and a showcase of Svelte projects from around the community.
|
||||
|
||||
## New features
|
||||
|
||||
1. `use:obj.method` allows functions defined within objects to be used within actions ([Example](https://svelte.dev/repl/c305722adb4a4545b27b198ea8ff9bde?version=3.27.0), **3.26.0**, warning removed in **3.27.0**)
|
||||
2. `_` is now supported as a "numerical separator", similar to a `.` or `,` ([Example](https://svelte.dev/repl/844c39e91d1248649fe54af839fab570?version=3.26.0), **3.26.0**)
|
||||
3. `import.meta` now works in template expressions ([Example](https://svelte.dev/repl/9630de41957a4c80a4fce264360a6bc7?version=3.26.0), **3.26.0**)
|
||||
@ -15,21 +16,23 @@ Welcome to the first edition of our "What's new in Svelte" series! We'll try to
|
||||
5. The `{#key}` block is now available to key arbitrary content on an expression. Whenever the expression changes, the contents inside the `{#key}` block will be destroyed and recreated. For an in-depth explanation and to find out how it's implemented, check out the [new blog post](https://lihautan.com/contributing-to-svelte-implement-key-block/) of Svelte Team member Tan Li Hau. ([More info](https://github.com/sveltejs/svelte/issues/1469), **3.29.0**)
|
||||
6. Slots can now be forwarded through child components! This used to only be possible by adding extra wrapper `<div>`s ([More info](https://github.com/sveltejs/svelte/issues/2079), **3.29.0**)
|
||||
7. When using TypeScript, you can now type the `createEventDispatcher` method:
|
||||
```html
|
||||
|
||||
```svelte
|
||||
<script lang="ts">
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
|
||||
const dispatch = createEventDispatcher<{
|
||||
/**
|
||||
* you can also add docs
|
||||
*/
|
||||
checked: boolean; // Will translate to `CustomEvent<boolean>`
|
||||
hello: string;
|
||||
}>();
|
||||
const dispatch = createEventDispatcher<{
|
||||
/**
|
||||
* you can also add docs
|
||||
*/
|
||||
checked: boolean; // Will translate to `CustomEvent<boolean>`
|
||||
hello: string;
|
||||
}>();
|
||||
|
||||
// ...
|
||||
// ...
|
||||
</script>
|
||||
```
|
||||
|
||||
This will make sure that you can invoke dispatch only with the specified event names and its types. The Svelte for VS Code extension was also updated to deal with this new feature. It will provide strong typings for these events as well as autocompletion and hover information.
|
||||
|
||||
**New from Sapper!**
|
||||
@ -37,44 +40,47 @@ Sapper 0.28.9 just came out. The highlights from it include much better support
|
||||
|
||||
In addition, Sapper's CSS handling has been rewritten over the course of recent releases in order to fix existing CSS handling bugs, refactor the CSS handling to occur entirely within a Rollup plugin, and remove the need internally to register CSS in the routing system. Congrats and thank you to the folks working on Sapper for all their solid work!
|
||||
|
||||
|
||||
## Impactful bug fixes
|
||||
|
||||
- CSS compilation will no longer remove rules for the `open` attribute on `<details>` elements ([Example](https://svelte.dev/repl/ab4c0c177d1f4fab92f46eb8539cea9a?version=3.26.0), **3.26.0**)
|
||||
- `prettier-plugin-svelte` will do a better job now at dealing with whitespaces, especially around inline elements. It will also preserve formatting inside `<pre>` tags and will no longer format languages which are not supported by Prettier, like SASS, Pug or Stylus.
|
||||
|
||||
|
||||
## Coming up
|
||||
|
||||
- [Svelte Summit](https://sveltesummit.com/), Svelte's second global online conference, is taking place on October 18! Sign up for free to get reminders and talk updates!
|
||||
|
||||
For all the features and bugfixes see the CHANGELOG for [Svelte](https://github.com/sveltejs/svelte/blob/master/CHANGELOG.md) and [Sapper](https://github.com/sveltejs/sapper/blob/master/CHANGELOG.md).
|
||||
|
||||
|
||||
---
|
||||
|
||||
## Svelte Showcase
|
||||
|
||||
- [This CustomMenu example](https://svelte.dev/repl/3a33725c3adb4f57b46b597f9dade0c1?version=3.25.0) demos how to replace the OS right-click menu
|
||||
- [GitHub Tetris](https://svelte.dev/repl/cc1eaa7c66964fedb5e70e3ecbbaa0e1?version=3.25.1) lets you play a Tetris-like game in a git commit history
|
||||
- [Who are my representatives?](https://whoaremyrepresentatives.us/) is a website built with Svelte to help US residents get more info on their congressional representatives
|
||||
- [Pick Palette](https://github.com/bluwy/pick-palette) is a color palette manager made with Svelte!
|
||||
|
||||
### In-depth learning:
|
||||
|
||||
- [Svelte 3 Up and Running](https://www.amazon.com/dp/B08D6T6BKS/ref=cm_sw_r_tw_dp_x_OQMtFb3GPQCB2) is a new book about building production-ready static web apps with Svelte 3
|
||||
- [Sapper Tutorial (Crash Course)](https://www.youtube.com/playlist?list=PL4cUxeGkcC9gdr4Qhx83gBBcID-KMe-PQ) walks through the ins-and-outs of Sapper, the Svelte-powered application framework
|
||||
- [Svelte Society Day France](https://france.sveltesociety.dev/) happened September 27th featuring a wide variety of topics all in French! You can find the full recording [here](https://www.youtube.com/watch?v=aS1TQ155JK4).
|
||||
|
||||
### Plug-and-play components:
|
||||
|
||||
- [svelte-zoom](https://github.com/vaheqelyan/svelte-zoom) brings "nearly native" pan-and-zoom to images on desktop and mobile
|
||||
- [svelte-materialify](https://github.com/TheComputerM/svelte-materialify) is a Material component library for Svelte with over 50 components
|
||||
- [svelte-undoable](https://github.com/macfja/svelte-undoable) makes it easy to introduce undo and redo functionality using `bind:`
|
||||
- [This Tilt component](https://svelte.dev/repl/7b23ad9d2693424482cd411b0378b55b?version=3.24.1) implements a common UX pattern where the hovered element tilts to follow the mouse
|
||||
|
||||
### Lots of examples of how use JS tech came out this month:
|
||||
- [Sapper with PostCSS and Tailwind](https://codechips.me/sapper-with-postcss-and-tailwind/)
|
||||
- [PrismJS (Code block syntax highlighting)](https://github.com/phptuts/Svelte-PrismJS)
|
||||
- [Filepond (Drag-and-drop file upload)](https://github.com/pqina/svelte-filepond)
|
||||
- [Ionic (UI Components)](https://github.com/Tommertom/svelte-ionic-app)
|
||||
- [Pell (WYSIWYG Editor)](https://github.com/Demonicious/svelte-pell/)
|
||||
- [Leaflet (Mapping)](https://github.com/anoram/leaflet-svelte)
|
||||
|
||||
- [Sapper with PostCSS and Tailwind](https://codechips.me/sapper-with-postcss-and-tailwind/)
|
||||
- [PrismJS (Code block syntax highlighting)](https://github.com/phptuts/Svelte-PrismJS)
|
||||
- [Filepond (Drag-and-drop file upload)](https://github.com/pqina/svelte-filepond)
|
||||
- [Ionic (UI Components)](https://github.com/Tommertom/svelte-ionic-app)
|
||||
- [Pell (WYSIWYG Editor)](https://github.com/Demonicious/svelte-pell/)
|
||||
- [Leaflet (Mapping)](https://github.com/anoram/leaflet-svelte)
|
||||
|
||||
**Reminder**: There's a [Svelte integrations repo](https://github.com/sveltejs/integrations) that demonstrates ways to incorporate Svelte into your stack (and vice versa). If you've got questions on how to use a particular piece of tech with Svelte, you may find your answer there... and if you've gotten something to work with Svelte, consider contributing!
|
||||
|
@ -10,7 +10,7 @@ Welcome back to the "What's new in Svelte" series! This month, we're covering ne
|
||||
## New features & impactful bug fixes
|
||||
|
||||
1. Destructuring Promises now works as expected by using the `{#await}` syntax
|
||||
(**3.29.3**, [Example](https://svelte.dev/repl/3fd4e2cecfa14d629961478f1dac2445?version=3.29.3))
|
||||
(**3.29.3**, [Example](https://svelte.dev/repl/3fd4e2cecfa14d629961478f1dac2445?version=3.29.3))
|
||||
2. Slot forwarding (released in 3.29.0) should no longer hang during compilation (**3.29.3**, [Example](https://svelte.dev/repl/29959e70103f4868a6525c0734934936?version=3.29.3))
|
||||
3. Better typings for the `get` function in `svelte/store` and on lifecycle hooks (**3.29.1**)
|
||||
|
||||
@ -18,17 +18,17 @@ Welcome back to the "What's new in Svelte" series! This month, we're covering ne
|
||||
|
||||
Sapper got some new types in its `preload` function, which will make typing easier if you are using TypeScript. See the [Sapper docs](https://sapper.svelte.dev/docs#Typing_the_function) on how to use them. There also were fixes to `preload` links in exported sites. Route layouts got a few fixes too - including ensuring CSS is applied to nested route layouts. You can also better organize your files now that extensions with multiple dots are supported. (**0.28.10**)
|
||||
|
||||
|
||||
For all the features and bugfixes see the CHANGELOGs for [Svelte](https://github.com/sveltejs/svelte/blob/master/CHANGELOG.md) and [Sapper](https://github.com/sveltejs/sapper/blob/master/CHANGELOG.md).
|
||||
|
||||
|
||||
## [Svelte Summit](https://sveltesummit.com/) was Svelte-tacular!
|
||||
|
||||
- Rich Harris demoed the possible future of Svelte development in a talk titled "Futuristic Web Development". The not-yet-public project is called SvelteKit (name may change) and will bring a first-class developer experience and more flexibility for build outputs. If you want to get the full sneak-peek, [check out the video](https://www.youtube.com/watch?v=qSfdtmcZ4d0).
|
||||
- 17 speakers made the best of the conference's virtual format... From floating heads to seamless demos, Svelte developers from every skill level will find something of interest in this year's [YouTube playlist](https://www.youtube.com/playlist?list=PL8bMgX1kyZThM1sbYCoWdTcpiYysJsSeu)
|
||||
|
||||
---
|
||||
|
||||
## Community Showcase
|
||||
|
||||
- [Svelte Lab](https://sveltelab.app/) showcases a variety of components, visualizations and interactions that can be achieved in Svelte. You can click into any component to see its source or edit it, using the site's built-in REPL
|
||||
- [svelte-electron-boilerplate](https://github.com/hjalmar/svelte-electron-boilerplate) is a fast way to get up and running with a Svelte app built in the desktop javascript framework, Electron
|
||||
- [React Hooks in Svelte](https://github.com/joshnuss/react-hooks-in-svelte) showcases examples of common React Hooks ported to Svelte.
|
@ -23,26 +23,23 @@ This was slightly tongue-in-cheek — as the talk explains, it's really more of
|
||||
</figure>
|
||||
</div>
|
||||
|
||||
|
||||
## What's Sapper?
|
||||
|
||||
[Sapper](https://sapper.svelte.dev) is an *app framework* (or 'metaframework') built on top of Svelte (which is a *component* framework). Its job is to make it easy to build Svelte apps with all the modern best practices like server-side rendering (SSR) and code-splitting, and to provide a project structure that makes development productive and fun. It uses *filesystem-based routing* (as popularised by [Next](https://nextjs.org/) and adopted by many other frameworks, albeit with some enhancements) — your project's file structure mirrors the structure of the app itself.
|
||||
[Sapper](https://sapper.svelte.dev) is an _app framework_ (or 'metaframework') built on top of Svelte (which is a _component_ framework). Its job is to make it easy to build Svelte apps with all the modern best practices like server-side rendering (SSR) and code-splitting, and to provide a project structure that makes development productive and fun. It uses _filesystem-based routing_ (as popularised by [Next](https://nextjs.org/) and adopted by many other frameworks, albeit with some enhancements) — your project's file structure mirrors the structure of the app itself.
|
||||
|
||||
While the Svelte homepage and documentation encourages you to [degit](https://github.com/Rich-Harris/degit) the [sveltejs/template](https://github.com/sveltejs/template) repo to start building an app, Sapper has long been our recommended way to build apps; this very blog post is (at the time of writing!) rendered with Sapper.
|
||||
|
||||
|
||||
## Why are we migrating to something new?
|
||||
|
||||
Firstly, the distinction between [sveltejs/template](https://github.com/sveltejs/template) and [sveltejs/sapper-template](https://github.com/sveltejs/sapper-template) is confusing, particularly to newcomers to Svelte. Having a single recommended way to start building apps with Svelte will bring enormous benefits: we simplify onboarding, reduce the maintenance and support burden, and can potentially begin to explore the new possibilities that are unlocked by having a predictable project structure. (This last part is deliberately vague because it will take time to fully understand what those possibilities are.)
|
||||
|
||||
Aside from all that, we've been tempted by the thought of rewriting Sapper for a while. This is partly because the codebase has become a little unkempt over the years ([Sapper started in 2017](/blog/sapper-towards-the-ideal-web-app-framework)), but mostly because the web has changed a lot recently, and it's time to rethink some of our foundational assumptions.
|
||||
|
||||
|
||||
## How is this new thing different?
|
||||
|
||||
The first of those foundational assumptions is that you need to use a module bundler like [webpack](https://webpack.js.org/) or [Rollup](https://rollupjs.org/) to build apps. These tools trace the dependency graph of your application, analysing and transforming code along the way (turning Svelte components to JS modules, for example), in order to create bundles of code that can run anywhere. As the original creator of Rollup, I can attest that it is a surprisingly complex problem with fiendish edge cases.
|
||||
|
||||
You certainly needed a bundler several years ago, because browsers didn't natively support the `import` keyword, but it's much less true today. Right now, we're seeing the rise of the *unbundled development* workflow, which is radically simpler: instead of eagerly bundling your app, a dev server can serve modules (converted to JavaScript, if necessary) *on-demand*, meaning startup is essentially instantaneous however large your app becomes.
|
||||
You certainly needed a bundler several years ago, because browsers didn't natively support the `import` keyword, but it's much less true today. Right now, we're seeing the rise of the _unbundled development_ workflow, which is radically simpler: instead of eagerly bundling your app, a dev server can serve modules (converted to JavaScript, if necessary) _on-demand_, meaning startup is essentially instantaneous however large your app becomes.
|
||||
|
||||
[Snowpack](https://www.snowpack.dev/) is at the vanguard of this movement, and it's what powers SvelteKit. It's astonishingly fast, and has a beautiful development experience (hot module reloading, error overlays and so on), and we've been working closely with the Snowpack team on features like SSR. The hot module reloading is particularly revelatory if you're used to using Sapper with Rollup (which has never had first-class HMR support owing to its architecture, which prioritises the most efficient output).
|
||||
|
||||
@ -50,13 +47,12 @@ That's not to say we're abandoning bundlers altogether. It's still essential to
|
||||
|
||||
The other foundational assumption is that a server-rendered app needs, well, a server. Sapper effectively has two modes — `sapper build`, which creates a standalone app that has to run on a Node server, and `sapper export` which bakes your app out as a collection of static files suitable for hosting on services like GitHub Pages.
|
||||
|
||||
Static files can go pretty much anywhere, but running a Node server (and monitoring/scaling it etc) is less straightforward. Nowadays we're witnessing a shift towards *serverless platforms*, in which you as the app author don't need to think about the server your code is running on, with all the attendant complexity. You can get Sapper apps running on serverless platforms, thanks to things like [vercel-sapper](https://github.com/thgh/vercel-sapper), but it's certainly not what you'd call idiomatic.
|
||||
Static files can go pretty much anywhere, but running a Node server (and monitoring/scaling it etc) is less straightforward. Nowadays we're witnessing a shift towards _serverless platforms_, in which you as the app author don't need to think about the server your code is running on, with all the attendant complexity. You can get Sapper apps running on serverless platforms, thanks to things like [vercel-sapper](https://github.com/thgh/vercel-sapper), but it's certainly not what you'd call idiomatic.
|
||||
|
||||
<aside><p>It'll still be possible to create both Node apps and fully pre-rendered (aka exported) sites</a></p></aside>
|
||||
|
||||
SvelteKit fully embraces the serverless paradigm, and will launch with support for all the major serverless providers, with an 'adapter' API for targeting any platforms that we don't officially cater to. In addition, we'll be able to do partial pre-rendering, which means that static pages can be generated at build time but dynamic ones get rendered on-demand.
|
||||
|
||||
|
||||
## When can I start using it?
|
||||
|
||||
If you're feeling brave, you can start right now:
|
||||
@ -71,19 +67,16 @@ We don't recommend it though! There are no docs, and we won't be able to offer a
|
||||
|
||||
The work is being done in a private monorepo while we're still in exploration mode. Our plan is to get a public beta ready and announce it here once we've closed a few issues — the repo itself will remain private at that time, but we'll create a place to collect feedback from the YOLO crowd. After that, we'll work towards a 1.0 release which will involve opening the repo up.
|
||||
|
||||
I'm not going to make any firm promises about timings, because I don't like to break promises. But I *think* we're talking about weeks rather than months.
|
||||
|
||||
I'm not going to make any firm promises about timings, because I don't like to break promises. But I _think_ we're talking about weeks rather than months.
|
||||
|
||||
## What if I don't want to use SvelteKit?
|
||||
|
||||
You won't have to — it will always be possible to use Svelte as a standalone package or via a bundler integration like [rollup-plugin-svelte](https://github.com/sveltejs/rollup-plugin-svelte). We think it's essential that you can bend Svelte to fit your workflow, however esoteric, and use third-party app frameworks like [Elder.js](https://github.com/Elderjs/elderjs), [Routify](https://routify.dev/), [Plenti](https://plenti.co/), [Crown](https://crownframework.com/), [JungleJS](https://www.junglejs.org/) and others.
|
||||
|
||||
|
||||
## TypeScript?
|
||||
|
||||
Don't worry, we won't launch without full TypeScript support.
|
||||
|
||||
|
||||
## How can I migrate my existing Sapper apps?
|
||||
|
||||
For the most part, it should be relatively straightforward to migrate a Sapper codebase.
|
||||
@ -92,12 +85,10 @@ There are some unavoidable changes (being able to run on serverless platforms me
|
||||
|
||||
Detailed migration guides will accompany the 1.0 launch.
|
||||
|
||||
|
||||
## How can I contribute?
|
||||
|
||||
Keep your eyes peeled for announcements about when we'll launch the public beta and open up the repo. (Also, blog post TODO but I would be remiss if I didn't mention that we now have an [OpenCollective](https://opencollective.com/svelte) where you can contribute financially to the project if it's been valuable to you. Many, many thanks to those of you who already have.)
|
||||
|
||||
|
||||
## Where can I learn more?
|
||||
|
||||
Follow [@sveltejs](https://twitter.com/sveltejs) and [@SvelteSociety](https://twitter.com/SvelteSociety) on Twitter, and visit [svelte.dev/chat](https://svelte.dev/chat). You should also subscribe to [Svelte Radio](https://www.svelteradio.com/), where Kevin and his co-hosts will grill me about this project on an upcoming episode (and between now and next week when we record it, [reply to this Twitter thread](https://twitter.com/Rich_Harris/status/1323376048571121665) with your additional questions).
|
||||
Follow [@sveltejs](https://twitter.com/sveltejs) and [@SvelteSociety](https://twitter.com/SvelteSociety) on Twitter, and visit [svelte.dev/chat](https://svelte.dev/chat). You should also subscribe to [Svelte Radio](https://www.svelteradio.com/), where Kevin and his co-hosts will grill me about this project on an upcoming episode (and between now and next week when we record it, [reply to this Twitter thread](https://twitter.com/Rich_Harris/status/1323376048571121665) with your additional questions).
|
@ -9,18 +9,19 @@ It's the last "What's new in Svelte" of the year and there's lots to celebrate!
|
||||
|
||||
## New features & impactful bug fixes
|
||||
|
||||
1. `$$props`, `$$restProps`, and `$$slots` are all now supported in custom web components (**3.29.5**, [Example](https://svelte.dev/repl/ad8e6f39cd20403dacd1be84d71e498d?version=3.29.5)) and `slot` components now support spread props: `<slot {...foo} />` (**3.30.0**)
|
||||
1. `$$props`, `$$restProps`, and `$$slots` are all now supported in custom web components (**3.29.5**, [Example](https://svelte.dev/repl/ad8e6f39cd20403dacd1be84d71e498d?version=3.29.5)) and `slot` components now support spread props: `<slot {...foo} />` (**3.30.0**)
|
||||
2. A new `hasContext` lifecycle function makes it easy to check whether a `key` has been set in the context of a parent component (**3.30.0** & **3.30.1**, [Docs](https://svelte.dev/docs#run-time-svelte-hascontext))
|
||||
3. There is now a new `SvelteComponentTyped` class which makes it easier to add strongly typed components that extend base Svelte components. Component library and framework authors rejoice! An example: `export class YourComponent extends SvelteComponentTyped<{aProp: boolean}, {click: MouseEvent}, {default: {aSlot: string}}> {}` (**3.31.0**, [RFC](https://github.com/sveltejs/rfcs/pull/37))
|
||||
4. Transitions within `{:else}` blocks should now complete successfully (**3.29.5**, [Example](https://svelte.dev/repl/49cef205e5da459594ef2eafcbd41593?version=3.29.5))
|
||||
5. Svelte now includes an export map, which explicitly states which files can be imported from its npm package (**3.29.5** with some fixes in **3.29.6**, **3.29.7** and **3.30.0**)
|
||||
6. `rollup-plugin-svelte` had a new [7.0.0 release](https://github.com/sveltejs/rollup-plugin-svelte/blob/master/CHANGELOG.md). The biggest change is that the `css` option was removed. Users who were using that option should add another plugin like `rollup-plugin-css-only` as demonstrated [in the template](https://github.com/sveltejs/template/blob/5b1135c286f7a649daa99825a077586655051649/rollup.config.js#L48)
|
||||
|
||||
|
||||
## What's going on in Sapper?
|
||||
|
||||
Lots of new TypeScript definition improvements to make editing Sapper apps even easier! CSS for dynamic imports also should now work in `client.js` files. (Unreleased)
|
||||
|
||||
## What's the deal with SvelteKit?
|
||||
|
||||
We're glad you asked! If you didn't catch Rich's blog post from early last month, [you can find it here](https://svelte.dev/blog/whats-the-deal-with-sveltekit)!
|
||||
|
||||
For all the features and bugfixes see the CHANGELOGs for [Svelte](https://github.com/sveltejs/svelte/blob/master/CHANGELOG.md) and [Sapper](https://github.com/sveltejs/sapper/blob/master/CHANGELOG.md).
|
||||
@ -30,6 +31,7 @@ For all the features and bugfixes see the CHANGELOGs for [Svelte](https://github
|
||||
## Community Showcase
|
||||
|
||||
**Apps & Sites**
|
||||
|
||||
- [narration.studio](https://narration.studio/) (Chrome Only) is an automatic in-browser audio recording & editing platform for voice over narration.
|
||||
- [Vippet](https://vippet.netlify.app/) is a video recording and editing tool for the browser.
|
||||
- [Pattern Monster](https://pattern.monster/) is a simple online pattern generator to create repeatable SVG patterns.
|
||||
@ -39,19 +41,21 @@ For all the features and bugfixes see the CHANGELOGs for [Svelte](https://github
|
||||
- [svelte-presenter](https://github.com/stephane-vanraes/svelte-presenter) lets you quickly make good looking presentations using Svelte and mdsvex.
|
||||
|
||||
**Demos**
|
||||
|
||||
- [u/loopcake got SSR working in Java Spring Boot](https://www.reddit.com/r/sveltejs/comments/jkh5up/svelte_ssr_but_its_java_spring_boot_and_its_native/) for all the Java shops out there looking to render Svelte server-side.
|
||||
- [svelte-liquid-swipe](https://github.com/tncrazvan/svelte-liquid-swipe) shows off a fancy interaction pattern using svg paths.
|
||||
- [Crossfade Link Animation](https://svelte.dev/repl/7f68e148caf04b2787bb6f296208f870?version=3.29.7) demonstrates how to animate between navigation links using a crossfade (made by Blu, from the Discord community)
|
||||
- [Clip-Path Transitions](https://svelte.dev/repl/b5ad281ae8024b629b545c70c9e8764d?version=3.29.7) showcases how to use clip paths and custom transitions to create magical in-and-out transitions (made by Faber, from the Discord community)
|
||||
|
||||
**Learning Resources**
|
||||
|
||||
- [lihautan](https://www.youtube.com/channel/UCbmC3HP3FaAFdcZkui8YoMQ/featured) has been making easy-to-follow videos to share his in-depth knowledge of Svelte.
|
||||
- [Lessons From Building a Static Site Generator](https://nicholasreese.com/lessons-from-building-a-static-site-generator/) shares the backstory and thinking behind Elder.js - and the design decision made along the way.
|
||||
- [Svelte Tutorial and Projects Course ](https://www.udemy.com/course/svelte-tutorial-and-projects-course/) is a udemy course by John Smilga where students learn Svelte.js by building interesting projects.
|
||||
- [Building Pastebin on IPFS - with FastAPI, Svelte, and IPFS](https://amalshaji.wtf/building-pastebin-on-ipfs-with-fastapi-svelte-and-ipfs) explains how to make a distributed pastebin-like application.
|
||||
|
||||
|
||||
**Components, Libraries & Tools**
|
||||
|
||||
- [svelte-crossword](https://russellgoldenberg.github.io/svelte-crossword/) is a customizable crossword puzzle component for Svelte.
|
||||
- [svelte-cloudinary](https://github.com/cupcakearmy/svelte-cloudinary) makes it easy to integrate Cloudinary with Svelte (including TypeScript and SSR support)
|
||||
- [Svelte Nova](https://extensions.panic.com/extensions/sb.lao/sb.lao.svelte-nova/) extends the new Nova editor to support Svelte
|
@ -13,14 +13,12 @@ A new minor release replaces the `SvelteComponent` class with a `SvelteComponent
|
||||
|
||||
If you're using `SvelteComponent` or the new `SvelteComponentTyped` in your project or library, let us know what you're using it for and we'll add it to the showcase!
|
||||
|
||||
|
||||
## What's going on in Sapper?
|
||||
|
||||
More quality of life features are landing in the upcoming release every day. `0.29.0` will include new TypeScript definitions, fixes to scroll tracking and prefetching behavior, and improvements to the runtime router to support encoded query parameters.
|
||||
|
||||
If you're upgrading from 0.28.x, check out [the migration guide](https://sapper.svelte.dev/migrating/#0_28_to_0_29) for steps on updating to Sapper 0.29.
|
||||
|
||||
|
||||
## Is SvelteKit ready yet?
|
||||
|
||||
To avoid too much churn during development, SvelteKit is still being worked on in a private repo. There will be an announcement on the Discord, blog and Twitter when it's ready for a larger group of users and contributors.
|
||||
@ -29,7 +27,6 @@ In the meantime, you can explore the current build by running `npm init svelte@n
|
||||
|
||||
As cautioned in _[What's the deal with SvelteKit?](https://svelte.dev/blog/whats-the-deal-with-sveltekit)_, there are no docs or support available yet... So use at your own risk / for your own enjoyment!
|
||||
|
||||
|
||||
---
|
||||
|
||||
## Community Showcase
|
@ -8,12 +8,12 @@ authorURL: https://dreamindani.com
|
||||
With the shortest month of the year coming up, Svelte maintainers and community members alike have been busy this last month – from big changes in `svelte-loader`, `prettier-plugin-svelte`, `rollup-plugin-svelte`, and `language-tools` to steady progress in Sapper and `svelte-preprocess`. Meanwhile, lots of folks have been busy integrating Svelte with other popular frameworks.
|
||||
|
||||
## New compiler features
|
||||
|
||||
- Aria roles from the [WAI-ARIA Graphics Module](https://www.w3.org/TR/graphics-aria-1.0/#role_definitions) are now recognized as valid aria roles in Svelte components (**3.31.1**)
|
||||
- Compiler warnings for the common React attributes, `className` and `htmlFor`, now make it easier to port React components to Svelte (**3.31.1**)
|
||||
|
||||
Have a suggestion for a compiler feature or want to help implement new features/bug fixes? Check out the ["triage: good first issue" tag for Svelte](https://github.com/sveltejs/svelte/issues?q=is%3Aopen+is%3Aissue+label%3A%22triage%3A+good+first+issue%22)
|
||||
|
||||
|
||||
## New bits in language-tools
|
||||
|
||||
- User disabled auto import suggestions no longer show in VS Code (**103.0.0**)
|
||||
@ -34,7 +34,7 @@ A great way to try the language tools is to download the [Svelte Extension for V
|
||||
- [Sapper](https://github.com/sveltejs/sapper) got some improvements in scroll tracking and handling encoding query parameters. Dynamic imports also now work as expected in browsers that don't support ES modules. These changes from 0.29.0 and a step-by-step migration guide can be found [in the changelog](https://github.com/sveltejs/sapper/blob/master/CHANGELOG.md)
|
||||
- [prettier-plugin-svelte](https://github.com/sveltejs/prettier-plugin-svelte) version 2 was released. It received an overhaul and comes with a rewrite of the HTML formatting. The output is now much more in line with how standard Prettier formats HTML. Better defaults for `svelteBracketNewLine` and `options-scripts-markup-styles` should now match how the majority of users like to order the code blocks. Additionally, Prettier's `htmlWhitespaceSensitivity` setting is now supported. [More info in the changelog](https://github.com/sveltejs/prettier-plugin-svelte/blob/master/CHANGELOG.md)
|
||||
|
||||
New changes to the Svelte Society website include [a new cheat sheet](https://sveltesociety.dev/cheatsheet) for easy access to useful code patterns and some smaller visual fixes across the site. **Want to help make the Svelte Society website ready for prime time**? [Checkout the GitHub repo](https://github.com/svelte-society/sveltesociety.dev) to get started!
|
||||
New changes to the Svelte Society website include [a new cheat sheet](https://sveltesociety.dev/cheatsheet) for easy access to useful code patterns and some smaller visual fixes across the site. **Want to help make the Svelte Society website ready for prime time**? [Checkout the GitHub repo](https://github.com/svelte-society/sveltesociety.dev) to get started!
|
||||
|
||||
---
|
||||
|
||||
@ -47,7 +47,6 @@ New changes to the Svelte Society website include [a new cheat sheet](https://sv
|
||||
- [sho.rest](https://github.com/Melonai/shorest) is a self-hostable url shortener
|
||||
- [night.fm](https://night.fm/) is a cyberpunk-themed radio station
|
||||
|
||||
|
||||
**Demos, Libraries & Components**
|
||||
|
||||
- [Svelte Reactive Debugger](https://addons.mozilla.org/en-US/firefox/addon/svelte-reactive-debugger/) is a way to monitor Svelte reactive statements in Firefox devtools
|
||||
@ -60,8 +59,8 @@ New changes to the Svelte Society website include [a new cheat sheet](https://sv
|
||||
- [svelte-video-player](https://github.com/meigo/svelte-video-player) is a customizable `VideoPlayer` component
|
||||
- [svelte-readonly](https://github.com/Crisfole/svelte-readonly) is a very small store that exposes only a readable interface.
|
||||
|
||||
|
||||
**New Integrations & Starters**
|
||||
|
||||
- [svelte-derver-starter](https://github.com/AlexxNB/svelte-derver-starter) is a starter for baking fullstack application with the client based on Svelte and server side powered by Derver.
|
||||
- [eleventy-plugin-embed-svelte](https://github.com/shalomscott/eleventy-plugin-embed-svelte) makes it easy to embed Svelte components into an 11ty site.
|
||||
- [svelte-tailwind-extension-boilerplate](https://github.com/kyrelldixon/svelte-tailwind-extension-boilerplate) is a good foundation for a Chrome extension using either JavaScript or TypeScript, Svelte for the frontend, Tailwind CSS for styling, Jest for testing, and Rollup as the build system.
|
@ -10,18 +10,18 @@ Lots to cover this month with releases from across the Svelte ecosystem. Most im
|
||||
Let's dive into the news 🐬
|
||||
|
||||
## What's new in `sveltejs/svelte`
|
||||
* SSR store handling has been reworked to subscribe and unsubscribe as in DOM mode. SSR stores should work much more consistently now (**3.31.2**, see [custom stores](https://svelte.dev/examples/custom-stores) and [Server-side component API ](https://svelte.dev/docs#run-time-server-side-component-api))
|
||||
* Multiple instances of the same action are now allowed on an element (**3.32.0**, [example](https://svelte.dev/repl/01a14375951749dab9579cb6860eccde?version=3.32.0))
|
||||
* The new `foreign` namespace should make it easier for alternative compile targets (like Svelte Native and SvelteGUI) by disabling certain HTML5-specific behaviour and checks (**3.32.0**, [more info](https://github.com/sveltejs/svelte/pull/5652))
|
||||
* Support for inline comment sourcemaps in code from preprocessors (**3.32.0**)
|
||||
* Destructured defaults are now allowed to refer to other variables (**3.33.0**, [example](https://svelte.dev/repl/0ee7227e1b45465b9b47d7a5ae2d1252?version=3.33.0))
|
||||
* Custom elements will now call `onMount` functions when connecting and clean up when disconnecting (**3.33.0**, checkout [this PR](https://github.com/sveltejs/svelte/pull/4522) for an interesting conversation on how folks are using Svelte with Web Components)
|
||||
* A `cssHash` option has been added to the compiler options to control the classname used for CSS scoping (**3.34.0**, [docs](https://svelte.dev/docs#compile-time-svelte-compile))
|
||||
* Continued improvement to TypeScript definitions
|
||||
|
||||
- SSR store handling has been reworked to subscribe and unsubscribe as in DOM mode. SSR stores should work much more consistently now (**3.31.2**, see [custom stores](https://svelte.dev/examples/custom-stores) and [Server-side component API ](https://svelte.dev/docs#run-time-server-side-component-api))
|
||||
- Multiple instances of the same action are now allowed on an element (**3.32.0**, [example](https://svelte.dev/repl/01a14375951749dab9579cb6860eccde?version=3.32.0))
|
||||
- The new `foreign` namespace should make it easier for alternative compile targets (like Svelte Native and SvelteGUI) by disabling certain HTML5-specific behaviour and checks (**3.32.0**, [more info](https://github.com/sveltejs/svelte/pull/5652))
|
||||
- Support for inline comment sourcemaps in code from preprocessors (**3.32.0**)
|
||||
- Destructured defaults are now allowed to refer to other variables (**3.33.0**, [example](https://svelte.dev/repl/0ee7227e1b45465b9b47d7a5ae2d1252?version=3.33.0))
|
||||
- Custom elements will now call `onMount` functions when connecting and clean up when disconnecting (**3.33.0**, checkout [this PR](https://github.com/sveltejs/svelte/pull/4522) for an interesting conversation on how folks are using Svelte with Web Components)
|
||||
- A `cssHash` option has been added to the compiler options to control the classname used for CSS scoping (**3.34.0**, [docs](https://svelte.dev/docs#compile-time-svelte-compile))
|
||||
- Continued improvement to TypeScript definitions
|
||||
|
||||
For a complete list of changes, including bug fixes and links to PRs, check out [the CHANGELOG](https://github.com/sveltejs/svelte/blob/master/CHANGELOG.md)
|
||||
|
||||
|
||||
## New from `sveltejs/language-tools`
|
||||
|
||||
- For language server clients that don't support `didChangeWatchedFiles`, a fallback file watcher will be used instead
|
||||
@ -45,7 +45,7 @@ Haven't tried the language-tools yet? Check out [Svelte Extension for VSCode](ht
|
||||
**Apps & Sites**
|
||||
|
||||
- [Tracking the Coronavirus](https://www.nytimes.com/interactive/2021/us/new-york-city-new-york-covid-cases.html) from NYTimes is an example of SvelteKit in production
|
||||
- [Budibase](https://github.com/Budibase/budibase) is an open-source low-code platform, helping developers and IT professionals build, automate, and ship internal tools 50x faster on their own infrastructure.
|
||||
- [Budibase](https://github.com/Budibase/budibase) is an open-source low-code platform, helping developers and IT professionals build, automate, and ship internal tools 50x faster on their own infrastructure.
|
||||
- [Track the Parcel](https://tracktheparcel.com/) is a one-stop tool for tracking parcel status with all major package shippers.
|
||||
- [Memo](https://sendmemo.app/features/) is a replacement for email that uses Svelte for modern messaging
|
||||
- [Userscripts Safari](https://github.com/quoid/userscripts) is an open-source userscript editor for Safari... a native Svelte app for Mac OS!
|
||||
@ -61,8 +61,6 @@ Haven't tried the language-tools yet? Check out [Svelte Extension for VSCode](ht
|
||||
- [weatherify](https://brdtheo-weatherify.netlify.app/) is a very pretty (and [open source](https://github.com/brdtheo/weatherify)) weather app
|
||||
- [DSN Live](https://dsn-live.netlify.app/#/) lets you monitor connections between NASA/JPL and interplanetary spacecraft missions in real time.
|
||||
|
||||
|
||||
|
||||
**Demos, Libraries, Tools & Components**
|
||||
|
||||
- [spc](https://github.com/khang-nd/spc) is a special characters picker component for the web
|
||||
@ -86,7 +84,6 @@ Haven't tried the language-tools yet? Check out [Svelte Extension for VSCode](ht
|
||||
|
||||
**Have your own Svelte Component to share?** Check out the [Components](https://sveltesociety.dev/components) page on the Svelte Society site. You can contribute by making [a PR to this file](https://github.com/svelte-society/sveltesociety.dev/blob/master/src/pages/components/components.json).
|
||||
|
||||
|
||||
**Learning Resources & Starters**
|
||||
|
||||
- [The **unofficial** SvelteKit docs](https://sk-incognito.vercel.app/learn/what-is-sveltekit) were built using SvelteKit and are [open for contributions](https://github.com/GrygrFlzr/kit-docs)
|
@ -28,7 +28,6 @@ You'll find documentation at [kit.svelte.dev/docs](https://kit.svelte.dev/docs).
|
||||
|
||||
The source code is available at [github.com/sveltejs/kit](https://github.com/sveltejs/kit). Issues and pull requests are disabled while we finish getting our house in order, but we'll be making it fully open in the near future.
|
||||
|
||||
|
||||
## Wait, what is SvelteKit?
|
||||
|
||||
Think of it as [Next](https://nextjs.org/) for Svelte. It's a framework for building apps with Svelte, complete with server-side rendering, routing, code-splitting for JS and CSS, adapters for different serverless platforms and so on.
|
||||
@ -45,7 +44,6 @@ Vite falls into the same category as Snowpack. While Vite 1 wasn't suitable for
|
||||
|
||||
We owe a deep debt of gratitude to the Snowpack team, both for the close collaboration earlier in development and for lighting the path that web development will take over the next few years. It's a wonderful tool, and you should absolutely try it out.
|
||||
|
||||
|
||||
## Dogfooding as extreme sport
|
||||
|
||||
SvelteKit is very much in beta, but that doesn't mean it hasn't been used in production.
|
@ -8,11 +8,13 @@ authorURL: https://dreamindani.com
|
||||
Two projects that have been months (even years) in the making have made their way out into the world. SvelteKit is now in public beta and slotted components are now available in Svelte!
|
||||
|
||||
## What's up with SvelteKit?
|
||||
|
||||
[SvelteKit](https://kit.svelte.dev/) - Svelte's versatile framework for building SSR, serverless applications, or SPAs - is now officially in public beta. Expect bugs! Lots more detail in the [latest blog post](https://svelte.dev/blog/sveltekit-beta). Want to know when 1.0 is close? Check out the milestone on [github](https://github.com/sveltejs/kit/milestone/2).
|
||||
|
||||
Want to learn more about how to get started, what's different compared to Sapper, new features and migration paths? Check out this week's [episode of Svelte Radio](https://www.svelteradio.com/episodes/svelte-kit-public-beta) for a deep dive with Antony, Kev and Swyx.
|
||||
|
||||
## New in Svelte & Language Tools
|
||||
|
||||
- Slotted components, including `<svelte:fragment slot="...">` lets component consumers target specific slots with rich content (**Svelte 3.35.0, Language Tools [104.5.0](https://github.com/sveltejs/language-tools/releases/tag/extensions-104.5.0)**, check out the [docs](https://svelte.dev/docs#template-syntax-svelte-fragment) and the [tutorial](https://svelte.dev/tutorial/svelte-fragment))
|
||||
- Linked editing now works for HTML in Svelte files (**Language Tools, [104.6.0](https://github.com/sveltejs/language-tools/releases/tag/extensions-104.6.0)**)
|
||||
- Type definitions `svelte.d.ts` are now resolved in order, allowing library authors to ship type definitions with their svelte components (**Language Tools, [104.7.0](https://github.com/sveltejs/language-tools/releases/tag/extensions-104.7.0)**)
|
||||
@ -32,7 +34,6 @@ Want to learn more about how to get started, what's different compared to Sapper
|
||||
- [Svelte Game of Life](https://github.com/alanrsoares/svelte-game-of-life) is an educational implementation of Conway's Game of Life in TypeScript + Svelte
|
||||
- [foxql](https://github.com/foxql) is a peer to peer full text search engine that runs on your browser.
|
||||
|
||||
|
||||
**Demos, Libraries, Tools & Components**
|
||||
|
||||
- [svelte-nodegui](https://github.com/nodegui/svelte-nodegui) is a way to build performant, native and cross-platform desktop applications with Node.js and Svelte
|
||||
@ -46,17 +47,16 @@ Want to learn more about how to get started, what's different compared to Sapper
|
||||
|
||||
**Want to contribute your own component?** Submit a [Component](https://sveltesociety.dev/components) to the Svelte Society site by making [a PR to this file](https://github.com/svelte-society/sveltesociety.dev/blob/master/src/pages/components/components.json).
|
||||
|
||||
|
||||
**Starters**
|
||||
|
||||
- [sveltekit-electron](https://github.com/FractalHQ/sveltekit-electron) is a starter kit for Electron using SvelteKit
|
||||
- [sveltekit-tailwindcss-external-api](https://github.com/acidlake/sveltekit-tailwindcss-external-api) is everything you need to build a Svelte project with TailwindCSS and an external API, powered by create-svelte.
|
||||
- [Sapper Netlify](https://www.npmjs.com/package/sapper-netlify) is a Sapper project that can run on a Netlify function.
|
||||
|
||||
|
||||
**Looking for a particular starter?** Check out [svelte-adders](https://github.com/svelte-add/svelte-adders) and a number of other template examples at the community site [sveltesociety.dev](https://sveltesociety.dev/templates/)
|
||||
|
||||
**Learning Resources**
|
||||
|
||||
- [How to Build a Website with Svelte and SvelteKit](https://prismic.io/blog/svelte-sveltekit-tutorial) is a step-by-step tutorial walking through the new SvelteKit setup.
|
||||
- [A Svelte store for prefers-reduced-motion](https://geoffrich.net/posts/svelte-prefers-reduced-motion-store/) demonstrates how to make a custom Svelte store whose value will indicate whether the user has requested reduced motion and improve accessibility.
|
||||
- [TypeScript support in Svelte](https://developer.mozilla.org/en-US/docs/Learn/Tools_and_testing/Client-side_JavaScript_frameworks/Svelte_TypeScript) is an MDN guide to using TypeScript in Svelte.
|
||||
@ -67,7 +67,6 @@ Want to learn more about how to get started, what's different compared to Sapper
|
||||
- [Svelte Store: Reactive context using Svelte Store](https://www.youtube.com/watch?v=-rTnWlbdjoY) is a video answer to the question, "How do we make [a] context value reactive?"
|
||||
- [Creating Social Sharing Images with Cloudinary and Svelte](https://www.youtube.com/watch?v=-Si5o-R7KHY) is a video from Cloudinary that demonstrates how to dynamically develop Open Graph images and Twitter Cards for a JAMstack website.
|
||||
|
||||
|
||||
## See you next month!
|
||||
|
||||
Got something to add? Join us on [Svelte Society](https://sveltesociety.dev/), [Reddit](https://www.reddit.com/r/sveltejs/) and [Discord](https://discord.com/invite/yy75DKs)!
|
@ -8,10 +8,12 @@ authorURL: https://dreamindani.com
|
||||
Last week, Svelte Summit blew us away with a mountain of content! [Check out the full recording](https://www.youtube.com/watch?v=fnr9XWvjJHw) or an audio-only (p)review [on Svelte Radio](https://www.svelteradio.com/episodes/svelte-summit-party-episode). Now let's get into this month's news...
|
||||
|
||||
## New features in the Svelte Compiler
|
||||
|
||||
- `:global()` is now supported as part of compound CSS selectors (**3.38.0**, [Example](https://svelte.dev/repl/54148fd2af484f2c84977c94e523c7c5?version=3.38.0))
|
||||
- CSS custom properties can now be passed to components for use cases such as theming (**3.38.0**, [Docs coming soon](https://github.com/sveltejs/svelte/issues/6268))
|
||||
|
||||
## New in SvelteKit
|
||||
|
||||
- [kit.svelte.dev](https://kit.svelte.dev/) has a fresh new look and the [SvelteKit Demo Site](https://netlify.demo.svelte.dev/) got a fresh set of paint. Check it out by running `npm init svelte@next`
|
||||
- You can now use `@sveltejs/adapter-static` to create a single-page app or SPA by specifying a fallback page ([PR](https://github.com/sveltejs/kit/pull/1181), [Docs](https://github.com/sveltejs/kit/tree/master/packages/adapter-static))
|
||||
- Disable Server-side Rendering (SSR) app-wide or on a page-by-page basis ([PR](https://github.com/sveltejs/kit/pull/713))
|
||||
@ -20,6 +22,7 @@ Last week, Svelte Summit blew us away with a mountain of content! [Check out the
|
||||
- `fetch` in SvelteKit code will now use the environment-provided implementation, whenever possible. If `fetch` is unavailable, it will be polyfilled by adapters ([PR](https://github.com/sveltejs/kit/pull/1066), [Docs](https://kit.svelte.dev/docs/loading#input-fetch))
|
||||
|
||||
## New in Svelte & Language Tools
|
||||
|
||||
- `svelte-preprocess` now supports the "extends" field of the tsconfig.json (4.7.2)
|
||||
- HTML `style` attributes now have hover & auto-complete. Foreign namespaces and ESM configs are now supported in the Svelte language server & extensions
|
||||
- The Svelte language tools can now infer slot/event types from their props if a generic relationship between them was defined
|
||||
@ -39,18 +42,17 @@ Last week, Svelte Summit blew us away with a mountain of content! [Check out the
|
||||
- [Frog Safety](https://frog-safety.vercel.app/) is a guide for African Dwarf Frogs and the API freshwater master kit
|
||||
- [Stardew Valley Character Preview](https://github.com/overscore-media/stardew-valley-character-preview) loads your character's attributes from your Stardew Valley savefile and lets you play around with different outfits, colours, and accessories.
|
||||
|
||||
|
||||
**Demos, Libraries, Tools & Components**
|
||||
|
||||
- [svelte-parallax](https://github.com/kindoflew/svelte-parallax) is a spring-based parallax component for Svelte
|
||||
- [@svelte-plugins/viewable](https://github.com/svelte-plugins/viewable) is a simple rule-based approach to tracking element viewability.
|
||||
- [Sveltekit-JUI](https://github.com/Wolfr/sveltekit-jui) is a kit of UI components to be used in conjunction with Svelte and Svelte Kit.
|
||||
- [EZGesture](https://github.com/mhmd-22/ezgesture#integrating-with-other-frameworks) makes it easy to add gestures functionality with simple native DOM events
|
||||
- [EZGesture](https://github.com/mhmd-22/ezgesture#integrating-with-other-frameworks) makes it easy to add gestures functionality with simple native DOM events
|
||||
|
||||
**Want to contribute your own component?** Submit a [Component](https://sveltesociety.dev/components) to the Svelte Society site by making [a PR to this file](https://github.com/svelte-society/sveltesociety.dev/blob/master/src/pages/components/components.json).
|
||||
|
||||
|
||||
**Starters**
|
||||
|
||||
- [How to use Vercel Analytics with SvelteKit](https://ivoberger.com/posts/using-vercel-analytics-with-svelte-kit) teaches how to track Web Vitals across your users' devices
|
||||
- [Asp.NETCore + Svelte + Vite](https://github.com/Kiho/aspcore-spa-cli/tree/master/samples/SviteSample) connects the three frameworks with SpaCliMiddleware (VS2019)
|
||||
- [Add CoffeeScript to Svelte](https://github.com/Leftium/coffeescript-adder) is an experimental command to run to add CoffeeScript to your SvelteKit project or Vite-powered Svelte app
|
||||
@ -59,8 +61,8 @@ Last week, Svelte Summit blew us away with a mountain of content! [Check out the
|
||||
|
||||
**Looking for a starter or integration?** Check out [svelte-adders](https://github.com/svelte-add/svelte-adders) and a number of other template examples at the community site [sveltesociety.dev](https://sveltesociety.dev/templates)
|
||||
|
||||
|
||||
**Learning Resources**
|
||||
|
||||
- [Amazing macOS Dock animation in Svelte](https://dev.to/puruvj/amazing-macos-dock-animation-in-svelte-5hfb) demonstrates how nice Svelte and popmotion look together
|
||||
- [Solving the Tower of Hanoi with recursive Svelte templates](https://geoffrich.net/posts/svelte-tower-of-hanoi/) incorporates the `<svelte:self>` element into a common computer science problem
|
||||
- [DIY SvelteKit CDK adapter](https://dev.to/juranki/diy-sveltekit-cdk-adapter-3enp) puts together SvelteKit and AWS CDK
|
||||
@ -69,8 +71,6 @@ Last week, Svelte Summit blew us away with a mountain of content! [Check out the
|
||||
- lihautan's latest video updates in the [Svelte 101](https://www.youtube.com/watch?v=rwYgOU0WmVk&list=PLoKaNN3BjQX3mxDEVG3oGJx2ByXnue_gR&index=59) and [Svelte Store](https://www.youtube.com/watch?v=p4GmT0trCPE&list=PLoKaNN3BjQX3fG-XOSwsPHtnV8FUY6lgK&index=19) playlists cover slots, stores and context - and when to use which
|
||||
- [DavidParkerW](https://www.youtube.com/c/DavidParkerW/playlists) has been exploring Svelte, Sapper and SvelteKit in some real-world scenarios, like [displaying a blog post list from an API](https://www.youtube.com/watch?v=kAPVFgFnxaM&list=PLPqKsyEGhUna6cvm6d4vZNI6gbt_0S4Xx&index=15)
|
||||
|
||||
|
||||
|
||||
## See you next month!
|
||||
|
||||
Got something to add? Join us on [Svelte Society](https://sveltesociety.dev/), [Reddit](https://www.reddit.com/r/sveltejs/) and [Discord](https://discord.com/invite/yy75DKs)!
|
@ -8,25 +8,26 @@ authorURL: https://dreamindani.com
|
||||
This month, we saw lots of contributions to SvelteKit and its docs. The language tools also got some new features, most notably deeper integration with Svelte files within JavaScript or TypeScript files. Let's jump into the updates...
|
||||
|
||||
## New in SvelteKit
|
||||
|
||||
- `svelte.config.js` config files are now loaded in ESM format (`.js` instead of `.cjs`).
|
||||
- AMP pages will now use the rendered CSS, rather than emitted CSS
|
||||
- `svelte-check` has been added to the TypeScript template ([sveltejs/kit#1556](https://github.com/sveltejs/kit/pull/1556))
|
||||
- Support for https keypair [sveltejs/kit#1456](https://github.com/sveltejs/kit/pull/1456)
|
||||
- Now bundling Vite with SvelteKit and using an upgraded version. Remove Vite from your `package.json` if it's there
|
||||
- Etags for binary responses [sveltejs/kit#1382](https://github.com/sveltejs/kit/pull/1382)
|
||||
- Renamed `$layout` to `__layout` and `$error` to `__error`
|
||||
- Removed `getContext` in favor of `request.locals`
|
||||
- `svelte-check` has been added to the TypeScript template ([sveltejs/kit#1556](https://github.com/sveltejs/kit/pull/1556))
|
||||
- Support for https keypair [sveltejs/kit#1456](https://github.com/sveltejs/kit/pull/1456)
|
||||
- Now bundling Vite with SvelteKit and using an upgraded version. Remove Vite from your `package.json` if it's there
|
||||
- Etags for binary responses [sveltejs/kit#1382](https://github.com/sveltejs/kit/pull/1382)
|
||||
- Renamed `$layout` to `__layout` and `$error` to `__error`
|
||||
- Removed `getContext` in favor of `request.locals`
|
||||
- Renamed `.svelte` output directory to `.svelte-kit`. Update your `.gitignore` accordingly
|
||||
- `trailingSlash: 'never' | 'always' | 'ignore'` is now available in the config. This should make it easier to build sites that work with static hosting providers that expect a trailing slash for `index.html` pages, and provides an escape hatch for anyone that needs more complex behaviour.
|
||||
|
||||
## Notable bug fixes in SvelteKit
|
||||
- `adapter-netlify` got a fix [sveltejs/kit#1467](https://github.com/sveltejs/kit/pull/1467) and new documentation in the readme https://github.com/sveltejs/kit/tree/master/packages/adapter-netlify
|
||||
|
||||
- `adapter-netlify` got a fix [sveltejs/kit#1467](https://github.com/sveltejs/kit/pull/1467) and new documentation in the readme https://github.com/sveltejs/kit/tree/master/packages/adapter-netlify
|
||||
- The router will no longer intercept navigation for URLs that the app does not own. This fixes a crash for apps that have `<a>` elements on the page with the same origin but don't share a base path with the app.
|
||||
- Hash only changes are now handled by the router fixing the browser's "back" navigation between hash changes in some circumstances.
|
||||
|
||||
|
||||
|
||||
## New in Svelte & Language Tools
|
||||
|
||||
- Svelte 3.38.1 and 3.38.2 fixed an issue with hydration that was causing duplicate elements. If you're seeing this in your project, be sure to update the latest version!
|
||||
- A new TypeScript plugin provides deeper integration with Svelte files within JavaScript or TypeScript files. This includes diagnostics, references and renaming of variables. It comes packaged with the VS Code extension but is turned off by default for now. You can enable it through [this setting](https://github.com/sveltejs/language-tools/tree/master/packages/svelte-vscode#svelteenable-ts-plugin). We encourage you to test it out and [provide feedback](https://github.com/sveltejs/language-tools/issues/580)
|
||||
- In the latest version of `svelte-check` you can now provide the path to your `tsconfig.json` or `jsconfig.json`. Example: `svelte-check --tsconfig "./tsconfig.json"`. This ensures the diagnostics are only run on files that are referenced in that config. It also runs diagnostics on JavaScript and/or TypeScript files which removes the need to run another check (like `tsc --noEmit`) for non-Svelte files (`svelte-check` version [**1.6.0**](https://github.com/sveltejs/language-tools/releases/tag/svelte-check-1.6.0))
|
||||
@ -46,7 +47,6 @@ This month, we saw lots of contributions to SvelteKit and its docs. The language
|
||||
- [Greedy Goblin](https://greedygoblin-fe11c.web.app/) is a recipe app for old-school Runescape players.
|
||||
- [hashbrown.geopjr.dev](https://hashbrown.geopjr.dev/) is a GNOME-shell inspired webpage to learn about, explore the source code and download the Hashbrown GTK app ([link to source](https://github.com/GeopJr/Hashbrown/tree/website)).
|
||||
|
||||
|
||||
**Libraries, Tools & Components**
|
||||
|
||||
- [svelte-image-crop](https://novacbn.github.io/svelte-image-crop/) is a simple click'n'drag image cropping library using Web APIs.
|
||||
@ -56,10 +56,8 @@ This month, we saw lots of contributions to SvelteKit and its docs. The language
|
||||
- [svelte-entity-store](https://www.npmjs.com/package/svelte-entity-store) is to provide a simple, generic solution for storing collections of entity objects.
|
||||
- [svelte-animation-store](https://github.com/joshnuss/svelte-animation-store) is a store that is based on Svelte's tweened store, that lets you pause, continue, reset, replay, reverse or adjust speed of a tween.
|
||||
|
||||
|
||||
**Want to contribute a component?** Submit a [Component](https://sveltesociety.dev/components) to the Svelte Society site by making [a PR to this file](https://github.com/svelte-society/sveltesociety.dev/blob/master/src/pages/components/components.json).
|
||||
|
||||
|
||||
## See you next month!
|
||||
|
||||
Did we miss something? Join us on [Svelte Society](https://sveltesociety.dev/), [Reddit](https://www.reddit.com/r/sveltejs/) and [Discord](https://discord.com/invite/yy75DKs)!
|
@ -8,22 +8,22 @@ authorURL: https://dreamindani.com
|
||||
As the northern hemisphere heats up, Svelte has stayed cool with lots of performance and bug fixes, better TypeScript support, and lots of new components & tools from around the ecosystem. Let's take a peek 👀
|
||||
|
||||
## New in SvelteKit
|
||||
|
||||
- `adapter-node` now precompresses assets using gzip & brotli ([#1693](https://github.com/sveltejs/kit/pull/1693))
|
||||
- Support for TypeScript transpilation has been added to the `svelte-kit package` tooling ([#1633](https://github.com/sveltejs/kit/pull/1633))
|
||||
- Improved caching defaults in `adapter-node` ([#1416](https://github.com/sveltejs/kit/pull/1416))
|
||||
- Allow configuring Rollup output options ([#1572](https://github.com/sveltejs/kit/pull/1572))
|
||||
- Fixed usage of SSL with HMR ([#1517](https://github.com/sveltejs/kit/pull/1517))
|
||||
|
||||
## Features & bug fixes from around svelte/\*
|
||||
|
||||
|
||||
## Features & bug fixes from around svelte/*
|
||||
- [Svelte 3.38.3](https://github.com/sveltejs/svelte/blob/master/CHANGELOG.md#3383) (released June 22) includes a bunch of performance and bug fixes - including hydration optimizations, `this` preservation in bubbled events, and more!
|
||||
- The latest language tools releases added support for prop renaming from outside of a component, PostCSS syntax grammar, and a `.d.ts` output target in `svelte2tsx` which can be used to create type definitions from Svelte files.
|
||||
- Also in language tools, some long-awaited experimental features for enhanced TypeScript support were added - including explicitly typing all possible component events or slots, and using generics. Have a look at [the RFC](https://github.com/sveltejs/rfcs/pull/38) for more details and leave feedback in [this issue](https://github.com/sveltejs/language-tools/issues/442) if you are using it.
|
||||
- `svelte-scroller` got some quality-of-life fixes in 2.0.7 - fixing an initial width bug and updating its `index` more conservatively
|
||||
|
||||
|
||||
## Coming soon to Svelte
|
||||
|
||||
- Constants in markup ([RFC](https://github.com/sveltejs/rfcs/blob/master/text/0000-markup-constants.md)): Adds a new `{@const ...}` tag that defines a local constant ([PR](https://github.com/sveltejs/svelte/pull/6413))
|
||||
|
||||
---
|
||||
@ -31,12 +31,13 @@ As the northern hemisphere heats up, Svelte has stayed cool with lots of perform
|
||||
## Community Showcase
|
||||
|
||||
**Apps & Sites**
|
||||
|
||||
- [SvelteThemes](https://sveltethemes.dev/) is a curated list of Svelte themes and templates built using svelte, sveltekit, elderjs, routify etc.
|
||||
- [Beatbump](https://github.com/snuffyDev/Beatbump) is an alternative frontend for YouTube Music created using Svelte/SvelteKit.
|
||||
- [Sveltuir](https://github.com/webspaceadam/sveltuir) is an app help you memorize the guitar fretboard
|
||||
|
||||
|
||||
**Educational Content**
|
||||
|
||||
- [Svelte Radio: A Jolly Good Svelte Summer](https://share.transistor.fm/s/60880542) is a conversation about what's new in Svelte and a celebration of Svelte Radio's 1-year anniversary
|
||||
- [Class properties in Svelte](https://navillus.dev/blog/svelte-class-props) is a refresher on the power of `class` for developers switching over to Svelte from React
|
||||
- [Sveltekit Tutorial for Beginners](https://www.youtube.com/playlist?list=PLm_Qt4aKpfKjf77S8UD79Ockhwp_699Ms) is a video playlist for learning SvelteKit by WebJeda
|
||||
@ -47,8 +48,8 @@ As the northern hemisphere heats up, Svelte has stayed cool with lots of perform
|
||||
- [Render Katex with Svelte from zero to hero](https://www.youtube.com/watch?v=euowJs9CblA) demonstrates how to implement Katex in a Svelte project
|
||||
- [Using Custom Elements in Svelte](https://css-tricks.com/using-custom-elements-in-svelte/) shows some of the quirks to look out for when using custom elements in a Svelte site
|
||||
|
||||
|
||||
**Libraries, Tools & Components**
|
||||
|
||||
- [svelte-pipeline](https://github.com/novacbn/svelte-pipeline) provides custom JavaScript contexts and the Svelte Compiler as Svelte Stores, for REPLs, Editors, etc.
|
||||
- [Sveltotron](https://github.com/Salemmous/sveltotron) is an Electron-based app made to inspect your Svelte app
|
||||
- [svelte-qr-reader-writer](https://github.com/pleasemarkdarkly/svelte-qr-reader-writer) is a Svelte component that helps read and write data from QR codes
|
||||
@ -56,10 +57,8 @@ As the northern hemisphere heats up, Svelte has stayed cool with lots of perform
|
||||
- [svelte-typed-context](https://www.npmjs.com/package/svelte-typed-context) provides an interface which, when provided to `getContext` or `setContext`, allows for stricter types
|
||||
- [svelte-modals](https://svelte-modals.mattjennings.io/) is a simple, flexible, zero-dependency modal manager for Svelte
|
||||
|
||||
|
||||
**Want to contribute a component? Interested in helping make Svelte's presence on the web better?** Submit a Component to the Svelte Society site by making [a PR to this file](https://github.com/svelte-society/sveltesociety-2021/blob/main/src/routes/components/components.json) or check out [the list of open issues](https://github.com/svelte-society/sveltesociety-2021/issues) if you'd like to contribute to the Svelte Society rewrite in SvelteKit.
|
||||
|
||||
|
||||
## See you next month!
|
||||
|
||||
Want more updates? Join us on [Reddit](https://www.reddit.com/r/sveltejs/) or [Discord](https://discord.com/invite/yy75DKs)!
|
@ -20,6 +20,7 @@ July was the most active month for the Svelte core repo since late 2019 as we re
|
||||
For a full list of features and bug fixes, check out the [Svelte changelog](https://github.com/sveltejs/svelte/blob/master/CHANGELOG.md).
|
||||
|
||||
## SvelteKit Updates
|
||||
|
||||
- `prerender.force` is now `prerender.onError` which lets you fine-tune which errors fail the build and which do not ([#2007](https://github.com/sveltejs/kit/pull/2007))
|
||||
- esbuild's configuration is now exposed for use with SvelteKit adapters ([#1914](https://github.com/sveltejs/kit/pull/1914))
|
||||
- Error messages are friendlier now for common config errors ([#1910](https://github.com/sveltejs/kit/pull/1910)) and compiler errors ([#1827](https://github.com/sveltejs/kit/pull/1827))
|
||||
@ -30,7 +31,8 @@ For a full list of features and bug fixes, check out the [Svelte changelog](http
|
||||
|
||||
To see all updates to SvelteKit, check out the [SvelteKit changelog](https://github.com/sveltejs/kit/blob/master/packages/kit/CHANGELOG.md).
|
||||
|
||||
## Features & bug fixes from around svelte/*
|
||||
## Features & bug fixes from around svelte/\*
|
||||
|
||||
- Language Tools now better support the "Workplace Trust" functionality (used in VS Code)
|
||||
- In svelte2tsx, ambient type declarations are now renamed to avoid conflicting declarations in the future. Users are now expected to provide the ambient type definitions themselves - fixing JS output
|
||||
- Sapper released v0.29.2 which fixes regex routes, status codes when requesting a directory, and exports when a user has not provided a `base` tag ([changelog](https://github.com/sveltejs/sapper/blob/master/CHANGELOG.md))
|
||||
@ -40,6 +42,7 @@ To see all updates to SvelteKit, check out the [SvelteKit changelog](https://git
|
||||
## Community Showcase
|
||||
|
||||
**Apps & Sites**
|
||||
|
||||
- [Parsnip](https://www.parsnip.ai/) is a mobile-first, progressive-web-app that helps you to learn to cook at home. Check out the [conversation on Reddit](https://www.reddit.com/r/sveltejs/comments/oearb9/learning_to_cook_at_home_with_parsnip_built/) for all the geeky details.
|
||||
- [Central Bank Digital Currency (CBDC) tracker](https://www.atlanticcouncil.org/cbdctracker/) is a site that keeps track of how countries around the world are adopting digital currencies.
|
||||
- [Svelte Commerce](https://github.com/itswadesh/svelte-commerce) is an advanced frontend platform for eCommerce based on Sveltekit.
|
||||
@ -48,6 +51,7 @@ To see all updates to SvelteKit, check out the [SvelteKit changelog](https://git
|
||||
**Looking for a Svelte project to work on? Interested in helping make Svelte's presence on the web better?** Check out [the list of open issues](https://github.com/svelte-society/sveltesociety-2021/issues) if you'd like to contribute to the Svelte Society rewrite in SvelteKit.
|
||||
|
||||
**Educational Content**
|
||||
|
||||
- [How I Built a Cross-Platform Desktop Application with Svelte, Redis, and Rust](https://css-tricks.com/how-i-built-a-cross-platform-desktop-application-with-svelte-redis-and-rust/) is a blog post by Luke Edwards, Svelte maintainer and Developer Advocate from Cloudflare.
|
||||
- [How to Create a Blog with SvelteKit and Strapi](https://strapi.io/blog/how-to-create-a-blog-with-svelte-kit-strapi) is a step-by-step tutorial by Aarnav Pai from Strapi
|
||||
- [Sveltekit Markdown Blog](https://www.youtube.com/watch?v=sKKgT0SEioI&list=PLm_Qt4aKpfKgonq1zwaCS6kOD-nbOKx7V) is a YouTube tutorial series by WebJeda.
|
||||
@ -56,6 +60,7 @@ To see all updates to SvelteKit, check out the [SvelteKit changelog](https://git
|
||||
- [How to add Magic Link to a SvelteKit application](https://magic.link/posts/magic-svelte) is a guide to the popular password-less login pattern.
|
||||
|
||||
**Libraries, Tools & Components**
|
||||
|
||||
- [Svelte-Capacitor](https://github.com/drannex42/svelte-capacitor/) just released v2.0.0 - making it even easier to build hybrid mobile apps for iOS and Android using Svelte and Capacitor with near native performance.
|
||||
- [svelte-remixicon](https://github.com/ABarnob/svelte-remixicon) is an icon library for Svelte based on Remix Icon, consisting of more than 2000 icons.
|
||||
- [SveltePress](https://github.com/GeopJr/SveltePress) is a documentation tool built on top of SvelteKit.
|
||||
@ -65,7 +70,6 @@ To see all updates to SvelteKit, check out the [SvelteKit changelog](https://git
|
||||
|
||||
Check out the community site [sveltesociety.dev](https://sveltesociety.dev/templates/) for more templates, adders and adapters from across the Svelte ecosystem.
|
||||
|
||||
|
||||
## See you next month!
|
||||
|
||||
Want more updates? Join us on [Reddit](https://www.reddit.com/r/sveltejs/) or [Discord](https://discord.com/invite/yy75DKs)!
|
@ -35,12 +35,12 @@ The focus this past month was on continuing to iron out any kinks, with well ove
|
||||
|
||||
To see all updates to SvelteKit, check out the [SvelteKit changelog](https://github.com/sveltejs/kit/blob/master/packages/kit/CHANGELOG.md).
|
||||
|
||||
|
||||
---
|
||||
|
||||
## Community Showcase
|
||||
|
||||
**Apps & Sites**
|
||||
|
||||
- [macos-web](https://github.com/PuruVJ/macos-web) by @puruvjdev has been rebuilt with Svelte from the ground up. Check out all the details in this [Twitter thread](https://twitter.com/puruvjdev/status/1426267327687847939)
|
||||
- [Brave Search](https://search.brave.com/) is using Svelte
|
||||
- [exatorrent](https://github.com/varbhat/exatorrent) is a self-hostable, easy-to-use, lightweight and feature-rich torrent client written in Go and Svelte
|
||||
@ -55,6 +55,7 @@ To see all updates to SvelteKit, check out the [SvelteKit changelog](https://git
|
||||
**Looking for a Svelte project to work on? Interested in helping make Svelte's presence on the web better?** Check out [the list of open issues](https://github.com/svelte-society/sveltesociety-2021/issues) if you'd like to contribute to the Svelte Society rewrite in SvelteKit.
|
||||
|
||||
**Educational Content**
|
||||
|
||||
- [Tauri with Standard Svelte or SvelteKit](https://medium.com/@cazanator/tauri-with-standard-svelte-or-sveltekit-ad7f103c37e7) walks through how to setup Svelte with Tauri, a new light-weight framework for developing cross-platform hybrid desktop applications
|
||||
- [Svelte - Web App Development Reimagined [An Intro to Svelte]](https://www.youtube.com/watch?v=4CGzFwHoD0A&list=PLEx5khR4g7PKSASVAXXiAhkyx02_OeruP) is a great intro talk from the goto; conference
|
||||
- [LevelUpTuts - Even More 5 Things I Like More In Svelte Than React](https://www.youtube.com/watch?v=ISmnG2sIOeM) highlights Svelte's approach to refs (don't need them), meta tags and more
|
||||
@ -62,6 +63,7 @@ To see all updates to SvelteKit, check out the [SvelteKit changelog](https://git
|
||||
- [Migrating from Sapper to SvelteKit](https://shipbit.de/blog/migrating-from-sapper-to-svelte-kit/) is a review and retrospective of ShipBit's migration from Sapper
|
||||
|
||||
**Libraries, Tools & Components**
|
||||
|
||||
- [svelte-stripe-js](https://github.com/joshnuss/svelte-stripe-js) is everything you need to add Stripe to your Svelte project. 100% SvelteKit compatible
|
||||
- [svelte-steps](https://github.com/shaozi/svelte-steps) is a customizable step component written in Svelte
|
||||
- [simple-optics-module](https://gitlab.com/Samzelot/simple-optics-module) is an online open source optics tool for experimenting and teaching geometrical optics
|
||||
@ -77,7 +79,6 @@ To see all updates to SvelteKit, check out the [SvelteKit changelog](https://git
|
||||
|
||||
Check out the community site [sveltesociety.dev](https://sveltesociety.dev/templates/) for more templates, adders and adapters from across the Svelte ecosystem.
|
||||
|
||||
|
||||
## See you next month!
|
||||
|
||||
Want more updates? Join us on [Reddit](https://www.reddit.com/r/sveltejs/) or [Discord](https://discord.com/invite/yy75DKs)!
|
@ -21,7 +21,7 @@ For a full list of features and bug fixes, check out the [Svelte changelog](http
|
||||
|
||||
## SvelteKit Updates
|
||||
|
||||
Nearly 100 PRs committed again this past month, but there's still lots to do and Svelte maintainers are [looking for help getting SvelteKit to 1.0](https://github.com/sveltejs/kit/issues/2100). Antony said it well in a [recent comment](https://github.com/sveltejs/kit/issues/2100#issuecomment-895446285) on the issue:
|
||||
Nearly 100 PRs committed again this past month, but there's still lots to do and Svelte maintainers are [looking for help getting SvelteKit to 1.0](https://github.com/sveltejs/kit/issues/2100). Antony said it well in a [recent comment](https://github.com/sveltejs/kit/issues/2100#issuecomment-895446285) on the issue:
|
||||
|
||||
> If you think you are too n00b to contribute (you're not), then add tests, or write tests for the feature you want to add, before you add it! Start small, and learn the codebase that way.
|
||||
|
||||
@ -41,22 +41,23 @@ Notable SvelteKit improvements this month include...
|
||||
|
||||
To see all updates to SvelteKit, check out the [SvelteKit changelog](https://github.com/sveltejs/kit/blob/master/packages/kit/CHANGELOG.md).
|
||||
|
||||
|
||||
---
|
||||
|
||||
## Community Showcase
|
||||
|
||||
**Apps & Sites**
|
||||
|
||||
- [radiofrance](https://www.radiofrance.fr/) just migrated their website to SvelteKit
|
||||
- [FLAYKS](https://flayks.com/) is the portfolio site for Félix Péault made with SvelteKit, Sanity, and Anime.js
|
||||
- [hirehive](https://www.hirehive.com/) is a candidate and job tracking site
|
||||
- [Microsocial](https://microsocial.xyz/) is an experimental Peer-to-Peer Social Platform
|
||||
- [Microsocial](https://microsocial.xyz/) is an experimental Peer-to-Peer Social Platform
|
||||
- [Dylan Ipsum](https://www.dylanlyrics.app/) is a random text generator to replace lorem ipsum with Bob Dylan lyrics
|
||||
- [Chip8 Svelte](https://github.com/mikeyhogarth/chip8-svelte) is a CHIP-8 emulator frontend, built on top of CHIP8 TypeScript
|
||||
|
||||
**Looking for a Svelte project to work on? Interested in helping make Svelte's presence on the web better?** Check out [the list of open issues](https://github.com/svelte-society/sveltesociety-2021/issues) if you'd like to contribute to the Svelte Society rewrite in SvelteKit.
|
||||
|
||||
**Podcasts Featuring Svelte**
|
||||
|
||||
- [Syntax Podcast: From React to SvelteKit](https://podcasts.apple.com/us/podcast/from-react-to-sveltekit/id1253186678?i=1000536276106) Scott talks with Wes about moving Level Up Tutorials from React to SvelteKit — why he did it, how, benefits, things to watch out for, and more!
|
||||
- [Web Rush Podcast: Svelte Tools and Svelte Society](https://www.webrush.io/episodes/episode-150-svelte-tools-and-svelte-society) Kevin Åberg Kultalahti talks about what Svelte Society is, what he's excited about with Svelte, how important documentation is to any product, and much _much_ more
|
||||
- [Svelte: The Compiled Future of Front End](https://www.arahansen.com/the-compiled-future-of-front-end/) details the history of component-based frontends and how a compiler changes everything
|
||||
@ -65,6 +66,7 @@ To see all updates to SvelteKit, check out the [SvelteKit changelog](https://git
|
||||
- [JS Party: 1Password](https://twitter.com/geoffrich_/status/1441816829853253640?s=20) mentioned on the latest episode of The Changelog's JS Party that they use Svelte to power their in-page suggestions
|
||||
|
||||
**Educational Content**
|
||||
|
||||
- [How I built a blog with Svelte and SvelteKit](https://fantinel.dev/blog-development-sveltekit/) is an introduction to Svelte, SvelteKit and Progressive Enhancement with code examples
|
||||
- [I built a decentralized chat dapp](https://www.youtube.com/watch?v=J5x3OMXjgMc) is a tutorial on how to use popular web3 technologies like GUN to build a decentralized web app (dapp)
|
||||
- [Writing a Svelte Store with TypeScript](https://javascript.plainenglish.io/writing-a-svelte-store-with-typescript-22fa1c901a4) is a deep dive into writing Svelte stores with TypeScript
|
||||
@ -73,8 +75,9 @@ To see all updates to SvelteKit, check out the [SvelteKit changelog](https://git
|
||||
- [An early look at SvelteKit](https://www.infoworld.com/article/3630395/an-early-look-at-sveltekit.html) is a post from Infoworld walking through the features and onboarding of SvelteKit
|
||||
|
||||
**Libraries, Tools & Components**
|
||||
|
||||
- [sveltekit-netlify-cms](https://github.com/buhrmi/sveltekit-netlify-cms) is a SvelteKit skeleton app configured for use with Netlify CMS
|
||||
- [SvelteFireTS](https://github.com/jacobbowdoin/sveltefirets) is a SvelteKit + TypeScript + Firebase library inspired by Fireship.io
|
||||
- [SvelteFireTS](https://github.com/jacobbowdoin/sveltefirets) is a SvelteKit + TypeScript + Firebase library inspired by Fireship.io
|
||||
- [stores-x](https://github.com/Anyass3/stores-x) lets you use Svelte stores just like vueX
|
||||
- [sveltekit-snippets](https://github.com/stordahl/sveltekit-snippets) is a VSCode extension that provides snippets for common patterns in SvelteKit & Vanilla Svelte
|
||||
- [svelte-xactor](https://github.com/wobsoriano/svelte-xactor) is a middleware that allows you to easily convert your xactor machines into a global store that implements the store contract
|
||||
@ -86,10 +89,8 @@ To see all updates to SvelteKit, check out the [SvelteKit changelog](https://git
|
||||
- [focus-svelte](https://github.com/chanced/focus-svelte) is a focus trap for Svelte with zero dependencies
|
||||
- [filedrop-svelte](https://github.com/chanced/filedrop-svelte) is a file dropzone action & component for Svelte
|
||||
|
||||
|
||||
Check out the community site [sveltesociety.dev](https://sveltesociety.dev/templates/) for more templates, adders and adapters from across the Svelte ecosystem.
|
||||
|
||||
|
||||
## Before you go, answer the call for speakers!
|
||||
|
||||
Svelte Summit Fall 2021 (happening 20 November 2021) is looking for speakers. Submit your talk proposal before 30 October... all are welcome to present and attend.
|
@ -12,6 +12,7 @@ Also, don't miss out on [Svelte Summit](https://sveltesummit.com/) on November 2
|
||||
Now onto what's new!
|
||||
|
||||
## New in Svelte and SvelteKit
|
||||
|
||||
- [svelte.dev](https://svelte.dev/) now runs on SvelteKit alongside [sveltesociety.dev](https://sveltesociety.dev). svelte.dev is a relatively complicated site with live code editing, authentication, and a markdown-based blog - making it a great way for us to really test out SvelteKit
|
||||
- A new compiler option, `enableSourcemap`, provides more control over the compiler output for JS and CSS sourcemaps (**3.44.0**). With this new feature, SvelteKit and the Vite Svelte plugin can now properly handle environment variables in `.svelte` templates (See [sveltejs/kit#720](https://github.com/sveltejs/kit/issues/720) and [sveltejs/vite-plugin-svelte#201](https://github.com/sveltejs/vite-plugin-svelte/pull/201))
|
||||
- The Svelte Language Tools now support reading the configuration of the VS Code CSS settings ([#1219](https://github.com/sveltejs/language-tools/issues/1219))
|
||||
@ -20,15 +21,14 @@ Now onto what's new!
|
||||
- SvelteKit no longer supports Node 12 ([2604](https://github.com/sveltejs/kit/pull/2604))
|
||||
- SvelteKit was upgraded from Vite 2.6.0 to Vite 2.6.12 fixing an issue where Vite would corrupt the Svelte runtime (https://github.com/vitejs/vite/issues/4306). It also included two fixes from the SvelteKit team to avoid or make diagnosing Vite issues in SvelteKit templates easier (https://github.com/vitejs/vite/pull/5192 and https://github.com/vitejs/vite/pull/5193). Vite 2.7 is currently available in beta with additional fixes for SSR
|
||||
|
||||
|
||||
To see all updates to Svelte and SvelteKit, check out the [Svelte](https://github.com/sveltejs/svelte/blob/master/CHANGELOG.md) and [SvelteKit changelog](https://github.com/sveltejs/kit/blob/master/packages/kit/CHANGELOG.md), respectively.
|
||||
|
||||
|
||||
---
|
||||
|
||||
## Community Showcase
|
||||
|
||||
**Apps & Sites**
|
||||
|
||||
- [Tangent](http://tangentnotes.com/) is a clean and powerful notes app for Mac & Windows
|
||||
- [The Pudding](https://pudding.cool/) is a digital publication that explains ideas debated in culture with visual essays - rebuilt in SvelteKit
|
||||
- [Power Switcher](https://powerswitcher.axpo.com/) is an interactive overview of the development of the power supply in Switzerland, as energy sources migrate to cleaner sources
|
||||
@ -44,6 +44,7 @@ To see all updates to Svelte and SvelteKit, check out the [Svelte](https://githu
|
||||
- [Palitra App](https://palitra.app/) is a search-based color palette generator
|
||||
|
||||
**Podcasts Featuring Svelte**
|
||||
|
||||
- [Svelte Radio](https://www.svelteradio.com/episodes/svelte-summit-is-coming-up-and-svelte-is-growing) dives into the tech behind the recently released Svelte Summit website and a bunch of other fun stuff!
|
||||
- [PodRocket](https://podrocket.logrocket.com/rich-harris), LogRocket's podcast, talks Svelte with Rich Harris
|
||||
- [PodRocket also dove deep](https://podrocket.logrocket.com/elderjs) into Elder.js with Nick Reese
|
||||
@ -51,6 +52,7 @@ To see all updates to Svelte and SvelteKit, check out the [Svelte](https://githu
|
||||
- [devtools.fm](https://devtools.fm/episode/15) talks with Rich Harris about developing engaging data visualizations and building the tools of tomorrow
|
||||
|
||||
**Educational Content**
|
||||
|
||||
- [Have Single-Page Apps Ruined the Web?](https://www.youtube.com/watch?v=860d8usGC0o) Rich Harris answers the controversial question at this year's Jamstack Conf
|
||||
- [Svelte vs SvelteKit - What's The Difference?](https://www.youtube.com/watch?v=IKhtnhQKjxQ) LevelUpTuts provides a quick guide to explaining the relationship between the two projects. You can check out the rest of Scott Tolinski's guides to Svelte in his new series, ["Weekly Svelte"](https://www.youtube.com/playlist?list=PLLnpHn493BHF-Onm1MQgKC1psvW-rJuYi)
|
||||
- [WebJeda's SvelteKit Hooks](https://www.youtube.com/watch?v=RarufLoEL08&list=PLm_Qt4aKpfKgzcTiMT2cgWGBDBIPK06DQ) series continues this month with Part 3 - Cookie Session Authentication
|
||||
@ -61,6 +63,7 @@ To see all updates to Svelte and SvelteKit, check out the [Svelte](https://githu
|
||||
- [What Svelte's accessibility warnings won't tell you](https://geoffrich.net/posts/svelte-a11y-limits/) explains how Svelte's a11y warnings work and why you shouldn't count on them to make your app accessible
|
||||
|
||||
**Libraries, Tools & Components**
|
||||
|
||||
- [svelte-adapter-azure-swa](https://github.com/geoffrich/svelte-adapter-azure-swa) is an adapter for Svelte apps that creates an Azure Static Web App, using an Azure function for dynamic server rendering
|
||||
- [Inlang](https://docs.inlang.dev/getting-started/svelte-kit) is a localization and internationalization toolkit that now supports SvelteKit
|
||||
- [svelte-translate-tools](https://github.com/noelmugnier/svelte-translate-tools) extract/generate/compile translation files for your Svelte App at build time
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
title: "What's new in Svelte: December 2021"
|
||||
description: "Svelte Summit Fall 2021 Recap, Rich Harris joins Vercel, and Kevin goes full-time on Svelte Society"
|
||||
description: 'Svelte Summit Fall 2021 Recap, Rich Harris joins Vercel, and Kevin goes full-time on Svelte Society'
|
||||
author: Dani Sandoval
|
||||
authorURL: https://dreamindani.com
|
||||
---
|
||||
@ -9,12 +9,12 @@ With SvelteKit getting more and more stable each day, there's not much to cover
|
||||
|
||||
If you want to dive deep into the last month's worth of bug fixes, check out the [Svelte](https://github.com/sveltejs/svelte/blob/master/CHANGELOG.md) and [SvelteKit](https://github.com/sveltejs/kit/blob/master/packages/kit/CHANGELOG.md) changelogs, respectively.
|
||||
|
||||
|
||||
## What happened at Svelte Summit?
|
||||
|
||||
If you missed Svelte Summit, you can watch the entire live stream on [YouTube](https://www.youtube.com/watch?v=1Df-9EKvZr0) and catch a recap in the [#svelte-summit channel on Discord](https://discord.gg/YmHcdnhu).
|
||||
|
||||
Here are the highlights:
|
||||
|
||||
- [Rich Harris](https://twitter.com/rich_harris) took us through a tour of Svelte's history and announced [his move to Vercel](https://vercel.com/blog/vercel-welcomes-rich-harris-creator-of-svelte) - where he will be helping maintain Svelte full-time! ([20:00](https://www.youtube.com/watch?v=1Df-9EKvZr0&t=1200s))
|
||||
- [Steph Dietz](https://twitter.com/steph_dietz_) explained how Svelte's simple abstractions makes it easy for beginners and experts alike to learn and use JavaScript - without the boilerplate ([29:00](https://www.youtube.com/watch?v=1Df-9EKvZr0&t=1740s))
|
||||
- [Kevin Bridges](https://twitter.com/kevinast) dove deep into Svelte's reactivity logic by visualizing it through `ReflectiveCounter` and showing how to "fine tune" it, as needed. A full "syllabus" for the presentation is available on [Kevin's site](https://wiibridges.com/presentations/ResponsiveSvelte/). ([42:55](https://www.youtube.com/watch?v=1Df-9EKvZr0&t=2575s))
|
||||
@ -38,17 +38,17 @@ Thanks to [Kevin](https://twitter.com/kevmodrome) and all the Svelte Society vol
|
||||
|
||||
If you have feedback on the Svelte Summit, Kev is [looking for feedback on the Svelte subreddit](https://www.reddit.com/r/sveltejs/comments/qzgo3k/svelte_summit_feedback/) 👀
|
||||
|
||||
|
||||
---
|
||||
|
||||
## Community Showcase
|
||||
|
||||
**Apps & Sites**
|
||||
|
||||
- [pixeldrain](https://github.com/Fornaxian/pixeldrain_web) is a free-to-use file sharing platform
|
||||
- [LifeHash](http://lifehash.info/) generates beautiful visual hashes from Blockchain Commons
|
||||
- [simple-cloud-music](https://github.com/dufu1991/simple-cloud-music) is a lightweight third-party NetEase cloud music player for modern browsers (likely only works on Chrome)
|
||||
- [palette.rocks](https://palette.rocks/) is a color palette generator with contrast-checking built-in
|
||||
- [Kadium](https://github.com/probablykasper/kadium) is an app for staying on top of YouTube channel uploads
|
||||
- [Kadium](https://github.com/probablykasper/kadium) is an app for staying on top of YouTube channel uploads
|
||||
- [Multi-Monitor Calculator](https://multimonitorcalculator.com/) is a tool for planning your multi-monitor setup
|
||||
- [Your Home](https://yourhome.fb.com/) is an interactive overview of Facebook's privacy settings
|
||||
- [Svelte Crush](https://svelte-crush.netlify.app/) is a Candy Crush style match-3 game
|
||||
@ -56,8 +56,8 @@ If you have feedback on the Svelte Summit, Kev is [looking for feedback on the S
|
||||
|
||||
**Looking for a Svelte project to work on? Interested in helping make Svelte's presence on the web better?** Check out [the list of open issues](https://github.com/svelte-society/sveltesociety-2021/issues) if you'd like to contribute to the Svelte Society rewrite in SvelteKit.
|
||||
|
||||
|
||||
**Videos, Blogs and Podcasts**
|
||||
|
||||
- [How To Make and Publish a Svelte Library](https://www.youtube.com/watch?v=_TymiadmPrc)
|
||||
- [SvelteKit is now fully supported in WebContainers](https://blog.stackblitz.com/posts/sveltekit-supported-in-webcontainers/)
|
||||
- [Introducing Svelte, and Comparing Svelte with React and Vue](https://joshcollinsworth.com/blog/introducing-svelte-comparing-with-react-vue)
|
||||
@ -72,6 +72,7 @@ If you have feedback on the Svelte Summit, Kev is [looking for feedback on the S
|
||||
- [Building SvelteKit applications with Serverless Redis](https://blog.upstash.com/svelte-with-serverless-redis)
|
||||
|
||||
**Libraries, Tools & Components**
|
||||
|
||||
- [svelte-cubed](https://github.com/Rich-Harris/svelte-cubed) is a Three.js component library for Svelte - created by Rich Harris for his presentation at Svelte Summit Fall 2021
|
||||
- [svelte-fsm](https://github.com/kenkunz/svelte-fsm) is a tiny, simple, expressive, pragmatic Finite State Machine (FSM) library, optimized for Svelte
|
||||
- [bromb](https://github.com/samuelstroschein/bromb) is a feedback widget for websites/web apps that is small and easy to integration/self-host
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
title: "What's new in Svelte: January 2022"
|
||||
description: "Faster builds with SvelteKit and a much anticipated REPL feature"
|
||||
description: 'Faster builds with SvelteKit and a much anticipated REPL feature'
|
||||
author: Dani Sandoval
|
||||
authorURL: https://dreamindani.com
|
||||
---
|
||||
@ -8,6 +8,7 @@ authorURL: https://dreamindani.com
|
||||
Happy new year, Svelte Community! Lots to share this month across Svelte, SvelteKit, Language Tools and the Showcase. Thanks to everyone who made 2021 a great year to use Svelte. Looking forward to the next one 🚀
|
||||
|
||||
## What's new in SvelteKit
|
||||
|
||||
- `@sveltejs/adapter-static` for SvelteKit now has a `precompress` option to make brotli compression of assets and pages easier to do out of the box ([#3079](https://github.com/sveltejs/kit/pull/3079))
|
||||
- Concurrency mode in SvelteKit will now prerender pages in parallel ([#3120](https://github.com/sveltejs/kit/pull/3120)). It is enabled by default in `1.0.0-next.205` and later
|
||||
- CSS is now automatically included before JS for improved page performance ([d13efe](https://github.com/sveltejs/kit/commit/d138efe21692f5925f1e89afc0a33f42d6a1a711))
|
||||
@ -17,18 +18,18 @@ Happy new year, Svelte Community! Lots to share this month across Svelte, Svelte
|
||||
- After the [update to Vite 2.7](https://github.com/sveltejs/kit/pull/3018), SvelteKit users are [reporting significant performance improvements](https://www.reddit.com/r/sveltejs/comments/rljhfc/sveltekit_massive_compiler_improvement_by/) and loading third-parties libraries in SSR has also been greatly improved
|
||||
- SvelteKit server will now automatically restart when the config files is changed ([vite-plugin-svelte#237](https://github.com/sveltejs/vite-plugin-svelte/pull/237))
|
||||
|
||||
|
||||
## Other new bits from `svelte/*`
|
||||
|
||||
- [Svelte 3.44.3](https://github.com/sveltejs/svelte/blob/master/CHANGELOG.md#3443) is out with a few bug fixes in the binding and loop code
|
||||
- Svelte Language Tools has introduced support for the then/catch shorthands from Svelte 3.41 and TypeScript's "go to" functionality ([105.8.0 and later](https://github.com/sveltejs/language-tools/releases/tag/extensions-105.8.0))
|
||||
- The Svelte REPL got a nice upgrade as well - letting you delete saved REPLs. Try it out by logging in at [svelte.dev/apps](https://svelte.dev/apps)
|
||||
|
||||
|
||||
---
|
||||
|
||||
## Community Showcase
|
||||
|
||||
**Apps & Sites**
|
||||
|
||||
- [Discover Twitter Spaces](https://github.com/navneetsharmaui/discover-twitter-spaces) is a tool that helps you find the Twitter Spaces
|
||||
- [Modern Fluid Typography Editor](https://github.com/codeAdrian/modern-fluid-typography-editor) helps create beautiful fluid typography using CSS clamp
|
||||
- [Unnwhiteboard](https://github.com/AviKKi/unnwhiteboard) is a job board for companies (or teams) that don't do "whiteboard" interviews
|
||||
@ -41,10 +42,10 @@ A lot of work this month has gone into migrating the Svelte main website and Sve
|
||||
|
||||
If you're looking for a fun SvelteKit project to work on, [you can contribute to the Svelte Society site rewrite](https://github.com/svelte-society/sveltesociety-2021/issues) 💅
|
||||
|
||||
|
||||
**Learning and Listening**
|
||||
|
||||
_To Read_
|
||||
|
||||
- [Mutating Query Params in SvelteKit Without Page Reloads or Navigations](https://dev.to/mohamadharith/mutating-query-params-in-sveltekit-without-page-reloads-or-navigations-2i2b) by Mohamad Harith
|
||||
- [Svelte for Reactaholics : A guide for React developers](https://www.100ms.live/blog/svelte-guide-for-react-developers) by Puru Vijay
|
||||
- [Svelte's lifecycle methods can be used anywhere](https://geoffrich.net/posts/svelte-lifecycle-examples/) and [The many meanings of $ in Svelte](https://geoffrich.net/posts/svelte-$-meanings/) by Geoff Rich
|
||||
@ -54,6 +55,7 @@ _To Read_
|
||||
- [What happened in #Svelte language tools this year](https://twitter.com/dummdidumm_/status/1474158105395179525?t=ytj2K2Q52iD5-lNyLnQaAQ&s=19) by Simon H
|
||||
|
||||
_To Watch_
|
||||
|
||||
- [The Future of Svelte (Interview with Rich Harris)](https://www.youtube.com/watch?v=uQntFkK8Z54) by Lee Robinson, Director of Developer Relations at Vercel
|
||||
- [Svelte is becoming the go-to framework](https://www.youtube.com/watch?v=fo6BKY2xR2w&t=1834s) for Obsidian plugin developers
|
||||
- [Sveltekit WordPress Headless Blog](https://www.youtube.com/watch?v=c0UDVgjPxFw) by WebJeda
|
||||
@ -61,10 +63,12 @@ _To Watch_
|
||||
- [Deploy a full-stack SvelteKit app on Cloudflare Pages](https://www.youtube.com/watch?v=Wc1_U6Dy5Tw) by 1nf
|
||||
|
||||
_To Listen To_
|
||||
|
||||
- [Syntax podcast: How To Do Things In Svelte](https://podcasts.apple.com/ca/podcast/how-to-do-things-in-svelte/id1253186678?i=1000544796072)
|
||||
- [JS Party #205: So much Sveltey goodness (w/ Rich Harris)](https://changelog.com/jsparty/205)
|
||||
|
||||
**Libraries, Tools & Components**
|
||||
|
||||
- [svelte-headlessui](https://github.com/rgossiaux/svelte-headlessui) is an unofficial, complete Svelte port of the Headless UI component library
|
||||
- [svelte-forms v2](https://chainlist.github.io/svelte-forms/) has been released - the author is [looking for feedback](https://www.reddit.com/r/sveltejs/comments/r6354j/svelteforms_v2_has_been_released/)
|
||||
- [Percival](https://github.com/ekzhang/percival) is a declarative data query and visualization language
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
title: "Accelerating Svelte's Development"
|
||||
description: "Scaling the team, building partnerships, and growing the community"
|
||||
description: 'Scaling the team, building partnerships, and growing the community'
|
||||
author: Ben McCann
|
||||
authorURL: https://www.benmccann.com/
|
||||
---
|
||||
@ -16,6 +16,7 @@ To help developers build fully-featured applications with Svelte without worryin
|
||||
Rich Harris, Svelte’s creator, has [joined Vercel to work on Svelte full-time](https://vercel.com/blog/vercel-welcomes-rich-harris-creator-of-svelte). We’re incredibly excited to have Rich’s level of involvement in Svelte increase even more and have him steward Svelte into the future.
|
||||
|
||||
Svelte has been made possible by the work of a large, dedicated community. Svelte has added numerous core maintainers over the course of the pandemic, including three this past week. In alphabetical order:
|
||||
|
||||
- [benmccann](https://github.com/benmccann) - primary maintainer of SvelteKit for much of 2021
|
||||
- [bluwy](https://github.com/bluwy) - major contributor across SvelteKit, vite-plugin-svelte, and Vite
|
||||
- [dominikg](https://github.com/dominikg) - creator of vite-plugin-svelte
|
||||
@ -42,7 +43,8 @@ We’ve also been working closely with the [Vite](https://vitejs.dev) team to ir
|
||||
|
||||
[SvelteSociety](https://sveltesociety.dev/) just hosted the [4th Svelte Summit](https://sveltesummit.com/) — [read a summary here](https://svelte.dev/blog/whats-new-in-svelte-december-2021#what-happened-at-svelte-summit) — and Kevin Åberg Kultalahti is [going full-time to lead SvelteSociety](https://twitter.com/kevmodrome/status/1463151477174714373). In addition to hosting Svelte Summit, Kevin and SvelteSociety host and manage the [Svelte Radio podcast](https://www.svelteradio.com/), the [SvelteSociety YouTube channel](https://www.youtube.com/SvelteSociety), and the [Svelte subreddit](https://www.reddit.com/r/sveltejs). SvelteSociety has become the home of all things related to the Svelte community, with the sveltejs/community and sveltejs/integrations repos being retired in favor of [sveltesociety.dev](https://sveltesociety.dev/), which has been redesigned and rebuilt in SvelteKit. In October [Brittney Postma](https://github.com/brittneypostma), [Willow aka GHOST](https://ghostdev.xyz), [Steph Dietz](https://github.com/StephDietz), and [Gen Ashley](https://twitter.com/coderinheels) founded [Svelte Sirens](https://sveltesirens.dev/), a group for women & non-binary community members and their allies.
|
||||
|
||||
Hundreds of developers join the Svelte Discord every week to chat about Svelte. You may have noticed that, as of recently, some members of the server have purple names. These are people with the ambassadors role, which was created to recognise some of the community’s most valued members and help manage the demands of a rapidly growing community. Svelte ambassadors are people who are well known for their helpfulness and contributions and for upholding Svelte’s reputation as a friendly, welcoming community, and we’re deeply grateful for their involvement. The initial ambassadors in alphabetical order are:
|
||||
Hundreds of developers join the Svelte Discord every week to chat about Svelte. You may have noticed that, as of recently, some members of the server have purple names. These are people with the ambassadors role, which was created to recognise some of the community’s most valued members and help manage the demands of a rapidly growing community. Svelte ambassadors are people who are well known for their helpfulness and contributions and for upholding Svelte’s reputation as a friendly, welcoming community, and we’re deeply grateful for their involvement. The initial ambassadors in alphabetical order are:
|
||||
|
||||
- [babichjacob](https://github.com/babichjacob)
|
||||
- [brady fractal](https://github.com/FractalHQ)
|
||||
- [brittney postma](https://github.com/brittneypostma)
|
||||
@ -56,7 +58,7 @@ Hundreds of developers join the Svelte Discord every week to chat about Svelte.
|
||||
- [swyx](https://github.com/sw-yx)
|
||||
- [theo](https://github.com/theo-steiner)
|
||||
|
||||
We’re also testing out [GitHub discussions on SvelteKit](https://github.com/sveltejs/kit/discussions) and may bring this to other repos in the Svelte organization if feedback is positive.
|
||||
We’re also testing out [GitHub discussions on SvelteKit](https://github.com/sveltejs/kit/discussions) and may bring this to other repos in the Svelte organization if feedback is positive.
|
||||
|
||||
## Things to watch
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
title: "What's new in Svelte: February 2022"
|
||||
description: "Rapid-fire releases across Svelte, SvelteKit and the community"
|
||||
description: 'Rapid-fire releases across Svelte, SvelteKit and the community'
|
||||
author: Dani Sandoval
|
||||
authorURL: https://dreamindani.com
|
||||
---
|
||||
@ -10,12 +10,14 @@ Happy February, everyone! Over the last month or so, we've seen Svelte and Svelt
|
||||
Let's take a look...
|
||||
|
||||
## Highlights from the Svelte changelog
|
||||
|
||||
- **3.45.0** brought a [new a11y warning `a11y-no-redundant-roles`](https://svelte.dev/docs#accessibility-warnings-a11y-no-redundant-roles), destructuring and caching fixes
|
||||
- **3.46.0** added the much requested [`{@const}` tag](https://svelte.dev/docs#template-syntax-const) and [`style:` directive](https://svelte.dev/docs#template-syntax-element-directives-style-property)
|
||||
- Check out **3.46.1 - 3.46.3** for fixes to the `{@const}` tag and `style:` directive, along with a number of fixes to animations
|
||||
- [AST output is now available in the Svelte REPL](https://svelte.dev/repl/hello-world)
|
||||
|
||||
## What's new in SvelteKit
|
||||
|
||||
- `inlineStyleThreshold` allows you to specify where inline stylesheets are inserted into the page ([Docs](https://kit.svelte.dev/docs/configuration#inlinestylethreshold), [#2620](https://github.com/sveltejs/kit/pull/2620))
|
||||
- `beforeNavigate`/`afterNavigate` lifecycle functions lets you add functionality before or after a page navigation ([Docs](https://kit.svelte.dev/docs/modules#$app-navigation), [#3293](https://github.com/sveltejs/kit/pull/3293))
|
||||
- Platform context can now be passed from adapters ([Docs](https://kit.svelte.dev/docs/adapters#supported-environments-platform-specific-context), [#3429](https://github.com/sveltejs/kit/pull/3429))
|
||||
@ -24,23 +26,26 @@ Let's take a look...
|
||||
- Fallthrough routes let you specify where to route when an route can't be loaded ([Docs](https://kit.svelte.dev/docs/routing#advanced-routing-fallthrough-routes), [#3217](https://github.com/sveltejs/kit/pull/3217))
|
||||
|
||||
**New configs**
|
||||
|
||||
- Content Security Policy (CSP) is now supported for increased security when using inline javascript or stylesheets ([Docs](https://kit.svelte.dev/docs/configuration#csp), [#3499](https://github.com/sveltejs/kit/pull/3499))
|
||||
- `kit.routes` config allows you to customise public/private modules during build ([Docs](https://kit.svelte.dev/docs/configuration#routes), [#3576](https://github.com/sveltejs/kit/pull/3576))
|
||||
- `prerender.createIndexFiles` config lets you prerender index.html files as their subfolder's name ([Docs](https://kit.svelte.dev/docs/configuration#prerender), [#2632](https://github.com/sveltejs/kit/pull/2632))
|
||||
- HTTP methods can now be overridden using `kit.methodOverride` ([Docs](https://kit.svelte.dev/docs/routing#endpoints-http-method-overrides), [#2989](https://github.com/sveltejs/kit/pull/2989))
|
||||
|
||||
**Config changes**
|
||||
|
||||
- `config.kit.hydrate` and `config.kit.router` are now nested under `config.kit.browser` ([Docs](https://kit.svelte.dev/docs/configuration#browser), [3578](https://github.com/sveltejs/kit/pull/3578))
|
||||
|
||||
**Breaking change**
|
||||
- use `Request` and `Response` objects in endpoints and hooks ([#3384](https://github.com/sveltejs/kit/pull/3384))
|
||||
|
||||
- use `Request` and `Response` objects in endpoints and hooks ([#3384](https://github.com/sveltejs/kit/pull/3384))
|
||||
|
||||
---
|
||||
|
||||
## Community Showcase
|
||||
|
||||
**Apps & Sites**
|
||||
|
||||
- [timb(re)](https://paullj.github.io/timb) is a live music programming environment
|
||||
- [Music for Programming](https://musicforprogramming.net/latest/) is a series of mixes intended for listening while `${task}` to focus the brain and inspire the mind
|
||||
- [Team Tale](https://teamtale.app/) allows two authors to write the same story in a tag-team sort of fashion
|
||||
@ -59,10 +64,10 @@ Let's take a look...
|
||||
|
||||
Want to work on a SvelteKit site with others, [try contributing to the Svelte Society site](https://github.com/svelte-society/sveltesociety-2021/issues)!
|
||||
|
||||
|
||||
**Learning and Listening**
|
||||
|
||||
_To Read_
|
||||
|
||||
- [Accelerating Svelte's Development](https://svelte.dev/blog/accelerating-sveltes-development) by Ben McCann
|
||||
- [Storybook for Vite](https://storybook.js.org/blog/storybook-for-vite/)
|
||||
- [Let's learn SvelteKit by building a static Markdown blog from scratch](https://joshcollinsworth.com/blog/build-static-sveltekit-markdown-blog) by Josh Collinsworth
|
||||
@ -74,6 +79,7 @@ _To Read_
|
||||
- [Comparing Svelte Reactivity Options](https://opendirective.net/2022/01/06/comparing-svelte-reactivity-options/) by Steve Lee
|
||||
|
||||
_To Watch_
|
||||
|
||||
- [Integrating Storybook with SvelteKit](https://www.youtube.com/watch?v=Kc1ULlfyUcw) and [Integrating FaunaDB with Svelte](https://www.youtube.com/watch?v=zaoLZc76uZM) by the Svelte Sirens
|
||||
- [SvelteKit Crash Course Tutorial](https://www.youtube.com/watch?v=9OlLxkaeVvw&list=PL4cUxeGkcC9hpM9ARM59Ve3jqcb54dqiP) by The Net Ninja
|
||||
- [Svelte for Beginners](https://www.youtube.com/watch?v=BrkrOjknC_E&list=PLA9WiRZ-IS_ylnMYxIFCsZN6xVVSvLuHk) by Joy of Code
|
||||
@ -82,11 +88,13 @@ _To Watch_
|
||||
- [Sveltekit - Get All Routes/Pages](https://www.youtube.com/watch?v=Y_NE2R3HuOU) by WebJeda
|
||||
|
||||
_To Listen To_
|
||||
|
||||
- [New Year, New Svelte!?](https://share.transistor.fm/s/36212cdc) from Svelte Radio
|
||||
- [So much Sveltey goodness (featuring Rich Harris)](https://changelog.com/jsparty/205) from JS Party
|
||||
- [The Other Side of Tech: A Documentarian Perspective (with Stefan Kingham)](https://codingcat.dev/podcast/2-4-the-other-side-of-tech-a-documentarian-perspective) from Purrfect.dev
|
||||
|
||||
**Libraries, Tools & Components**
|
||||
|
||||
- [threlte](https://github.com/grischaerbe/threlte) is a three.js component library for Svelte
|
||||
- [svelte-formify](https://github.com/nodify-at/svelte-formify) is a library to manage and validate forms that uses decorators to define validations
|
||||
- [gQuery](https://github.com/leveluptuts/gQuery) is a GraphQL Fetcher & Cache for Svelte Kit
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
title: "What's new in Svelte: March 2022"
|
||||
description: "Svelte Summit Spring is coming... and page endpoints are here!"
|
||||
description: 'Svelte Summit Spring is coming... and page endpoints are here!'
|
||||
author: Dani Sandoval
|
||||
authorURL: https://dreamindani.com
|
||||
---
|
||||
@ -12,29 +12,30 @@ Also, some long-requested features were added to SvelteKit this month... includi
|
||||
More on that and other new features and fixes below!
|
||||
|
||||
## What's new in SvelteKit
|
||||
|
||||
- The docs are now searchable and multipage with type definitions and hoverable code examples - Check them out at [kit.svelte.dev/docs](https://kit.svelte.dev/docs/)
|
||||
- Page endpoints significantly decrease the boilerplate needed when loading a page ([Issue](https://github.com/sveltejs/kit/issues/3532), [PR](https://github.com/sveltejs/kit/pull/3679), [Docs](https://kit.svelte.dev/docs/routing#endpoints-page-endpoints))
|
||||
- Application versioning and update detection support lets you determine what to do when a route fails to load after an app update ([Issue](https://github.com/sveltejs/kit/issues/87), [PR](https://github.com/sveltejs/kit/pull/3412), [Docs](https://kit.svelte.dev/docs/configuration#version))
|
||||
- A new option in `npm init svelte@next` will now set up Playwright automatically for testing ([PR](https://github.com/sveltejs/kit/pull/4056))
|
||||
|
||||
|
||||
**Breaking Changes**
|
||||
|
||||
- The `target` option is no longer available. Instead, the `init` script hydrates its `parentNode` ([#3674](https://github.com/sveltejs/kit/pull/3674))
|
||||
- App-level types now live in the `App` namespace which allows you to type global types like `Stuff` or `Session` ([#3670](https://github.com/sveltejs/kit/pull/3670))
|
||||
- `JSONString` is now `JSONValue` ([#3683](https://github.com/sveltejs/kit/pull/3683))
|
||||
- `createIndexFiles` has been removed — it is now controlled by the `trailingSlash` option ([#3801](https://github.com/sveltejs/kit/pull/3801))
|
||||
- SvelteKit will no longer exclude root-relative external links from prerendering, which will cause 404s if these URLs are intended to be served by a separate app. Use a custom [`prerender.onError`](https://kit.svelte.dev/docs/configuration#prerender) handler if you need to ignore them ([#3826](https://github.com/sveltejs/kit/pull/3826))
|
||||
|
||||
|
||||
## New in Language Tools
|
||||
- Accessing properties in markups has been improved in the Svelte language tools ([105.12.0](https://github.com/sveltejs/language-tools/releases/tag/extensions-105.12.0)) - working around some known issues with autocomplete ([#538](https://github.com/sveltejs/language-tools/issues/538) / [#1302](https://github.com/sveltejs/language-tools/issues/1302))
|
||||
|
||||
- Accessing properties in markups has been improved in the Svelte language tools ([105.12.0](https://github.com/sveltejs/language-tools/releases/tag/extensions-105.12.0)) - working around some known issues with autocomplete ([#538](https://github.com/sveltejs/language-tools/issues/538) / [#1302](https://github.com/sveltejs/language-tools/issues/1302))
|
||||
|
||||
---
|
||||
|
||||
## Community Showcase
|
||||
|
||||
**Apps & Sites**
|
||||
|
||||
- [SvelteStorm](https://github.com/open-source-labs/SvelteStorm) is specifically tailored to provide all of the essential tools a Svelte developer needs to build a Svelte application
|
||||
- [Supachat](https://github.com/Lleweraf/supachat) is a real-time chat app using Svelte and Supabase
|
||||
- [Radicle](https://radicle.xyz/) is a peer-to-peer stack for building software together
|
||||
@ -49,10 +50,10 @@ More on that and other new features and fixes below!
|
||||
|
||||
Want to work on a SvelteKit site with others? [Contribute to the Svelte Society site](https://github.com/svelte-society/sveltesociety.dev/issues)!
|
||||
|
||||
|
||||
**Learning Resources**
|
||||
|
||||
_To Read_
|
||||
|
||||
- [Svelte Components as Web Components](https://medium.com/@yesmeno/svelte-components-as-web-components-b400d1253504) by Matias Meno
|
||||
- [Simple Svelte Routing with Reactive URLs](https://bjornlu.com/blog/simple-svelte-routing-with-reactive-urls) by Bjorn Lu
|
||||
- [Leveling Up my Sveltekit / Sanity.io Blog Content with Featured Videos and Syntax Highlighting](https://ryanboddy.net/level-up-blog) by Ryan Boddy
|
||||
@ -64,12 +65,13 @@ _To Read_
|
||||
- [SvelteKit and the "Client pattern"](https://retro.cloud/sveltekit-and-the-client-pattern/) by Julian Laubstein
|
||||
|
||||
_To Watch_
|
||||
|
||||
- [~~Shadow~~ Page Endpoints In Svelte Kit - Weekly Svelte](https://www.youtube.com/watch?v=PoYPZT7ruqI) by LevelUpTuts
|
||||
- [Testing For Beginners (Playlist)](https://www.youtube.com/watch?v=y53wwdBr5AI&list=PLA9WiRZ-IS_z7KpqhPELfEMbhAGRwZrzn) by Joy of Code
|
||||
- [KitQL - The native SvelteKit library for GraphQL](https://www.youtube.com/watch?v=6pH4fnFN70w) by Jean-Yves COUËT
|
||||
|
||||
|
||||
**Libraries, Tools & Components**
|
||||
|
||||
- [gosvelte](https://github.com/sachinbhutani/gosvelte) is a proof of concept to serve Svelte-generated pages on GoLang HTTP server with server data being sent as props to svelte components
|
||||
- [svelte-ethers-store](https://www.npmjs.com/package/svelte-ethers-store) uses the ethers.js library as a collection of readable Svelte stores for Svelte, Sapper or SvelteKit
|
||||
- [Fluid Grid](https://fluid-grid.com/) is a CSS grid system for future web
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
title: "What's new in Svelte: April 2022"
|
||||
description: "Goodbye fallthrough routes, hello param validators!"
|
||||
description: 'Goodbye fallthrough routes, hello param validators!'
|
||||
author: Dani Sandoval
|
||||
authorURL: https://dreamindani.com
|
||||
---
|
||||
@ -10,18 +10,19 @@ This month, we felt a shift in the way SvelteKit handles page properties. The la
|
||||
More on that, and what else is new in Svelte, as we dive in...
|
||||
|
||||
## What's new in SvelteKit
|
||||
|
||||
- Param matchers allow you to check if a url parameter matches before rendering a page - replacing the need for fallthrough routes for this purpose ([Docs](https://kit.svelte.dev/docs/routing#advanced-routing-matching), [#4334](https://github.com/sveltejs/kit/pull/4334))
|
||||
- Explicit redirects can now be handled directly from endpoints ([#4260](https://github.com/sveltejs/kit/pull/4260))
|
||||
- `svelte-kit sync` ([#4182](https://github.com/sveltejs/kit/pull/4182)), TypeScript 4.6 ([#4190](https://github.com/sveltejs/kit/pull/4190)) and Vite 2.9 were released - adding non-blocking dependency optimization and experimental CSS source maps in dev mode as well as a number of bug fixes contributed by the SvelteKit team ([#4468](https://github.com/sveltejs/kit/pull/4468))
|
||||
|
||||
|
||||
**New Config Options**
|
||||
|
||||
- `outDir` fixes path issues in monorepos and other situations where the desired output directory is outside the project directory ([Docs](https://kit.svelte.dev/docs/configuration#outdir), [#4176](https://github.com/sveltejs/kit/pull/4176))
|
||||
- `endpointExtensions` prevents files other than .js and .ts files from being treated as endpoints, unless you specify endpointExtensions ([Docs](https://kit.svelte.dev/docs/configuration#endpointextensions), [#4197](https://github.com/sveltejs/kit/pull/4197))
|
||||
- `prerender.default` lets you prerender every page without having to write `export const prerender = true` in every page file ([Docs](https://kit.svelte.dev/docs/configuration#prerender), [#4192](https://github.com/sveltejs/kit/pull/4192))
|
||||
|
||||
|
||||
**Breaking Changes**
|
||||
|
||||
- Fallthrough routes have been removed. For migration tips, check out the PR ([#4330](https://github.com/sveltejs/kit/pull/4330))
|
||||
- `tabindex="-1"` is only added to `<body>` during navigation ([#4140](https://github.com/sveltejs/kit/pull/4140) and [#4184](https://github.com/sveltejs/kit/pull/4184))
|
||||
- Adapters are now required to supply a `getClientAddress` function ([#4289](https://github.com/sveltejs/kit/pull/4289))
|
||||
@ -29,8 +30,8 @@ More on that, and what else is new in Svelte, as we dive in...
|
||||
- The `\$` character is no longer allowed in dynamic parameters ([#4334](https://github.com/sveltejs/kit/pull/4334))
|
||||
- `svelte-kit package` has been marked as experimental so changes to it after Kit 1.0 will not be considered breaking ([#4164](https://github.com/sveltejs/kit/pull/4164))
|
||||
|
||||
|
||||
## New across the Svelte ecosystem
|
||||
|
||||
- Svelte: Lots of new types for TypeScript and Svelte plugin users - including `style:` directives and Svelte Actions (**3.46.4** and **3.46.5**)
|
||||
- Language Tools: Svelte project files are now importable/findable through references without having them imported in a TS file ([105.13.0](https://github.com/sveltejs/language-tools/releases/tag/extensions-105.13.0))
|
||||
- Language Tools: Region folding is now supported in html with `<!--#region-->`/`<!--#endregion-->` ([105.13.0](https://github.com/sveltejs/language-tools/releases/tag/extensions-105.13.0))
|
||||
@ -40,6 +41,7 @@ More on that, and what else is new in Svelte, as we dive in...
|
||||
## Community Showcase
|
||||
|
||||
**Apps & Sites built with Svelte**
|
||||
|
||||
- [Launcher](https://launcher.team/) is an open-source app launcher powered by SvelteKit, Prisma, and Tailwind
|
||||
- [Paaster](https://paaster.io/) is a secure by default end to end encrypted pastebin built with Svelte, Vite, TypeScript, Python, Starlette, rclone & Docker.
|
||||
- [Simple AF Video Converter](https://github.com/berlyozzy/Simple-AF-Video-Converter) is an Electron wrapper around ffmpeg.wasm to make converting videos between formats easier
|
||||
@ -50,7 +52,7 @@ More on that, and what else is new in Svelte, as we dive in...
|
||||
- [Multiply](https://www.multiply.us/) is an integrated PR and Social agency moving at the speed of culture
|
||||
- [yia!](https://www.yia.co.nz/) is a Young Innovator Award competition in New Zealand
|
||||
- [Write to Russia](https://www.writetorussia.org/index) is a community email writing platform to communicate with public `.ru` email addresses
|
||||
- [Markdown Playground](https://github.com/Petros-K/markdown-playground) is an online playground dedicated for your markdown experiments.
|
||||
- [Markdown Playground](https://github.com/Petros-K/markdown-playground) is an online playground dedicated for your markdown experiments.
|
||||
- [RatherMisty](https://rathermisty.com/) is a no frills weather app with weather data from Open-Meteo
|
||||
- [Minecraft Profile Pic (MCPFP)](https://github.com/MauritsWilke/mcpfp) is a site to generate Minecraft profile pictures with ease
|
||||
- [WebGL Fluid Simulation](https://github.com/jpaquim/svelte-webgl-fluid-simulation) is a configurable fluid simulation built with Svelte and WebGL
|
||||
@ -58,13 +60,14 @@ More on that, and what else is new in Svelte, as we dive in...
|
||||
|
||||
Itching to contribute to a modern SvelteKit website? [Help build the Svelte Society site](https://github.com/svelte-society/sveltesociety.dev/issues)!
|
||||
|
||||
|
||||
**Learning Resources**
|
||||
|
||||
_To Attend_
|
||||
|
||||
- [Svelte Summit: Spring](https://www.sveltesummit.com/) will take place on April 30, 2022! Join us for the 5th virtual Svelte conference on [YouTube](https://www.sveltesummit.com/) and Discord 🍾
|
||||
|
||||
_To Read_
|
||||
|
||||
- [Svelte(Kit) TypeScript Showcase + general TypeScript tips](https://github.com/ivanhofer/sveltekit-typescript-showcase) by Hofer Ivan
|
||||
- [Local constants in Svelte with the @const tag](https://geoffrich.net/posts/local-constants/) by Geoff Rich
|
||||
- [Design Patterns for Building Reusable Svelte Components](https://render.com/blog/svelte-design-patterns) by Eric Liu
|
||||
@ -78,6 +81,7 @@ _To Read_
|
||||
- [React ⇆ Svelte Cheatsheet](https://dev.to/joshnuss/react-to-svelte-cheatsheet-1a2a) lists the similarities and differences between the two libraries - by Joshua Nussbaum
|
||||
|
||||
_To Watch_
|
||||
|
||||
- [Svelte Extravaganza | Async](https://www.youtube.com/watch?v=mT4CLVHgtSg) by pngwn
|
||||
- [6 Svelte Packages You Should Know](https://www.youtube.com/watch?v=y5SrUKcX_Co) and [Basic React To Svelte Conversion](https://www.youtube.com/watch?v=DiSuwLlhOxs) by LevelUpTuts
|
||||
- [Page/Shadow Endpoint in SvelteKit](https://www.youtube.com/watch?v=j-9D5UDyVOM) by WebJeda
|
||||
@ -86,8 +90,8 @@ _To Watch_
|
||||
- [Fullstack SvelteKit Auth 🔐 with Firebase & Magic Links! 🪄](https://www.youtube.com/watch?v=MAHE4iQgh5Q) by Johnny Magrippis
|
||||
- [Firebase Authentication in SvelteKit! Full Stack App](https://www.youtube.com/watch?v=N6Y3hqhZvNI) by Ryan Boddy
|
||||
|
||||
|
||||
**Libraries, Tools & Components**
|
||||
|
||||
- [SvelTable](https://sveltable.io/) is a feature rich, data table component built with Svelte
|
||||
- [svelte-cyberComp](https://github.com/Cybersteam00/svelte-cyberComp) is a powerful, lightweight component library written in Svelte and TypeScript
|
||||
- [Flowbite Svelte](https://github.com/shinokada/flowbite-svelte) is an unofficial Flowbite component library for Svelte
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
title: "What's new in Svelte: May 2022"
|
||||
description: "Dynamically switch between HTML element types with `<svelte:element>`"
|
||||
description: 'Dynamically switch between HTML element types with `<svelte:element>`'
|
||||
author: Dani Sandoval
|
||||
authorURL: https://dreamindani.com
|
||||
---
|
||||
@ -8,10 +8,11 @@ authorURL: https://dreamindani.com
|
||||
With yesterday's Svelte Summit behind us, we've got a lot of news to share! Check out all of the recordings on the [Svelte Society YouTube Channel](https://www.youtube.com/sveltesociety) and the rest of this month's updates below...
|
||||
|
||||
## What's new in Svelte
|
||||
|
||||
- The `<svelte:element>` element lets you render an element of a dynamically specified type. This is useful, for example, when rendering rich text content from a CMS. Check out the [docs](https://svelte.dev/docs#template-syntax-svelte-element) or the [tutorial](https://svelte.dev/tutorial/svelte-element) for more info (**3.47.0**)!
|
||||
|
||||
|
||||
## Language Tools updates
|
||||
|
||||
- `svelte:element` and `sveltekit:reload` are now supported
|
||||
- Invalid Svelte import paths will now be automatically detected - see PR for getting back the old behavior ([#1448](https://github.com/sveltejs/language-tools/pull/1448))
|
||||
- `source.sortImports` lets you sort imports without deleting unused imports ([#1338](https://github.com/sveltejs/language-tools/issues/1338))
|
||||
@ -19,23 +20,24 @@ With yesterday's Svelte Summit behind us, we've got a lot of news to share! Chec
|
||||
- In VS Code, you can now wrap existing blocks of code in control flow tags using the `Insert Snippet` command ([#1373](https://github.com/sveltejs/language-tools/pull/1373))
|
||||
|
||||
## What's new in SvelteKit
|
||||
|
||||
- Files and directories can now be named `__tests__` and `__test__` in the routes directory ([#4438](https://github.com/sveltejs/kit/pull/4438))
|
||||
- Netlify Edge Functions ([#4657](https://github.com/sveltejs/kit/pull/4657)) and the Vercel build output API ([#4663](https://github.com/sveltejs/kit/pull/4663)) are now supported
|
||||
- Custom `load` dependencies, array of strings representing URLs the page depends on, are now available when loading routes ([Docs](https://kit.svelte.dev/docs/loading#output-dependencies), [#4536](https://github.com/sveltejs/kit/pull/4536))
|
||||
|
||||
|
||||
**Breaking Changes**
|
||||
|
||||
- Validators are now called "matchers" ([Docs](https://kit.svelte.dev/docs/routing#advanced-routing-matching), [#4358](https://github.com/sveltejs/kit/pull/4358))
|
||||
- `__layout.reset` has been replaced by named layouts - which have much configurability for shared layout elements ([Docs](https://kit.svelte.dev/docs/layouts#named-layouts), [#4388](https://github.com/sveltejs/kit/pull/4388))
|
||||
- Prerendering is now skipped for `rel="external"` links ([#4545](https://github.com/sveltejs/kit/pull/4545))
|
||||
- `maxage` is now `cache` in `LoadOutput` ([#4690](https://github.com/sveltejs/kit/pull/4690))
|
||||
|
||||
|
||||
---
|
||||
|
||||
## Community Showcase
|
||||
|
||||
**Apps & Sites built with Svelte**
|
||||
|
||||
- [polySpectra AR](https://ar.polyspectra.com/) lets you prototype faster 3D Printing with seamless AR file handoffs ([video demo](https://www.youtube.com/watch?v=VhYCeVGcG3E))
|
||||
- [Pixel Art Together](https://github.com/liveblocks/pixel-art-together) is a free multiplayer pixel art editor powered by Liveblocks
|
||||
- [Tooling Manager](https://tooling-manager.netlify.app/) lets you compare your JavaScript tech stack against industry standard boilerplates
|
||||
@ -49,10 +51,10 @@ With yesterday's Svelte Summit behind us, we've got a lot of news to share! Chec
|
||||
|
||||
Want to contribute to a modern SvelteKit website? [Help build the Svelte Society site](https://github.com/svelte-society/sveltesociety.dev/issues)!
|
||||
|
||||
|
||||
**Learning Resources**
|
||||
|
||||
_To Read_
|
||||
|
||||
- [4 tips for cleaner Svelte components](https://geoffrich.net/posts/clean-component-tips/) by Geoff Rich
|
||||
- [Building a Clubhouse clone with Svelte and 100ms](https://www.100ms.live/blog/clubhouse-clone-with-svelte) By Seun Taiwo
|
||||
- [SvelteKit uvu Testing: Fast Component Unit Tests](https://rodneylab.com/sveltekit-uvu-testing/) by Rodney Lab
|
||||
@ -61,21 +63,22 @@ _To Read_
|
||||
- [Add Commitint, Commitizen, Standard Version, and Husky to SvelteKit Project](https://davipon.hashnode.dev/add-commitint-commitizen-standard-version-and-husky-to-sveltekit-project) by David Peng
|
||||
|
||||
_To Watch or Hear_
|
||||
|
||||
- [Rich Harris - The Road to SvelteKit 1.0 (Svelte Society NYC)](https://www.youtube.com/watch?v=s6a1pbTVcUs) by Svelte Society
|
||||
- [Svelte Fundamentals - Intro to Svelte](https://codingcat.dev/course/intro-to-svelte) by Coding Cat
|
||||
- [Svelte Components Using Custom Markdown Renderers - Weekly Svelte](https://www.youtube.com/watch?v=ZiEROAqobwM) by LevelUpTuts
|
||||
- [Implementing {@const} in if block](https://www.youtube.com/watch?v=f5iReGqjmG0) by lihautan
|
||||
- [Svelte and Contributing to Open-Source with Geoff Rich](https://podcast.20minjs.com/1952066/10417700-episode-6-svelte-and-contributing-to-open-source-with-geoff-rich) by 20minJS
|
||||
|
||||
|
||||
**Libraries, Tools & Components**
|
||||
|
||||
- [KitDocs](https://github.com/svelteness/kit-docs) is a documentation integration for SvelteKit - like VitePress for Svelte.
|
||||
- [Svelte Copy](https://github.com/ghostdevv/svelte-copy) is a click/tap-to-copy library that makes it easy to copy to the clipboard
|
||||
- [Svend3r](https://github.com/oslabs-beta/svend3r) provides beautiful visualizations that harness the power of D3 to bring your data to life while abstracting away its imperative-style code
|
||||
- [Svelte Hamburgers](https://github.com/ghostdevv/svelte-hamburgers) is the easy to use Hamburger menu component for Svelte
|
||||
- [Svelte Droplet](https://github.com/probablykasper/svelte-droplet) is a file dropzone for Svelte
|
||||
- [Svelte MP3](https://www.npmjs.com/package/svelte-mp3) is a light blazingly fast yet simple minimalistic audio player for Svelte
|
||||
- [SvelteUI](https://github.com/Brisklemonade/svelteui) is a component library for building fully functional & accessible web applications faster than ever
|
||||
- [Svelte MP3](https://www.npmjs.com/package/svelte-mp3) is a light blazingly fast yet simple minimalistic audio player for Svelte
|
||||
- [SvelteUI](https://github.com/Brisklemonade/svelteui) is a component library for building fully functional & accessible web applications faster than ever
|
||||
- [svelte-spotlight](https://github.com/beynar/svelte-spotlight) is a headless spotlight component to help you build your site's global search box in minutes
|
||||
- [svelte-pdf-simple](https://github.com/gspasov/svelte-pdf-simple) is a simple svelte library for displaying PDFs and giving you all the control
|
||||
- [persistent-svelte-store](https://github.com/omer-g/persistent-svelte-store) is a generic persistent writable store, built from scratch in TypeScript according to the Svelte store contract
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
title: "What's new in Svelte: June 2022"
|
||||
description: "Cancellable dispatched events, deeper {@const} declarations and more!"
|
||||
description: 'Cancellable dispatched events, deeper {@const} declarations and more!'
|
||||
author: Dani Sandoval
|
||||
authorURL: https://dreamindani.com
|
||||
---
|
||||
@ -10,17 +10,19 @@ With last month's [Svelte Summit](https://www.youtube.com/watch?v=qqj2cBockqE) b
|
||||
Let's dive in!
|
||||
|
||||
## What's new in Svelte
|
||||
|
||||
- Custom events can now be cancelled in the `createEventDispatcher` function (**3.48.0**, [Docs](https://svelte.dev/docs#run-time-svelte-createeventdispatcher), [PR](https://github.com/sveltejs/svelte/pull/7064))
|
||||
- The `{@const}` tag can now be used in `{#if}` blocks to conditionally define variables (**3.48.0**, [Docs](https://svelte.dev/docs#template-syntax-const), [PR](https://github.com/sveltejs/svelte/pull/7451))
|
||||
- Lots of bug fixes across `<svelte:element>`, animations and various DOM elements. Check out the [CHANGELOG](https://github.com/sveltejs/svelte/blob/master/CHANGELOG.md#3480) for a deeper dive!
|
||||
|
||||
|
||||
## What's new in SvelteKit
|
||||
|
||||
- Vite 2.9.9 was released as one of the last Vite 2 releases. The Svelte team has been hard at work contributing to the Vite 3 release to make the integration between SvelteKit and Vite smoother than ever ([Vite 3.0 Milestone](https://github.com/vitejs/vite/milestone/5))
|
||||
- `config.kit.alias` lets you more easily declare a custom alias to replace values in `import` statements ([Docs](https://kit.svelte.dev/docs/configuration#alias), [PR](https://github.com/sveltejs/kit/pull/4964))
|
||||
- Pages marked for prerendering will now fail during SSR at runtime ([PR](https://github.com/sveltejs/kit/pull/4812))
|
||||
|
||||
**Breaking Changes**
|
||||
|
||||
- Node 14 is no longer supported ([PR](https://github.com/sveltejs/kit/pull/4922))
|
||||
- Requests to `/favicon.ico` will no longer be suppressed and will instead be handled as a valid route ([PR](https://github.com/sveltejs/kit/pull/5046))
|
||||
- AMP support has been moved to a separate `@sveltejs/amp` package ([Docs](https://kit.svelte.dev/docs/seo#manual-setup-amp), [PR](https://github.com/sveltejs/kit/pull/4710))
|
||||
@ -34,6 +36,7 @@ Let's dive in!
|
||||
## Community Showcase
|
||||
|
||||
**Apps & Sites built with Svelte**
|
||||
|
||||
- [Plantarium](https://github.com/jim-fx/plantarium) is a tool for the procedural generation of 3D plants.
|
||||
- [SPATULA](https://github.com/AlexWarnes/lamina-spatula) is a tool for building shading materials that are exportable as code material in any project that uses lamina and threejs
|
||||
- [Waaard](https://waaard.com/) lets you create and send protected links with a variety of SSO providers
|
||||
@ -48,10 +51,10 @@ Let's dive in!
|
||||
|
||||
Looking for a great SvelteKit website to contribute to? [Help build the Svelte Society site](https://github.com/svelte-society/sveltesociety.dev/issues)!
|
||||
|
||||
|
||||
**Learning Resources**
|
||||
|
||||
_To Read_
|
||||
|
||||
- [Component party](https://component-party.dev/) is a site that compares common patterns in different frameworks
|
||||
- [Quick tip: style prop defaults](https://geoffrich.net/posts/style-prop-defaults/) by Geoff Rich
|
||||
- [Working with reduced motion in Svelte](https://ghostdev.xyz/posts/working-with-reduced-motion-in-svelte) by GHOST
|
||||
@ -61,6 +64,7 @@ _To Read_
|
||||
_To Watch_
|
||||
|
||||
From Svelte Society:
|
||||
|
||||
- [The Svelte Summit Spring 2022 stream recording](https://www.youtube.com/watch?v=qqj2cBockqE) has been updated with chapter markers to make it easy to watch again and again
|
||||
- [The full recording of Svelte London, April 2022](https://www.youtube.com/watch?v=zIxzJzTnoxA) is up! Check out the amazing talks from across the Svelte London community
|
||||
- [Persian Svelte Society](https://www.youtube.com/channel/UCfWH9lCsXN3j8oXq8dru82Q) is making Persian-language videos about Svelte
|
||||
@ -70,8 +74,8 @@ From Svelte Society:
|
||||
- [Rendering your Svelte apps on Render](https://www.youtube.com/watch?v=SnV_hMLVyqs) on May 24
|
||||
- [The story behind the (unofficial) Svelte newsletter](https://www.youtube.com/watch?v=aK0xXm3hPxk&list=PL8bMgX1kyZThkJ_Rk6AAFI4eY24g5XKwK&index=7) on May 27
|
||||
|
||||
|
||||
Across the Web:
|
||||
|
||||
- [Building vite-plugin-svelte-inspector](https://www.youtube.com/watch?v=udYB24IMtsY), [What is Singleton?](https://www.youtube.com/watch?v=xhi0m1QZue0) and [What is Navigation?](https://www.youtube.com/watch?v=Ym-OnGUps2c) by lihautan
|
||||
- [Auto Import Components In Svelte Kit - Weekly Svelte](https://www.youtube.com/watch?v=JXvKBtTPr64) by LevelUpTuts
|
||||
- [🧪 Test SvelteKit with TDD & VITEST 🧪](https://www.youtube.com/watch?v=5bQD3dCoyHA) by Johnny Magrippis
|
||||
@ -80,6 +84,7 @@ Across the Web:
|
||||
- [SvelteKit Shiki Syntax Highlighting: Markdown Codeblocks](https://rodneylab.com/sveltekit-shiki-syntax-highlighting/) and [Svelte Capsize Styling: Typography Tooling](https://rodneylab.com/svelte-capsize-styling/) by Rodney Lab
|
||||
|
||||
_To Hear_
|
||||
|
||||
- Svelte Radio has been putting out weekly episodes:
|
||||
- [The Adventures of Running a Svelte Meetup](https://www.svelteradio.com/episodes/the-adventures-of-running-a-svelte-meetup)
|
||||
- [The other Rich! Geoff! (feat. Geoff Rich)](https://www.svelteradio.com/episodes/the-other-rich-geoff)
|
||||
@ -87,8 +92,8 @@ _To Hear_
|
||||
- [Stores Galore](https://www.svelteradio.com/episodes/stores-galore)
|
||||
- [Svelte and the Future of Frontend Development (feat. Rich Harris)](https://thenewstack.io/svelte-and-the-future-of-front-end-development/) from The New Stack
|
||||
|
||||
|
||||
**Libraries, Tools & Components**
|
||||
|
||||
- [vite-plugin-svelte-console-remover](https://github.com/jhubbardsf/vite-plugin-svelte-console-remover) is a Vite plugin that removes all console statements (log, group, dir, error, etc) from Svelte, JS, and TS files during build so they don't leak into production
|
||||
- [Svelte Headless Tables](https://github.com/bryanmylee/svelte-headless-table) is an unopinionated and extensible data tables for Svelte
|
||||
- [y-presence](https://github.com/nimeshnayaju/y-presence) is a lightweight set of libraries to easily add presence (live cursors/avatars) to any web application (now with Svelte support!)
|
||||
@ -105,7 +110,6 @@ There were lots of Svelte stores released this month from a number of authors...
|
||||
- [svelte-damped-store](https://github.com/aredridel/svelte-damped-store) is a derived writable store that can suspend updates while [svelte-lens-store](https://github.com/aredridel/svelte-lens-store) is a functional lens over Svelte stores
|
||||
- [svelte-persistent-store](https://github.com/furudean/svelte-persistent-store) is a writable svelte store that saves and loads data from `Window.localStorage` or `Window.sessionStorage`.
|
||||
|
||||
|
||||
Did we miss anything? Join us on [Reddit](https://www.reddit.com/r/sveltejs/) or [Discord](https://discord.com/invite/yy75DKs) to add your voice.
|
||||
|
||||
Don't forget that you can also join us in-person at the Svelte Summit in Stockholm! Come join us for two days of awesome Svelte content! [Get your tickets now](https://ti.to/svelte/svelte-summit-fall-edition).
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
title: "What's new in Svelte: July 2022"
|
||||
description: "Faster SSR, language tools improvements and a new paid contributor!"
|
||||
description: 'Faster SSR, language tools improvements and a new paid contributor!'
|
||||
author: Dani Sandoval
|
||||
authorURL: https://dreamindani.com
|
||||
---
|
||||
@ -16,13 +16,14 @@ Svelte supporters have donated approximately $80,000 to [the project on OpenColl
|
||||
We will also be utilizing OpenCollective funds to allow Svelte core maintainers to attend [Svelte Summit](https://www.sveltesummit.com/) in person this fall. Thanks to everyone who has donated so far!
|
||||
|
||||
## What's new in Svelte & Language Tools
|
||||
|
||||
- [learn.svelte.dev](https://learn.svelte.dev/) is a new way to learn Svelte and SvelteKit from the ground up that is currently in development
|
||||
- Faster SSR is coming in the next Svelte release. A PR two years in the making, resulting in up to 3x faster rendering in some benchmarking tests! ([PR](https://github.com/sveltejs/svelte/pull/5701))
|
||||
- "Find File References" ([0.14.28](https://github.com/sveltejs/language-tools/releases/tag/language-server-0.14.28)) and "Find Component References" ([0.14.29](https://github.com/sveltejs/language-tools/releases/tag/language-server-0.14.29)) in the latest versions of the Svelte extension shows where Svelte files and components have been imported and used ([Demo](https://twitter.com/dummdidumm_/status/1532459709604716544/photo/1))
|
||||
- The Svelte extension now supports CSS path completion ([0.14.29](https://github.com/sveltejs/language-tools/releases/tag/language-server-0.14.29))
|
||||
|
||||
|
||||
## What's new in SvelteKit
|
||||
|
||||
- Introduced `@sveltejs/kit/experimental/vite` which allows SvelteKit to interoperate with other tools in the Vite ecosystem like Vitest and Storybook ([#5094](https://github.com/sveltejs/kit/pull/5094)). Please [leave feedback](https://github.com/sveltejs/kit/issues/5184) as to whether the feature works and is helpful as we consider taking it out of experimental and making `vite.config.js` required for all users
|
||||
- Streaming in endpoints is now supported ([#3419](https://github.com/sveltejs/kit/issues/3419)). This was enabled by switching to the Undici `fetch` implementation ([#5117](https://github.com/sveltejs/kit/pull/5117))
|
||||
- Static assets can now be symlinked in development environments ([#5089](https://github.com/sveltejs/kit/pull/5089))
|
||||
@ -33,6 +34,7 @@ We will also be utilizing OpenCollective funds to allow Svelte core maintainers
|
||||
## Community Showcase
|
||||
|
||||
**Apps & Sites built with Svelte**
|
||||
|
||||
- [Virtual Maker](https://www.virtualmaker.net/) lets you make interactive 3D and VR scenes in your browser
|
||||
- [Apple Beta Music](https://www.reddit.com/r/sveltejs/comments/v7ic2s/apple_beta_music_uses_svelte/) appears to have been written in some combination of Svelte and web components
|
||||
- [Itatiaia](https://www.itatiaia.com.br/), the largest radio station in the country of Brazil just relaunched its news portal in SvelteKit
|
||||
@ -51,15 +53,16 @@ We will also be utilizing OpenCollective funds to allow Svelte core maintainers
|
||||
|
||||
Want to contribute to a site using the latest SvelteKit features? [Help build the Svelte Society site](https://github.com/svelte-society/sveltesociety.dev/issues)!
|
||||
|
||||
|
||||
**Learning Resources**
|
||||
|
||||
_Starring the Svelte team_
|
||||
|
||||
- [Svelte Origins: A JavaScript Documentary](https://www.youtube.com/watch?v=kMlkCYL9qo0) by OfferZen Origins
|
||||
- [Full Stack Documentation (announcing learn.svelte.dev)](https://portal.gitnation.org/contents/full-stack-documentation) by Rich Harris @ JSNation 2022
|
||||
- [All About the Sirens](https://www.svelteradio.com/episodes/all-about-the-sirens) by Svelte Radio
|
||||
|
||||
_To Watch_
|
||||
|
||||
- [SvelteKit Page Endpoints](https://www.youtube.com/watch?v=yQRf2wmTu5w), [Named Layouts](https://www.youtube.com/watch?v=UHX9TJ0BxZY) and [Passing data from page component to layout component with $page.stuff](https://www.youtube.com/watch?v=CXaCstU5pcw) by lihautan
|
||||
- [🍞 & 🧈: Magically load data with SvelteKit Endpoints](https://www.youtube.com/watch?v=f6prqYlbTE4) by Johnny Magrippis
|
||||
- [Svelte for React developers](https://www.youtube.com/watch?v=7tsrwrx5HtQ) by frontendtier
|
||||
@ -68,6 +71,7 @@ _To Watch_
|
||||
- [Svelte + websockets: Build a real-time Auction app](https://www.youtube.com/watch?v=CqgsWFrwQIU) by Evgeny Maksimov
|
||||
|
||||
_To Read_
|
||||
|
||||
- [Up-To-Date Analytics on a Static Website](https://paullj.github.io/posts/up-to-date-analytics-on-a-static-website) and [Fast, Lightweight Fuzzy Search using Fuse.js](https://paullj.github.io/posts/fast-lightweight-fuzzy-search-using-fuse.js) by paullj
|
||||
- [Use SvelteKit as a handler in the ExpressJs project](https://chientrm.medium.com/use-sveltekit-as-a-handler-in-the-expressjs-project-15524b01128f) by Tran Chien
|
||||
- [Creating a desktop application with Tauri and SvelteKit](https://github.com/Stijn-B/tauri-sveltekit-example) by Stijn-B
|
||||
@ -76,8 +80,8 @@ _To Read_
|
||||
- [SvelteKit Hooks. Everything You Need To Know](https://kudadam.com/blog/understanding-sveltekit-hooks) by Lucretius K. Biah
|
||||
- [3 tips for upgrading the performance of your Svelte stores](https://www.mathiaspicker.com/posts/3-tips-for-upgrading-the-performance-of-your-svelte-stores) by Mathias Picker
|
||||
|
||||
|
||||
**Libraries, Tools & Components**
|
||||
|
||||
- [Svend3r](https://github.com/oslabs-beta/svend3r) is a plug and play D3 charting library for Svelte
|
||||
- [Svelte Hover Draw SVG](https://github.com/davipon/svelte-hover-draw-svg) is a lightweight Svelte component to draw SVG on hover
|
||||
- [Svelte French Toast](https://svelte-french-toast.com/) provides buttery smooth toast notifications that are lightweight, customizable, and beautiful by default
|
||||
@ -90,7 +94,6 @@ _To Read_
|
||||
- [Svelte Component Snippets](https://marketplace.visualstudio.com/items?itemName=brysonbw.svelte-component-snippets) is a VS Code extension with access to common Svelte snippets
|
||||
- [Svelte Confetti](https://github.com/Mitcheljager/svelte-confetti) adds a little bit of flair to your app with some confetti 🎊
|
||||
|
||||
|
||||
What did we miss? Let us know on [Reddit](https://www.reddit.com/r/sveltejs/) or [Discord](https://discord.com/invite/yy75DKs) to add your voice.
|
||||
|
||||
Don't forget that you can also join us in-person at the Svelte Summit in Stockholm! Come join us for two days of awesome Svelte content! [Get your tickets now](https://www.sveltesummit.com/).
|
@ -12,6 +12,7 @@ Also, [@dummdidumm](https://github.com/dummdidumm) (Simon H) [has joined Vercel
|
||||
Now onto the rest of the updates...
|
||||
|
||||
## What's new in SvelteKit
|
||||
|
||||
- Dynamically imported styles are now included during SSR ([#5138](https://github.com/sveltejs/kit/pull/5138))
|
||||
- Improvements to routes and prop updates to prevent unnecessary rerendering ([#5654](https://github.com/sveltejs/kit/pull/5654), [#5671](https://github.com/sveltejs/kit/pull/5671))
|
||||
- Lots of improvements to error handling ([#4665](https://github.com/sveltejs/kit/pull/4665), [#5622](https://github.com/sveltejs/kit/pull/5622), [#5619](https://github.com/sveltejs/kit/pull/5619), [#5616](https://github.com/sveltejs/kit/pull/5616))
|
||||
@ -22,6 +23,7 @@ Now onto the rest of the updates...
|
||||
- `vite-plugin-svelte` has reached 1.0 and now supports Vite 3. You'll notice new default ports for `dev` (port 5173) and `preview` (port 4173) ([#5005](https://github.com/sveltejs/kit/pull/5005), [vite-plugin-svelte CHANGELOG](https://github.com/sveltejs/vite-plugin-svelte/blob/main/packages/vite-plugin-svelte/CHANGELOG.md))
|
||||
|
||||
**Breaking changes:**
|
||||
|
||||
- `mode`, `prod` and `server` are no longer available in `$app/env` ([#5602](https://github.com/sveltejs/kit/pull/5602))
|
||||
- `svelte-kit` CLI commands are now run using the `vite` command and `vite.config.js` is required. This will allow first-class support with other projects in the Vite ecosystem like Vitest and Storybook ([#5332](https://github.com/sveltejs/kit/pull/5332), [Docs](https://kit.svelte.dev/docs/project-structure#project-files-vite-config-js))
|
||||
- `endpointExtensions` is now `moduleExtensions` and can be used to filter param matchers ([#5085](https://github.com/sveltejs/kit/pull/5085), [Docs](https://kit.svelte.dev/docs/configuration#moduleextensions))
|
||||
@ -35,18 +37,18 @@ Now onto the rest of the updates...
|
||||
|
||||
For a full list of changes, check out kit's [CHANGELOG](https://github.com/sveltejs/kit/blob/master/packages/kit/CHANGELOG.md).
|
||||
|
||||
|
||||
## What's new in Svelte & Language Tools
|
||||
|
||||
- The `@layer` [CSS at-rule](https://developer.mozilla.org/en-US/docs/Web/CSS/@layer) is now supported in Svelte components (**3.49.0**, [PR](https://github.com/sveltejs/svelte/issues/7504))
|
||||
- The `inert` [HTML attribute](https://html.spec.whatwg.org/multipage/interaction.html#the-inert-attribute) is now supported in Svelte's language tools and plugins (**105.20.0**, [PR](https://github.com/sveltejs/language-tools/pull/1565))
|
||||
- The Svelte plugin will now use `SvelteComponentTyped` typings, if available (**105.19.0**, [PR](https://github.com/sveltejs/language-tools/pull/1548))
|
||||
|
||||
|
||||
---
|
||||
|
||||
## Community Showcase
|
||||
|
||||
**Apps & Sites built with Svelte**
|
||||
|
||||
- [PocketBase](https://github.com/pocketbase/pocketbase) is an open source Go backend with a single file and an admin dashboard built with Svelte
|
||||
- [Hondo](https://www.playhondo.com/how-to-play) is a word guessing game with multiple rounds
|
||||
- [Hexapipes](https://github.com/gereleth/hexapipes) is a site for playing hexagonal pipes puzzle
|
||||
@ -64,6 +66,7 @@ For a full list of changes, check out kit's [CHANGELOG](https://github.com/svelt
|
||||
**Learning Resources**
|
||||
|
||||
_Starring the Svelte team_
|
||||
|
||||
- [The Svelte Documentary is out!](https://www.svelteradio.com/episodes/the-svelte-documentary-is-out) on Svelte Radio
|
||||
- [Beginner SvelteKit](https://vercel.com/docs/beginner-sveltekit) by Vercel
|
||||
- [Challenge: Explore Svelte by Building a Bubble Popping Game](https://prismic.io/blog/try-svelte-build-game) by Brittney Postma
|
||||
@ -71,6 +74,7 @@ _Starring the Svelte team_
|
||||
- [Svelte Sirens July Talk - Testing in Svelte with Jess Sachs](https://sveltesirens.dev/event/testing-in-svelte)
|
||||
|
||||
_To Watch_
|
||||
|
||||
- [10 Awesome Svelte UI Component Libraries](https://www.youtube.com/watch?v=RkD88ARvucM) by LevelUpTuts
|
||||
- [Learn How SvelteKit Works](https://www.youtube.com/watch?v=VizuTy3uSNE) and [SvelteKit Endpoints](https://www.youtube.com/watch?v=XnVxDLTgCgo) by Joy of Code
|
||||
- [SvelteKit using TS, and Storybook setup](https://www.youtube.com/watch?v=L4F5dSu0FcQ) by Jarrod Kane
|
||||
@ -78,6 +82,7 @@ _To Watch_
|
||||
- [SvelteKit authentication, the better way - Tutorial](https://www.youtube.com/watch?v=Y98KipzwVdM) by Pilcrow
|
||||
|
||||
_To Read_
|
||||
|
||||
- [Some assorted Svelte demos](https://geoffrich.net/posts/assorted-svelte-demos/) by Geoff Rich
|
||||
- [Three ways to bootstrap a Svelte project](https://maier.tech/posts/three-ways-to-bootstrap-a-svelte-project) by Thilo Maier
|
||||
- [Design & build an app with Svelte](https://bootcamp.uxdesign.cc/design-build-an-app-with-svelte-ecd7ed0729da) by Hugo
|
||||
@ -90,16 +95,17 @@ _To Read_
|
||||
- [Transitional Apps with Phoenix and Svelte](https://nathancahill.com/phoenix-svelte) by Nathan Cahill
|
||||
|
||||
_Tech Demos_
|
||||
|
||||
- [Bringing the best GraphQL experience to Svelte](https://www.the-guild.dev/blog/houdini-and-kitql) by The Guild
|
||||
- [Style your Svelte website faster with Stylify CSS](https://stylifycss.com/blog/style-your-svelte-website-faster-with-stylify-css/) by Stylify
|
||||
- [Revamped Auth Helpers for Supabase (with SvelteKit support)](https://supabase.com/blog/2022/07/13/supabase-auth-helpers-with-sveltekit-support) by Supabase
|
||||
|
||||
|
||||
**Libraries, Tools & Components**
|
||||
|
||||
- [Lucia](https://github.com/pilcrowOnPaper/lucia-sveltekit) is a simple, JWT based authentication library for SvelteKit that connects your SvelteKit app with your database
|
||||
- [Skeleton](https://github.com/Brain-Bones/skeleton) is a UI component library for use with Svelte + Tailwind
|
||||
- [pass-composer](https://pass-composer.vercel.app/) helps you compose your postprocessing passes for threlte scenes
|
||||
- [@crikey/stores-*](https://whenderson.github.io/stores-mono/) is a collection of libraries to extend Svelte stores for common use-cases
|
||||
- [@crikey/stores-\*](https://whenderson.github.io/stores-mono/) is a collection of libraries to extend Svelte stores for common use-cases
|
||||
- [Svelte Chrome Storage](https://github.com/shaun-wild/svelte-chrome-storage) is a lightweight abstraction between Svelte stores and Chrome extension storage
|
||||
- [Svelte Schema Form](https://github.com/restspace/svelte-schema-form) is a form generator for JSON schema
|
||||
- [svelte-gesture](https://github.com/wobsoriano/svelte-gesture) is a library that lets you bind richer mouse and touch events to any component or view
|
@ -12,12 +12,14 @@ With the redesign of SvelteKit's filesystem-based router merging early last mont
|
||||
But the new routing isn't the only new feature in SvelteKit...
|
||||
|
||||
## What's new in SvelteKit
|
||||
|
||||
- `Link` is now supported as an HTTP header and works out of the box with Cloudflare's [Automatic Early Hints](https://github.com/sveltejs/kit/issues/5455) (**1.0.0-next.405**, [PR](https://github.com/sveltejs/kit/pull/5735))
|
||||
- `$env/static/*` are now virtual to prevent writing sensitive values to disk (**1.0.0-next.413**, [PR](https://github.com/sveltejs/kit/pull/5825))
|
||||
- `$app/stores` can now be used from anywhere on the browser (**1.0.0-next.428**, [PR](https://github.com/sveltejs/kit/pull/6100))
|
||||
- `config.kit.env.dir` is a new config that sets the directory to search for `.env` files (**1.0.0-next.430**, [PR](https://github.com/sveltejs/kit/pull/6175))
|
||||
|
||||
**Breaking changes:**
|
||||
|
||||
- The filesystem-based router and `load` API improves the way routes are managed. **Before installing version `@sveltejs/kit@1.0.0-next.406` or later, [follow this migration guide](https://github.com/sveltejs/kit/discussions/5774)** ([PR](https://github.com/sveltejs/kit/pull/5778), [Issue](https://github.com/sveltejs/kit/discussions/5748))
|
||||
- `event.session` has been removed from `load` along with the `session` store and `getSession`. Use `event.locals` instead (**1.0.0-next.415**, [PR](https://github.com/sveltejs/kit/pull/5946))
|
||||
- Named layouts have been removed in favor of `(groups)` (**1.0.0-next.432**, [Docs](https://kit.svelte.dev/docs/advanced-routing#advanced-layouts), [PR & Migration Instructions](https://github.com/sveltejs/kit/pull/6174))
|
||||
@ -27,14 +29,15 @@ But the new routing isn't the only new feature in SvelteKit...
|
||||
For a full list of changes, check out kit's [CHANGELOG](https://github.com/sveltejs/kit/blob/master/packages/kit/CHANGELOG.md).
|
||||
|
||||
**Updates to language tools**
|
||||
- TypeScript doesn't resolve imports to SvelteKit's $types very well, the latest version of Svelte's language tools makes it better (**105.21.0**, [#1592](https://github.com/sveltejs/language-tools/pull/1592))
|
||||
|
||||
- TypeScript doesn't resolve imports to SvelteKit's $types very well, the latest version of Svelte's language tools makes it better (**105.21.0**, [#1592](https://github.com/sveltejs/language-tools/pull/1592))
|
||||
|
||||
---
|
||||
|
||||
## Community Showcase
|
||||
|
||||
**Apps & Sites built with Svelte**
|
||||
|
||||
- [canno](https://twitter.com/a_warnes/status/1556724034959818754?s=20&t=RyKWALPByqMT5A_PkLtUew) is a simple interactive 3d physics game with adjustable gravity, cannon power, and debug visualizer - made with threlte
|
||||
- [straw.page](https://straw.page/) is an extremely simple website builder that lets you create unique websites straight from your phone
|
||||
- [Patra](https://patra.webjeda.com/) lets you share short notes just with a link. No database. No storage
|
||||
@ -49,6 +52,7 @@ For a full list of changes, check out kit's [CHANGELOG](https://github.com/svelt
|
||||
**Learning Resources**
|
||||
|
||||
_Starring the Svelte team_
|
||||
|
||||
- [Supper Club × Rich Harris, Author of Svelte — Syntax Podcast 499](https://syntax.fm/show/499/supper-club-rich-harris-author-of-svelte)
|
||||
- [Let's talk routing with Rich Harris on Svelte Radio](https://www.svelteradio.com/episodes/lets-talk-routing-with-rich-harris)
|
||||
- [2.17 - Building the Future of Svelte at Vercel with Rich Harris](https://www.youtube.com/watch?v=F1sSUDVoij4)
|
||||
@ -60,23 +64,25 @@ _Starring the Svelte team_
|
||||
- [Svelte London August Recording](https://www.youtube.com/watch?v=ua6gE2zPulw)
|
||||
|
||||
_Learning the new SvelteKit routing_
|
||||
|
||||
- [Migrating Breaking Changes in SvelteKit](https://www.netlify.com/blog/migrating-breaking-changes-in-sveltekit/) by Brittney Postma (Netlify)
|
||||
- [Major Svelte Kit API Change - Fixing `load`, and tightening up SvelteKit's design before 1.0](https://www.youtube.com/watch?v=OUGn7VifUCg) - Video by LevelUpTuts
|
||||
- [SvelteKit Is Never Going To Be The Same](https://www.youtube.com/watch?v=eVFcGA-15LA) - Video by Joy of Code
|
||||
- [Let's learn SvelteKit by building a static Markdown blog from scratch](https://joshcollinsworth.com/blog/build-static-sveltekit-markdown-blog) by Josh Collinsworth (updated Aug 26th to keep up with the new changes)
|
||||
|
||||
_To Watch_
|
||||
|
||||
- [Svelte Guide For React Developers](https://www.youtube.com/watch?v=uWDBEUkTRGk) and [Svelte State Management Guide](https://www.youtube.com/watch?v=4dDjQiOVrOo) by Joy of Code
|
||||
- [What Is Bookit? The Svelte Kit Storybook Killer](https://www.youtube.com/watch?v=aOBGhvggsq0) and [What Is @type{import In Svelte Kit - JSDoc Syntax](https://www.youtube.com/watch?v=y0DvJTVO65M) by LevelUpTuts
|
||||
- [TWF Yet another JS Framework... or not? Svelte!](https://www.youtube.com/watch?app=desktop&v=nT8QtDBIKZA) by TWF meetup
|
||||
|
||||
|
||||
_To Read_
|
||||
|
||||
- [Creating a Figma Plugin with Svelte](https://www.lekoarts.de/javascript/creating-a-figma-plugin-with-svelte) by Lennart
|
||||
- [Svelte Video Blog: Vlog with Mux from your own SvelteKit Site](https://plus.rodneylab.com/tutorials/svelte-video-blog) and [Svelte Shy Header: Peekaboo Sticky Header with CSS](https://rodneylab.com/svelte-shy-header/) by Rodney Lab
|
||||
|
||||
|
||||
**Libraries, Tools & Components**
|
||||
|
||||
- [@svelte-plugins/tooltips](https://github.com/svelte-plugins/tooltips) is a simple tooltip action and component designed for Svelte
|
||||
- [Lucia](https://github.com/pilcrowOnPaper/lucia-sveltekit) is a simple authentication library for SvelteKit that connects your SvelteKit app to your database
|
||||
- [remix-router-svelte](https://github.com/brophdawg11/remix-routers/tree/main/packages/svelte) is a Svelte implementation of the `react-router-dom` API (driven by `@remix-run/router`)
|
||||
@ -91,11 +97,12 @@ _To Read_
|
||||
- [vite-plugin-svelte-bridge](https://github.com/joshnuss/vite-plugin-svelte-bridge) lets you write Svelte components and use them from React & Vue
|
||||
|
||||
_UI Kits and Starters_
|
||||
|
||||
- [Svelte-spectre](https://github.com/basf/svelte-spectre) is a UI-kit based on spectre.css and powered by Svelte
|
||||
- [Skeleton](https://skeleton.brainandbonesllc.com/) allows you to build fast and reactive web UI using the power of Svelte + Tailwind
|
||||
- [iconsax-svelte](https://www.npmjs.com/package/iconsax-svelte) brings the popular icon kit to Svelte
|
||||
- [laravel-vite-svelte-spa-template](https://github.com/NukeJS/laravel-vite-svelte-spa-template) is a Laravel 9, Vite, Svelte SPA, Tailwind CSS (w/ Forms Plugin & Aspect Ratio Plugin), Axios, & TypeScript starter template
|
||||
- [neutralino-svelte-boilerplate-js](https://github.com/Raffaele/neutralino-svelte-boilerplate-js) is a cross platform desktop template for Neutralino and Svelte
|
||||
- [neutralino-svelte-boilerplate-js](https://github.com/Raffaele/neutralino-svelte-boilerplate-js) is a cross platform desktop template for Neutralino and Svelte
|
||||
- [figma-plugin-svelte-vite](https://github.com/candidosales/figma-plugin-svelte-vite) is a boilerplate for creating Figma plugins using Svelte, Vite and Typescript
|
||||
- [Urara](https://github.com/importantimport/urara) is a sweet & powerful SvelteKit blog starter
|
||||
- [SvelteKit Commerce](https://vercel.com/templates/svelte/sveltekit-commerce) is an all-in-one starter kit for high-performance e-commerce sites built with SvelteKit by Vercel
|
@ -1,17 +1,18 @@
|
||||
---
|
||||
title: "What's new in Svelte: October 2022"
|
||||
description: "Svelte Summit, `use:enhance`, and a SvelteKit Release Candidate!"
|
||||
description: 'Svelte Summit, `use:enhance`, and a SvelteKit Release Candidate!'
|
||||
author: Dani Sandoval
|
||||
authorURL: https://dreamindani.com
|
||||
---
|
||||
|
||||
There's a bunch of updates this month... from new features in Svelte and SvelteKit to a whole 2-day *summit*! Plus, the Svelte extension gets some helpful new tools, new accessibility (a11y) warnings, and Tan Li Hau teaches us how to build our own Svelte and a Svelte spreadsheet 😎
|
||||
There's a bunch of updates this month... from new features in Svelte and SvelteKit to a whole 2-day _summit_! Plus, the Svelte extension gets some helpful new tools, new accessibility (a11y) warnings, and Tan Li Hau teaches us how to build our own Svelte and a Svelte spreadsheet 😎
|
||||
|
||||
## What happened at Svelte Summit?
|
||||
|
||||
A lot! Below you can find all the talks, by timestamp, from each livestream. Bite-size videos of the event will be coming soon to the Svelte Society channel, so be sure to [Subscribe](https://www.youtube.com/c/SvelteSociety), if you haven't already!
|
||||
|
||||
_Day One_
|
||||
|
||||
- [12:31](https://www.youtube.com/watch?v=pJcbZr5VlV4&t=751s) - How to get Svelte adopted at work
|
||||
- [33:21](https://www.youtube.com/watch?v=pJcbZr5VlV4&t=2001s) - Animating Data Visualization in Svelte
|
||||
- [2:20:36](https://www.youtube.com/watch?v=pJcbZr5VlV4&t=8436s) - Red flags & code smells
|
||||
@ -24,6 +25,7 @@ _Day One_
|
||||
- [8:20:49](https://www.youtube.com/watch?v=pJcbZr5VlV4&t=30049s) - Building the future, faster
|
||||
|
||||
_Day Two_
|
||||
|
||||
- [24:09](https://www.youtube.com/watch?v=A8jkJTWacow&t=1449s) - Scrollytell me why: Ain't nothing but a piece of cake
|
||||
- [2:02:40](https://www.youtube.com/watch?v=A8jkJTWacow&t=7360s) - I told you my dog wouldn’t run
|
||||
- [2:29:43](https://www.youtube.com/watch?v=A8jkJTWacow&t=8983s) - 10Xing Svelte
|
||||
@ -31,17 +33,19 @@ _Day Two_
|
||||
- [5:09:39](https://www.youtube.com/watch?v=A8jkJTWacow&t=18579s) - Having fun with stores: an interactive demo of Svelte’s built in state management library
|
||||
- [5:37:06](https://www.youtube.com/watch?v=A8jkJTWacow&t=20226s) - When Keeping it Svelte Goes Wrong. An Analysis of Some of the Worst Svelte I Have Ever Coded
|
||||
- [7:22:05](https://www.youtube.com/watch?v=A8jkJTWacow&t=26525s) - Getting started with Hooks
|
||||
- [7:38:14](https://www.youtube.com/watch?v=A8jkJTWacow&t=27494s) - Special Announcement*
|
||||
- [7:38:14](https://www.youtube.com/watch?v=A8jkJTWacow&t=27494s) - Special Announcement\*
|
||||
|
||||
*In the final talk of the summit, Rich Harris announces the first Release Candidate of SvelteKit! With no planned breaking changes left, the team is hard at work squashing bugs and adding the remaining features for 1.0...
|
||||
\*In the final talk of the summit, Rich Harris announces the first Release Candidate of SvelteKit! With no planned breaking changes left, the team is hard at work squashing bugs and adding the remaining features for 1.0...
|
||||
|
||||
## More SvelteKit Updates
|
||||
|
||||
- `use:enhance` is the easiest way to progressively enhance a form ([Docs](https://kit.svelte.dev/docs/form-actions#progressive-enhancement-use-enhance), [#6633](https://github.com/sveltejs/kit/pull/6633), [#6828](https://github.com/sveltejs/kit/pull/6828), [#7012](https://github.com/sveltejs/kit/pull/7012))
|
||||
- The demo app has been updated to add the Sverdle game, which Rich demoed at Svelte Summit and demonstrates `use:enhance` ([#6979](https://github.com/sveltejs/kit/pull/6979))
|
||||
- Cloudflare Pages `_routes.json` specification is now supported by `adapter-cloudflare` ([#6530](https://github.com/sveltejs/kit/pull/6530))
|
||||
- Improved build performance by running asset and page compression in parallel ([#6710](https://github.com/sveltejs/kit/pull/6710))
|
||||
|
||||
**Breaking changes:**
|
||||
|
||||
- Node 16.14 is now the minimum version to run SvelteKit ([#6388](https://github.com/sveltejs/kit/pull/6388))
|
||||
- `App.PrivateEnv` and `App.PublicEnv` have been removed in favour of generated types ([#6413](https://github.com/sveltejs/kit/pull/6413))
|
||||
- `%sveltekit.message%` has been replaced with `%sveltekit.error.message%` ([6659](https://github.com/sveltejs/kit/pull/6659))
|
||||
@ -51,6 +55,7 @@ _Day Two_
|
||||
For a full list of changes, check out SvelteKit's [CHANGELOG](https://github.com/sveltejs/kit/blob/master/packages/kit/CHANGELOG.md).
|
||||
|
||||
## Svelte Updates
|
||||
|
||||
- New a11y warnings for `incorrect-aria-attribute-type`, `no-abstract-role`, `interactive-element-to-noninteractive-role` and `role-has-required-aria-props`.`no-noninteractive-tabindex` and `click-events-have-key-events` coming soon! (**3.50.0**)
|
||||
- New types for `ComponentEvents` and `SveltePreprocessor` (**3.50.0**)
|
||||
- Improved parsing speed when encountering large blocks of whitespace (**3.50.0**)
|
||||
@ -59,6 +64,7 @@ For a full list of changes, check out SvelteKit's [CHANGELOG](https://github.com
|
||||
For all the changes to the Svelte compiler, including upcoming changes, check out the [CHANGELOG](https://github.com/sveltejs/svelte/blob/master/CHANGELOG.md).
|
||||
|
||||
## New in Language Tools
|
||||
|
||||
- Better code formatting for editor suggestion (**106.0.0**, [#1598](https://github.com/sveltejs/language-tools/pull/1598))
|
||||
- Easily create SvelteKit route files from the context menu or command palette (**106.1.0**, [#1620](https://github.com/sveltejs/language-tools/pull/1620))
|
||||
|
||||
@ -75,6 +81,7 @@ It can be used for anything you may be trying to accomplish using Svelte includi
|
||||
## Community Showcase
|
||||
|
||||
**Apps & Sites built with Svelte**
|
||||
|
||||
- [Timeflow](https://www.timeflow.site/) is a smart calendar & task manager that dynamically schedules your tasks between your events
|
||||
- [GeoQuest](https://github.com/woutdp/geoquest) is an open source geography game
|
||||
- [Houses Of](https://housesof.world/) is a project showcasing charismatic houses around the world
|
||||
@ -84,25 +91,27 @@ It can be used for anything you may be trying to accomplish using Svelte includi
|
||||
- [RoomOS Device Widgets](https://github.com/wxsd-sales/roomos-device-widgets) is an app for demoing RoomOS device capabilities in Kiosk/PWA mode
|
||||
- [World Seed](https://store.steampowered.com/app/1870320/World_Seed/) is a full blown online multiplayer game
|
||||
- [Lirify](https://lirify-tan.vercel.app/) is a song lyrics writing web app tool made in Latvia
|
||||
- [Splet Tech Konferencija](https://www.splet.rs/) is a tech conference in Serbia with a *very* fancy website
|
||||
- [Splet Tech Konferencija](https://www.splet.rs/) is a tech conference in Serbia with a _very_ fancy website
|
||||
- [Unbounded](https://unbounded.polkadot.network/) is an open-source variable font - funded by blockchain (and an awesome-looking website)
|
||||
- [Porter's Paints](https://shop.porterspaints.com/) is an eCommerce site for (you guessed it) paints built with Svelte
|
||||
- [CRAN/E](https://www.cran-e.com/) is a search engine for modern R-packages
|
||||
|
||||
- [CRAN/E](https://www.cran-e.com/) is a search engine for modern R-packages
|
||||
|
||||
**Learning Resources**
|
||||
|
||||
_Starring the Svelte team_
|
||||
|
||||
- [Upgrading SvelteKit](https://www.youtube.com/watch?v=vzeZskhjoeQ) by Svelte Sirens (with Brittney, Kev, and GHOST!)
|
||||
- [Build your own Svelte](https://www.youtube.com/watch?v=mwvyKGw2CzU) by lihautan
|
||||
- [Native Page Transitions in SvelteKit: Part 1](https://geoffrich.net/posts/page-transitions-1/) by Geoff Rich
|
||||
- [Build a cross platform app with Tauri](https://ghostdev.xyz/posts/build-a-cross-platform-app-with-tauri/) by GHOST
|
||||
|
||||
_To Watch_
|
||||
|
||||
- [How To Use Future CSS In Svelte](https://www.youtube.com/watch?v=eqwtoaP-0pk) and [Master Animation With Svelte](https://www.youtube.com/watch?v=3RlBfUQCiAQ) by Joy of Code
|
||||
- [Svelte Kit Form Actions 101 - New Svelte Kit API](https://www.youtube.com/watch?v=i5zdnv83mxY) and [Svelte Kit Form Actions - Real World Examples - Q&A](https://www.youtube.com/watch?v=PK2Mpt1q6K8) by LevelUpTuts
|
||||
|
||||
_To Read_
|
||||
|
||||
- [What's new in `svelte-kit, 1.0.0-next.445`: (group) layout](https://dev.to/parables/whats-new-in-svelte-kit-100-next445-group-layout-1ld5) by Parables
|
||||
- [Handling breaking changes in SvelteKit pre-1.0](https://maier.tech/posts/handling-breaking-changes-in-sveltekit-pre-1-0) by Thilo Maier
|
||||
- [Svelte Custom Stores Demystified](https://raqueebuddinaziz.com/blog/svelte-custom-stores-demystified/) by Raqueebuddin Aziz
|
||||
@ -113,8 +122,8 @@ _To Read_
|
||||
- [Deploying SvelteKit with NodeJS to a Server Using GitLab and PM2](https://abyteofcoding.com/blog/deploying-sveltekit-with-nodejs-pm2-to-server/) by A Byte of Coding
|
||||
- [Quality of Life Tips when using SvelteKit in VS Code](https://www.reddit.com/r/sveltejs/comments/xltgyp/quality_of_life_tips_when_using_sveltekit_in_vs/) by doa-doa
|
||||
|
||||
|
||||
**Libraries, Tools & Components**
|
||||
|
||||
- [Svelte Fit](https://github.com/leveluptuts/svelte-fit) is an extremely simple, no dependency fit text library
|
||||
- [svelte-switch-case](https://github.com/l-portet/svelte-switch-case) is a switch case syntax for your Svelte components
|
||||
- [svelte-canvas-confetti](https://github.com/andreasmcdermott/svelte-canvas-confetti) uses a single canvas to render full-screen confetti
|
||||
@ -126,9 +135,10 @@ _To Read_
|
||||
- [whyframe](https://whyframe.dev/) gives iframes superpowers, making it easy to render anything in isolation
|
||||
- [@svelte-put/modal](https://github.com/vnphanquang/svelte-put/tree/main/packages/misc/modal) is a solution to async, declarative, type-safe modals in Svelte
|
||||
- [Kitty](https://github.com/grottopress/kitty) is a collection of libraries and handlers for developing secure frontend apps
|
||||
- [svelte-turnstile](https://github.com/ghostdevv/svelte-turnstile) is a component for Cloudflare Turnstile, the privacy focused CAPTCHA replacement
|
||||
- [svelte-turnstile](https://github.com/ghostdevv/svelte-turnstile) is a component for Cloudflare Turnstile, the privacy focused CAPTCHA replacement
|
||||
|
||||
_UI Kits and Starters_
|
||||
|
||||
- [QWER](https://github.com/kwchang0831/svelte-QWER) is a blog starter built with SvelteKit
|
||||
- [SvelteKit Zero API](https://github.com/Refzlund/sveltekit-zero-api) provides type-safety between the frontend and backend - creating a structure for easy APIs
|
||||
- [sveltekit-monorepo](https://github.com/sw-yx/sveltekit-monorepo) is monorepo starter with 2022 tech
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
title: "What's new in Svelte: November 2022"
|
||||
description: "Better forms, routes and inline styles across SvelteKit and Svelte"
|
||||
description: 'Better forms, routes and inline styles across SvelteKit and Svelte'
|
||||
author: Dani Sandoval
|
||||
authorURL: https://dreamindani.com
|
||||
---
|
||||
@ -10,17 +10,20 @@ It's been a busy October for the Svelte community. `use:enhance` and Advanced Ro
|
||||
There's also a _huge_ showcase to cover... so let's jump in!
|
||||
|
||||
## What's new in SvelteKit
|
||||
|
||||
- The new `update` method for `use:enhance` lets you easily get back the default form behavior while augmenting it with your own logic ([docs](https://kit.svelte.dev/docs/form-actions#progressive-enhancement-use-enhance), [#7083](https://github.com/sveltejs/kit/pull/7083) and [#7326](https://github.com/sveltejs/kit/pull/7326))
|
||||
- `[[optional]]` parameters are now available for routing ([docs](https://kit.svelte.dev/docs/advanced-routing#optional-parameters), [#7051](https://github.com/sveltejs/kit/pull/7051))
|
||||
- `goto` now has `invalidateAll` to (re-)run all `load` functions belonging to the new active page ([docs](https://kit.svelte.dev/docs/modules#$app-navigation-goto), [#7407](https://github.com/sveltejs/kit/pull/7407))
|
||||
- `config.kit.paths.base` is now used in adapters looking for static assets - fixing 404 issues across `adapter-netlify`, `adapter-vercel`, `adapter-cloudflare`, and `adapter-cloudflare-workers` ([#4448](https://github.com/sveltejs/kit/pull/4448))
|
||||
|
||||
**Breaking changes:**
|
||||
|
||||
- Errors will now be thrown when routes conflict ([#7051](https://github.com/sveltejs/kit/pull/7051))
|
||||
- The global `fetch` override has been removed when prerendering ([#7318](https://github.com/sveltejs/kit/pull/7318))
|
||||
- Route IDs have been prefixed with `/` ([#7338](https://github.com/sveltejs/kit/pull/7338))
|
||||
|
||||
## Svelte changes
|
||||
|
||||
- New accessibility warnings, `a11y-click-events-have-key-events` and `a11y-no-noninteractive-tabindex`, will now warn when your components lack required key events or tabindex. While `a11y-role-has-required-aria-props` will no longer warn when elements match their semantic role (**3.51.0**)
|
||||
- `--style-props` are now supported on `<svelte:component>` and `<svg>` (**3.51.0**, Component Example: [Before](https://svelte.dev/repl/48984f20503f4959b70f24f4130d164b?version=3.47.0) and [After](https://svelte.dev/repl/48984f20503f4959b70f24f4130d164b?version=3.51.0), SVG Example: [Before](https://svelte.dev/repl/b7a3f94255914044b35462234ccaea43?version=3.50.0) and [After](https://svelte.dev/repl/b7a3f94255914044b35462234ccaea43?version=3.51.0))
|
||||
- "nullish" values for component event handlers are now supported (**3.51.0**, [Example](https://svelte.dev/repl/9228022922af4c76af68ce42349ccbf9?version=3.51.0))
|
||||
@ -35,6 +38,7 @@ Tom Smykowski also released a great summary of [all the changes in 3.52.0](https
|
||||
## Community Showcase
|
||||
|
||||
**Apps & Sites built with Svelte**
|
||||
|
||||
- [AttendZen](https://www.attendzen.io/) is an event management and marketing platform for in-person, virtual or hybrid events
|
||||
- [Gram Jam](https://gramjam.app/) is a challenging daily word game using SvelteKit
|
||||
- [Collabwriting](https://collabwriting.com/) is an actionable knowledge base for your team
|
||||
@ -52,10 +56,10 @@ Tom Smykowski also released a great summary of [all the changes in 3.52.0](https
|
||||
- [splits](https://splits.best/) lets you track your splits, calculate your race pace, become a better athlete
|
||||
- [Weaver](https://jrende.xyz/weaver/) is an application for creating [weave drafts](https://www.gistyarn.com/blogs/how-to-weave/how-to-read-a-weaving-draft)
|
||||
|
||||
|
||||
**Learning Resources**
|
||||
|
||||
_To Watch_
|
||||
|
||||
- [Starting With Svelte - Brittney Postma](https://www.youtube.com/watch?v=pdKJzrPA0DY) by fitcevents
|
||||
- [Learn Svelte from scratch with Geoff Rich: A Svelte tutorial](https://www.youtube.com/watch?v=QoR0AZ-Rov8) by Kelvin Omereshone
|
||||
- [How To Connect to MongoDB in Svelte Kit](https://www.youtube.com/watch?v=gwktlvFHLMA) by LevelUpTuts
|
||||
@ -64,6 +68,7 @@ _To Watch_
|
||||
- [Sybil - Episode 1 - Rust knowledge management with SurrealDB](https://www.youtube.com/watch?v=eC7IePI5rIk) by Raphael Darley
|
||||
|
||||
_To Read_
|
||||
|
||||
- [4 things I miss from Svelte after working in React](https://geoffrich.net/posts/4-things-i-miss-svelte/) and [Create dynamic social card images with Svelte components](https://geoffrich.net/posts/svelte-social-image/) by Geoff Rich
|
||||
- [First-class Vite support in Storybook 7.0](https://storybook.js.org/blog/first-class-vite-support-in-storybook/) (Svelte and SvelteKit included) by Ian VanSchooten
|
||||
- [Better Svelte support is coming to WebStorm](https://blog.jetbrains.com/webstorm/2022/09/webstorm-2022-3-eap1/#information_regarding_svelte_support) from JetBrains
|
||||
@ -76,9 +81,8 @@ _To Read_
|
||||
- [Creating a Svelte Tabs component with Slot props](https://blog.openreplay.com/creating-a-svelte-tabs-component-with-slot-props/) by Shinichi Okada
|
||||
- [Sky Cart: An Open Source, cloud-agnostic shopping cart using Stripe Checkout](https://dev.to/stripe/sky-cart-an-open-source-cloud-agnostic-shopping-cart-using-stripe-checkout-o5k) by Mike Bifulco for Stripe
|
||||
|
||||
|
||||
|
||||
**Libraries, Tools & Components**
|
||||
|
||||
- [Threlte](https://threlte.xyz/) is a component library for Svelte to build and render three.js scenes declaratively and state-driven in Svelte apps. It's being featured again to highlight the new "Playground" button in its examples
|
||||
- [Svelte Turnstile](https://github.com/ghostdevv/svelte-turnstile) is a library to integrate Cloudflare's Turnstile (a new CAPTCHA alternative) into a Svelte app
|
||||
- [ActionStore](https://github.com/buhrmi/actionstore) allows you to push data directly into Svelte stores via ActionCable
|
||||
@ -96,6 +100,7 @@ _To Read_
|
||||
- [svelte-copy](https://github.com/ghostdevv/svelte-copy)'s new version lets you customize the events that cause text to be copied to the clipboard
|
||||
|
||||
_UI Kits, Integrations and Starters_
|
||||
|
||||
- [SvelteKit Statiko](https://github.com/ivodolenc/sveltekit-statiko) is a multi-featured assistant for SvelteKit static projects
|
||||
- [Svelte-TailwindCSS UI (STWUI)](https://github.com/N00nDay/stwui) is a Tailwind-based UI that is currently in pre-release beta
|
||||
- [KitBase](https://github.com/kevmodrome/kitbase) is a starter template for SvelteKit and PocketBase
|
||||
@ -107,6 +112,7 @@ _UI Kits, Integrations and Starters_
|
||||
- [hooks-as-store](https://github.com/micha-lmxt/hooks-as-store) lets you use React custom hooks in Svelte Apps
|
||||
|
||||
_Fun ones_
|
||||
|
||||
- [svelte-typewriter-store](https://github.com/paoloricciuti/svelte-typewriter-store) is the simplest way to get a rotating typewriter effect in Svelte
|
||||
- [Aksel](https://www.npmjs.com/package/aksel) is the seagull you needed on your site
|
||||
- [Svelte-Dodge](https://github.com/WbaN314/svelte-dodge) makes components dodge the pointer
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
title: "What's new in Svelte: December 2022"
|
||||
description: "Rounding the corner to SvelteKit 1.0"
|
||||
description: 'Rounding the corner to SvelteKit 1.0'
|
||||
author: Dani Sandoval
|
||||
authorURL: https://dreamindani.com
|
||||
---
|
||||
@ -10,6 +10,7 @@ SvelteKit 1.0 is just around the corner! With [99% of the milestone issues compl
|
||||
Let's get to it!
|
||||
|
||||
## What's new in SvelteKit
|
||||
|
||||
- Use the `willUnload` property to find out if the navigation will result the app being unloaded (full page reload/closing/leaving to another page). ([#6813](https://github.com/sveltejs/kit/pull/6813))
|
||||
- `__data.json` requests now allows for caching while ensuring we cache matching responses for all invalidation scenarios ([#7532](https://github.com/sveltejs/kit/pull/7532))
|
||||
- Linking to `<a name="hash">` tags is now supported ([#7596](https://github.com/sveltejs/kit/pull/7596))
|
||||
@ -19,8 +20,8 @@ Let's get to it!
|
||||
- `version` is now available via `$app/environment` ([#7689](https://github.com/sveltejs/kit/pull/7689), [#7694](https://github.com/sveltejs/kit/pull/7694))
|
||||
- `handleError` can now return a promise ([#7780](https://github.com/sveltejs/kit/pull/7780))
|
||||
|
||||
|
||||
**Breaking changes:**
|
||||
|
||||
- `routeId` is now `route.id` ([#7450](https://github.com/sveltejs/kit/pull/7450))
|
||||
- 'load' has been renamed to 'enter' and 'unload' to 'leave' in the `beforeNavigate` and `afterNavigate` methods. `beforeNavigate` is now called once with type 'unload' on external navigation and will no longer run during redirects ([#7502](https://github.com/sveltejs/kit/pull/7502), [#7529](https://github.com/sveltejs/kit/pull/7529), [#7588](https://github.com/sveltejs/kit/pull/7588))
|
||||
- The `redirect` helper will now only allow status codes between 300-308 for redirects and only `error` status codes between 400-599 are allowed ([#7767](https://github.com/sveltejs/kit/pull/7767)) ([#7615](https://github.com/sveltejs/kit/pull/7615), [#7767](https://github.com/sveltejs/kit/pull/7767))
|
||||
@ -35,6 +36,7 @@ Let's get to it!
|
||||
- `SubmitFunction` has been moved from `$app/forms` into `@sveltejs/kit` ([#7003](https://github.com/sveltejs/kit/pull/7003))
|
||||
|
||||
## New in Svelte
|
||||
|
||||
- The css compiler options of `css: false` and `css: true` have been replaced with `'external' | 'injected' | 'none'` settings to speed up compilation for `ssr` builds and improve clarity (**3.53.0**)
|
||||
|
||||
For all the changes to the Svelte compiler, including unreleased changes, check out the [CHANGELOG](https://github.com/sveltejs/svelte/blob/master/CHANGELOG.md).
|
||||
@ -44,6 +46,7 @@ For all the changes to the Svelte compiler, including unreleased changes, check
|
||||
## Community Showcase
|
||||
|
||||
**Apps & Sites built with Svelte**
|
||||
|
||||
- [Appwrite's new console](https://github.com/appwrite/console) makes its secure backend server for web, mobile & Flutter developers avaiable in the browser
|
||||
- [RepoMagic](https://www.repomagic.com/) is a search and analytics tool for GitHub
|
||||
- [Podman Desktop](https://github.com/containers/podman-desktop) is a graphical tool for developing on containers and Kubernetes
|
||||
@ -54,34 +57,35 @@ For all the changes to the Svelte compiler, including unreleased changes, check
|
||||
- [Let's premortem](https://letspremortem.com/) helps avoid lengthy, frustrating post-mortems after a project fails
|
||||
- [BLKMARKET.COM](https://beta.blkmarket.com/) is an illustration library for commercial and personal use
|
||||
- [Sigil](https://sigilspace.com/) is a canvas for anything with spaces organized by the most-voted content
|
||||
- [corpus-activity-streams](https://github.com/ryanatkn/corpus-activity-streams) is an unofficial ActivityStreams 2.0 vocabulary data set and alternative docs
|
||||
- [corpus-activity-streams](https://github.com/ryanatkn/corpus-activity-streams) is an unofficial ActivityStreams 2.0 vocabulary data set and alternative docs
|
||||
- [nodeMyAdmin](https://github.com/Andrea055/nodeMyAdmin) is an alternative to phpMyAdmin written with SvelteKit
|
||||
- [Image to Pattern Conversion](https://www.thread-bare.com/convert) is a cross-stitch pattern conversion tool with [a list of pre-made patterns](https://www.thread-bare.com/store) to start with
|
||||
- [Verbums](https://verbums.vdoc.dev/) is an English vocabulary trainer to improve language comprehension
|
||||
- [SVGPS](https://svgps.app/) removes the burden of working with a cluster of SVG files by converting your icons into a single JSON file
|
||||
- [This 3D retro-themed asteroid shooter](https://photon-alexwarnes.vercel.app/showcase/asteroids) was made with threlte
|
||||
|
||||
|
||||
**Learning Resources**
|
||||
|
||||
_To Hear_
|
||||
|
||||
- [Catching up after Svelte Summit](https://www.svelteradio.com/episodes/catching-up) and [3D, WebGL and AI](https://www.svelteradio.com/episodes/3d-webgl-and-ai) by Svelte Radio
|
||||
|
||||
_To Watch_
|
||||
|
||||
- [Domenik Reitzner - The easy way, an introduction to Sveltekit](https://www.youtube.com/watch?v=t-LKRrNedps) from Svelte Society Vienna
|
||||
- [Sirens: Form Actions](https://www.youtube.com/watch?v=2OISk5-EHek) - Kev joins the Sirens again to chat about Form actions in SvelteKit and create a new form for speaker submissions on SvelteSirens.dev
|
||||
- [Introduction To 3D With Svelte (Threlte)](https://www.youtube.com/watch?v=89LYeHOncVk), [How To Use Global Styles In SvelteKit](https://www.youtube.com/watch?v=jHSwChkx3TQ) and [Progressive Form Enhancement With SvelteKit](https://www.youtube.com/watch?v=6pv70d7i-3Q) by Joy of Code
|
||||
|
||||
_To Read_
|
||||
|
||||
- [Building tic-tac-toe with Svelte](https://geoffrich.net/posts/tic-tac-toe/) by Geoff Rich
|
||||
- [Speed up SvelteKit Pages With a Redis Cache](https://www.captaincodeman.com/speed-up-sveltekit-pages-with-a-redis-cache) by Captain Codeman
|
||||
- [Understanding environment variables in SvelteKit](https://www.okupter.com/blog/environment-variables-in-sveltekit), [Form validation with SvelteKit and Zod](https://www.okupter.com/blog/sveltekit-form-validation-with-zod) and [Build a SvelteKit application with Docker](https://www.okupter.com/blog/build-a-sveltekit-application-with-docker) by Justin Ahinon
|
||||
- [Why I failed to create the "Solid.js's store" for Svelte, and announcing svelte-store-tree v0.3.1](https://dev.to/igrep/why-i-failed-to-create-the-solidjss-store-for-svelte-and-announcing-svelte-store-tree-v031-1am2) by YAMAMOTO Yuji
|
||||
- [Create an offline-first and installable PWA with SvelteKit and workbox-precaching](https://www.sarcevic.dev/offline-first-installable-pwa-sveltekit-workbox-precaching) by Antonio Sarcevic
|
||||
|
||||
|
||||
|
||||
**Libraries, Tools & Components**
|
||||
|
||||
- [Skeleton](https://www.skeleton.dev/) is a UI toolkit to build fast and reactive web interfaces using Svelte + Tailwind CSS
|
||||
- [svelte-svg-spinners](https://github.com/luluvia/svelte-svg-spinners) is a collection of SVG Spinners components
|
||||
- [Svelte Floating UI](https://github.com/fedorovvvv/svelte-floating-ui) enables floating UIs with actions - no wrapper components or component bindings required
|
||||
@ -96,7 +100,6 @@ _To Read_
|
||||
- [svelte-lazyimage-cache](https://github.com/binsarjr/svelte-lazyimage-cache) is a Lazy Image component with IntersectionObserver and cache action
|
||||
- [threlte v5.0](https://www.reddit.com/r/sveltejs/comments/ywit18/threlte_v50_is_here_a_completely_new_developer/) is a completely new developer experience that is faster, more powerful, and incredibly flexible
|
||||
|
||||
|
||||
That's it for this month! Let us know if we missed anything on [Reddit](https://www.reddit.com/r/sveltejs/) or [Discord](https://discord.gg/svelte)
|
||||
|
||||
See ya next near 🎆
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
title: "What's new in Svelte: January 2023"
|
||||
description: "SvelteKit 1.0, learn.svelte.dev, and type definitions for Svelte elements."
|
||||
description: 'SvelteKit 1.0, learn.svelte.dev, and type definitions for Svelte elements.'
|
||||
author: Dani Sandoval
|
||||
authorURL: https://dreamindani.com
|
||||
---
|
||||
@ -10,11 +10,13 @@ It's been just two weeks since the release of [SvelteKit 1.0](https://svelte.dev
|
||||
Let's dive into the details...
|
||||
|
||||
## What's new in SvelteKit
|
||||
|
||||
- `@sveltejs/kit` 1.0 is out! All future releases will follow semver and changes will be listed as major/minor/patch in the [CHANGELOG](https://github.com/sveltejs/kit/blob/master/packages/kit/CHANGELOG.md#100).
|
||||
- Improved support for Storybook and Histoire ([#7990](https://github.com/sveltejs/kit/pull/7990)). Work is ongoing to fully support those tools ([storybook#20239](https://github.com/storybookjs/storybook/pull/20239)).
|
||||
- `vitePreprocess` is now the default preprocessor. Please see [the docs](https://kit.svelte.dev/docs/integrations#preprocessors) for differences between `vitePreprocess` and `svelte-preprocess` ([#8036](https://github.com/sveltejs/kit/pull/8036)).
|
||||
|
||||
**Breaking changes:**
|
||||
|
||||
- Unknown exports (except when starting with an underscore) are no longer allowed from `+(layout|page)(.server)?.js` and `+server.js` files ([#7878](https://github.com/sveltejs/kit/pull/7878))
|
||||
- `__data.json` is now stripped from URL ([#7979](https://github.com/sveltejs/kit/pull/7979))
|
||||
- `sveltekit()` will now return a promise for an array of Vite plugins ([#7994](https://github.com/sveltejs/kit/pull/7994))
|
||||
@ -27,17 +29,21 @@ Let's dive into the details...
|
||||
- Warnings and errors about removed/changed APIs have been removed ([#8019](https://github.com/sveltejs/kit/pull/8019))
|
||||
|
||||
## What's new in Svelte
|
||||
|
||||
- The `options.direction` argument can now be passed to custom transition functions (**3.54.0**, [#3918](https://github.com/sveltejs/svelte/issues/3918))
|
||||
- Variables can now be updated from a `@const` declared function (**3.54.0**, [#7843](https://github.com/sveltejs/svelte/issues/7843))
|
||||
- `svelte/elements` has been added for Svelte/HTML type definitions (**3.55.0**, [#7649](https://github.com/sveltejs/svelte/pull/7649))
|
||||
|
||||
## What's new in Language Tools
|
||||
|
||||
The Svelte extension and language tools now have a few new minimum version requirements:
|
||||
|
||||
- Node version is now 16
|
||||
- TypeScript version is now 4.9
|
||||
- Svelte version is now 3.55
|
||||
|
||||
The following features have also been released:
|
||||
|
||||
- missing handler quick fix ([#1731](https://github.com/sveltejs/language-tools/pull/1731))
|
||||
- add Svelte anchor missing attribute code action ([#1730](https://github.com/sveltejs/language-tools/pull/1730))
|
||||
- better commit characters handling ([#1742](https://github.com/sveltejs/language-tools/pull/1742))
|
||||
@ -53,6 +59,7 @@ For all the changes to the Svelte compiler, including unreleased changes, check
|
||||
## Community Showcase
|
||||
|
||||
**Apps & Sites built with Svelte**
|
||||
|
||||
- [Svelte Recipes 🧑🍳](https://svelte.recipes/) provides code snippets for common data visualization problems
|
||||
- [Everything Svelte](https://www.everythingsvelte.com/) is a new course teaching everything you need to know to build a modern web application
|
||||
- [CSS Timeline](https://css-timeline.vercel.app/) is a Timeline of the history and evolution of CSS
|
||||
@ -66,6 +73,7 @@ For all the changes to the Svelte compiler, including unreleased changes, check
|
||||
**Learning Resources**
|
||||
|
||||
_From Svelte Society_
|
||||
|
||||
- [Svelte Society - London December 2022](https://www.youtube.com/watch?v=2ijSarsHfN0) featuring two talks by Antony and Rich, respectively. Rich's talk, "Mistakes were made" is a SvelteKit 1.0 retrospective.
|
||||
- [SvelteKit with Netlify Edge Functions](https://twitter.com/BrittneyPostma/status/1603402599742537729?s=20&t=Lw08QNMpdEP1JZzMQGXLDA) by Brittney Postma
|
||||
- [Sirens Stream: Skeleton - A fully featured UI Toolkit](https://www.youtube.com/watch?v=2OnJYCXJPK4) with Chris Simmons and Brittney Postma
|
||||
@ -73,11 +81,13 @@ _From Svelte Society_
|
||||
- [Sirens: Form Actions](https://www.youtube.com/watch?v=2OISk5-EHek) - Kev joins the Sirens again to chat about Form actions in SvelteKit and create a new form for speaker submissions on SvelteSirens.dev
|
||||
|
||||
_To Watch_
|
||||
|
||||
- [SvelteKit is my mistress](https://www.youtube.com/watch?v=uEJ-Rnm2yOE) by Fireship
|
||||
- [Sveltekit 1.0 in under 3 minutes](https://www.youtube.com/watch?v=3KGKDgwIrkE) by Gui Bibeau
|
||||
- [What Svelte UI Library Should You Use?](https://www.youtube.com/watch?v=O0mNU0maItY) and [The Best Icon Library For Svelte (Iconify)](https://www.youtube.com/watch?v=iGVhzsTZSa8) by Joy of Code
|
||||
|
||||
_To Read_
|
||||
|
||||
- [Rendering emails with Svelte](https://escape.tech/blog/sveltemails/) by Gautier Ben Aïm
|
||||
- [Now That React is Dead, What’s the Next Big Thing?](https://javascript.plainenglish.io/now-that-react-js-is-dead-whats-the-next-big-thing-7fa72a36a69b) by Somnath Singh
|
||||
- [What is SvelteKit? And Why Should You Care?](https://blog.tiia.rocks/what-is-sveltekit-and-why-should-you-care) by Tila
|
||||
@ -86,6 +96,7 @@ _To Read_
|
||||
- [Creating A Custom Svelte Media Query Store](https://pqina.nl/blog/svelte-media-query-store/) by Rik Schennink
|
||||
|
||||
**Libraries, Tools & Components**
|
||||
|
||||
- [Konsta UI](https://konstaui.com/) is a library of pixel perfect mobile UI components built with Tailwind CSS for React, Vue & Svelte
|
||||
- [probablykasper/modal-svelte](https://github.com/probablykasper/modal-svelte) is a modal component for Svelte
|
||||
- [deepcrayon/scrolltron](https://spacecruft.org/deepcrayon/scrolltron) is a news ticker overlay for OBS Studio
|
136
site/content/blog/2023-03-01-whats-new-in-svelte-march-2023.md
Normal file
136
site/content/blog/2023-03-01-whats-new-in-svelte-march-2023.md
Normal file
@ -0,0 +1,136 @@
|
||||
---
|
||||
title: "What's new in Svelte: March 2023"
|
||||
description: 'SvelteHack, post-1.0 SvelteKit improvements and a huge showcase'
|
||||
author: Dani Sandoval
|
||||
authorURL: https://dreamindani.com
|
||||
---
|
||||
|
||||
March is _coming in hot_ with a number of essential features having been added to SvelteKit following its 1.0 launch. Check out [last week's blog post](https://svelte.dev/blog/streaming-snapshots-sveltekit) for more details.
|
||||
|
||||
Svelte Society also launched [SvelteHack](https://hack.sveltesociety.dev/) last month with over $12,000 in prizes - calling all Svelte developers, new and old, to make something awesome before the April 17th deadline!
|
||||
|
||||
And, if you haven't heard already, there's going to be another Svelte Summit! Head over to [SvelteSummit.com](https://www.sveltesummit.com/) and sign up for the newsletter to get updates about the next event 📬
|
||||
|
||||
Now let's jump into this month's changes...
|
||||
|
||||
## What's new in SvelteKit
|
||||
|
||||
- `$app/paths` can now be used without an app - making things like component testing with Vitest, using Storybook, etc. easier (**1.4.0**, [#8838](https://github.com/sveltejs/kit/pull/8838))
|
||||
- Adapters can now be configured at the route level (**1.5.0**, [Docs](https://kit.svelte.dev/docs/page-options#config), [#8740](https://github.com/sveltejs/kit/pull/8740))
|
||||
- The new snapshot mechanism preserves ephemeral DOM state even after navigation and page reloads (**1.5.0**,[Docs](https://kit.svelte.dev/docs/snapshots), [#8710](https://github.com/sveltejs/kit/pull/8710))
|
||||
- `OPTIONS` are now available within the server method (**1.6.0**, [Docs](https://kit.svelte.dev/docs/routing#server), [#8731](https://github.com/sveltejs/kit/pull/8731))
|
||||
- Richer error messages have been added for invalid exports (**1.7.0**, [#9055](https://github.com/sveltejs/kit/pull/9055))
|
||||
- Streaming promises are now available for server load functions (**1.8.0**, [Docs](https://kit.svelte.dev/docs/load#streaming-with-promises), [#8901](https://github.com/sveltejs/kit/pull/8901))
|
||||
- A new configuration option, `preloadStrategy`, helps tune preloading to avoid import 'waterfalls' on certain browsers (**1.8.4**, [Docs](https://kit.svelte.dev/docs/configuration#output), [#9179](https://github.com/sveltejs/kit/pull/9179))
|
||||
- The new `paths.relative` option can control interpretation of `paths.assets` and `paths.base` (**1.9.0**, [Docs](https://kit.svelte.dev/docs/configuration#paths), [#9220](https://github.com/sveltejs/kit/pull/9220))
|
||||
|
||||
## What's new in Svelte and Language Tools
|
||||
|
||||
- The REPL on `svelte.dev` now supports the `exports` field in `package.json` ([#445](https://github.com/sveltejs/sites/pull/445))
|
||||
- The new Call Hierarchy feature lets you see where a function or a class is called and follow the call stack up (**extensions-107.1.0**, [#1889](https://github.com/sveltejs/language-tools/pull/1889))
|
||||
- `declarationMap` support has been added to the Svelte extension. Now "go to definition" on `.svelte` files will navigate to the source code when a library has declaration maps (**extensions-107.1.0**, [#1878](https://github.com/sveltejs/language-tools/pull/1878))
|
||||
- [TypeScript Inlay Hints](https://code.visualstudio.com/docs/typescript/typescript-editing#_inlay-hints) support is now available via the Svelte Extension. Enable them with `javascript.inlayHints.*` or `typescript.inlayHints.*` (**extensions-107.1.0**, [#1855](https://github.com/sveltejs/language-tools/pull/1855))
|
||||
|
||||
\*for all the changes to the Svelte compiler, including unreleased changes, check out the [CHANGELOG](https://github.com/sveltejs/svelte/blob/master/CHANGELOG.md).
|
||||
|
||||
---
|
||||
|
||||
## Community Showcase
|
||||
|
||||
**Apps & Sites built with Svelte**
|
||||
|
||||
- [win32.run](https://github.com/ducbao414/win32.run) is a version of Windows XP in the browser - with a File System, programs, XP-style File Picker and Saver dialogs, 3rd-party programs, and more
|
||||
- [Svelte Radial Menu](https://github.com/tglide/svelte-radial-menu) is a radial menu experiment - based on [Rauno's radial menu](https://rauno.me/craft/radial-menu)
|
||||
- [apod color search](https://github.com/brycedorn/apod-color-search) lets you search for astronomy picture of the day (APO) photos by color
|
||||
- [SvHighlight](https://www.reddit.com/r/sveltejs/comments/10pvqfm/svhighlight_a_code_highlighter_for_sveltekit_and/) is a code highlighter for SvelteKit and TailwindCSS with blur and focus blocks
|
||||
- [Limey](https://limey.io/) lets you create beautiful one-page websites in minutes
|
||||
- [a/links](https://a-links.io/) is an extension for short, composable bookmarks
|
||||
- [Sprint Cards](https://sprint.cards) is a design challenge generator
|
||||
- [Plought](https://github.com/rossrobino/plought) is a tool to reduce noise in decision making
|
||||
- [ArcOS-Frontend](https://github.com/IzK-ArcOS/ArcOS-Frontend) is a rewrite of the Arc operating system's frontend in Svelte
|
||||
- [Poxi](https://poxi.page) is powering the user-made web with a drag-and-drop, drawable website editor that's easy to collaborate in
|
||||
- [demo-threlte-scroller-rocinante](https://twitter.com/a_warnes/status/1629235313808744449) is a "scrolly telling" proof-of-concept that combines svelte-sequence with Threlte
|
||||
- [Phonics + Stuff](https://www.phonicsandstuff.com/) is a set of resources for learning & teaching phonics
|
||||
|
||||
**Learning Resources**
|
||||
|
||||
_Featuring Svelte Contributors and Ambassadors_
|
||||
|
||||
- [Streaming, snapshots, and other new features since SvelteKit 1.0](https://svelte.dev/blog/streaming-snapshots-sveltekit) by Geoff Rich (on the Svelte Blog)
|
||||
- [View Transition Experiments with Svelte](https://geoffrich.net/posts/view-transition-experiments/) and [Native Page Transitions in SvelteKit (updated for 2023)](https://geoffrich.net/posts/page-transitions-1/) by Geoff Rich
|
||||
- [Ron Au's story and how to be whimsical!](https://www.svelteradio.com/episodes/ron-aus-story-and-how-to-be-whimsical) by Svelte Radio
|
||||
- [SvelteKit 1.0 with Rich Harris](https://podrocket.logrocket.com/sveltekit) by PodRocket
|
||||
- [Svelte Society Africa](https://twitter.com/SvelteAfrica/status/1620526757593116672?s=20) has formally launched!
|
||||
- [SvelteKit overview with Simon and Dominik](https://www.youtube.com/watch?v=CiOigf4FbNg) by Frontend RheinMain
|
||||
|
||||
_To Watch or Hear_
|
||||
|
||||
- [Delightful Web Development with SvelteKit](https://workshops.thisdot.co/learn/developing-with-sveltekit) is a workshop from This Dot Labs - taking place on April 13th.
|
||||
- [Have More Control Over Layouts With Group Layouts In SvelteKit](https://www.youtube.com/watch?v=9UpaKEVuErs) and [Learn SvelteKit Hooks Through 6 Examples](https://www.youtube.com/watch?v=Kzrz7GZ9pIg) by Joy of Code
|
||||
- [Svelte Kit Creating Popup Modals with Tailwind CSS](https://www.youtube.com/watch?v=qI4-q7SA7uM) and [SvelteKit: Creating Dynamic Tables with Tailwind CSS](https://www.youtube.com/watch?v=QqoYrdzoSSk) by Abdul Rehman 2050
|
||||
|
||||
_To Read_
|
||||
|
||||
- [Svelte Language Server Example](https://github.com/volarjs/svelte-language-tools) by VolarJS
|
||||
- [How I Made My App 2.4x Faster Switching to Svelte](https://blog.flotes.app/posts/flotes-2x-faster) by Erik Verduin
|
||||
- [Smooth Page Transitions with SvelteKit](https://www.philkruft.dev/blog/smooth-page-transitions-with-sveltekit/) and [How to Build a Static SvelteKit Site](https://www.philkruft.dev/blog/how-to-build-a-static-sveltekit-site/) by Phil Kruft
|
||||
- [Blazing fast PWAs with SEO power using SvelteKit and Ionic](https://ionic.io/blog/pwas-using-sveltekit-and-ionic) by Tommertom
|
||||
- [Svelte Stores Tutorial: Share Data Between Multiple Components](https://learnjavascripts.com/development/web-development/frameworks/svelte/svelte-stores-tutorial-share-data-between-multiple-components/) by Vincent Widerberg
|
||||
- [A Business Case for SvelteKit](https://elliscs.hashnode.dev/a-business-case-for-sveltekit) by Chris Ellis
|
||||
- [How to set up a new Svelte project with SvelteKit](https://www.inow.dev/how-to-set-up-a-new-svelte-project-with-sveltekit/) by Igor Nowosad
|
||||
- [How to type Events, Slots, and Props in Svelte](https://raqueebuddinaziz.com/blog/svelte-type-events-slots-and-props/) by Raqueebuddin Aziz
|
||||
- [Use TypeScript with SvelteKit and Supabase](https://blog.robino.dev/posts/supabase-sveltekit) by Ross Robino
|
||||
- [Invoking Svelte components from your Ember apps](https://dev.to/rajasegar/invoking-svelte-components-from-your-ember-apps-58h5) by Rajasegar Chandran
|
||||
- [Add a sitemap to your server side rendered SvelteKit website](https://www.okupter.com/blog/sitemap-server-side-rendered-sveltekit-website) and [State in URL: the SvelteKit approach](https://www.okupter.com/blog/state-in-url-the-sveltekit-approach) by Justin Ahinon
|
||||
- [Display crypto data real-time in a chart using Sveltekit, Chart.js & coincap.io](https://medium.com/@Heesel/display-crypto-data-real-time-in-a-chart-using-sveltekit-chart-js-coincap-io-70b90d3aac90) by Hessel
|
||||
|
||||
**Libraries, Tools & Components**
|
||||
|
||||
_UI Kits and Components_
|
||||
|
||||
- [Pink](https://pink.appwrite.io/) is a framework agnostic design system from Appwrite
|
||||
- [quick-pick](https://github.com/arabisaldrin/quick-pick) is a simple search tool where you control the search catalog
|
||||
- [Grail UI](https://github.com/grail-ui/grail-ui) offers a set of component primitives, actions and utilities that help you build accessible and high quality Svelte applications faster, while providing a great developer experience
|
||||
- [svelte-image-comparison](https://www.npmjs.com/package/svelte-image-comparison) is a Svelte component to compare image or canvas elements
|
||||
- [simple-font-select](https://www.npmjs.com/package/simple-font-select) is a simple font select component that exposes all local fonts as CSS font families
|
||||
- [svelte-datatables-net](https://www.npmjs.com/package/svelte-datatables-net) is a Svelte component that turns data into an interactive HTML table
|
||||
- [svelte-flextable](https://github.com/Parazeya/svelte-flextable) is a toolkit for creating server-side processing datatable components with Svelte
|
||||
- [svelte-algolia-instantsearch](https://github.com/aymeric-giraudet/svelte-algolia-instantsearch) is a community-developed wrapper around [instantsearch.js](https://github.com/algolia/instantsearch) for Svelte
|
||||
- [svelte-deep-zoom](https://www.npmjs.com/package/svelte-deep-zoom) is a Svelte component to render interactive Deep Zoom images (tiled image pyramids)
|
||||
- [SVoast](https://github.com/gibbu/svoast) is a simple toast component for Svelte
|
||||
- [svelte-otp](https://github.com/K4UNG/svelte-otp) is a simple lightweight OTP input component for svelte
|
||||
- [trace-svelte](https://trace-svelte.vercel.app/) is a line by line highlighter for Svelte
|
||||
- [Svelte Auth UI](https://github.com/multiplehats/svelte-auth-ui) is a set of authentication components for Svelte
|
||||
- [KitDocs](https://github.com/svelteness/kit-docs) is a documentation integration for SvelteKit - a VitePress alternative for Svelte
|
||||
- [svelte-signature-pad](https://www.npmjs.com/package/svelte-signature-pad) is a Svelte action to capture smoothed signatures as SVG paths using the excellent [perfect-freehand](https://github.com/steveruizok/perfect-freehand) library
|
||||
|
||||
_Helpers, Stores and Actions_
|
||||
|
||||
- [SvelteKit-Document](https://github.com/barvian/sveltekit-document) is a tiny utility for SvelteKit that lets you change the `<html>`, `<head>`, and `<body>` tags from any page or layout - with full SSR support
|
||||
- [SvelteKit Form Data](https://github.com/stolinski/sk-form-data) is an automatic SvelteKit form data parser middleware
|
||||
- [sveltekit-superforms](https://github.com/ciscoheat/sveltekit-superforms) supercharges your SvelteKit forms with a bunch of quality of life features. Purports to be a "powerhouse of a library"
|
||||
- [Houdini](https://github.com/HoudiniGraphQL/houdini) - the "disappearing" GraphQL client for the SvelteKit - is now 1.0
|
||||
- [sveltekit-modal-langchain](https://github.com/semicognitive/sveltekit-modal-langchain) is an example SvelteKit project using [sveltekit-modal](https://github.com/semicognitive/sveltekit-modal), showing how easy it is to write Python endpoints in SvelteKit
|
||||
- [mdsvex-excerpt](https://www.npmjs.com/package/mdsvex-excerpt) allows you to show only a portion of document in certain layouts
|
||||
- [Svelte Action Balancer](https://www.npmjs.com/package/svelte-action-balancer) is a simple Svelte action that makes titles more readable
|
||||
- [svelte-object](https://github.com/Refzlund/svelte-object) helps create and maintain objects using components. Values are stores and can therefore be intuitively subscribed to and updated
|
||||
- [svelte-relative-time](https://www.npmjs.com/package/svelte-relative-time) is a tiny Svelte action and component to render relative times
|
||||
- [svelte-disable-preload](https://www.npmjs.com/package/svelte-disable-preload) is a simple action to apply no-op event listeners to an element that prevent the document-level SvelteKit event handlers being invoked
|
||||
- [SvelteKit Static Sitemap](https://github.com/tlaundal/sveltekit-static-sitemap) generates a sitemap.xml for your page during build
|
||||
- [svelte-intersection-observer-action](https://www.npmjs.com/package/svelte-intersection-observer-action) is a Svelte action for element position notifications using IntersectionObserver
|
||||
- [svelte-sequence](https://github.com/AlexWarnes/svelte-sequence) provides custom stores to compose tweened motion sequences over multiple steps
|
||||
- [@svelte-put/inline-svg](https://github.com/vnphanquang/svelte-put/tree/main/packages/actions/inline-svg) is a Svelte action for inlining dynamic SVGs (fetched from network)
|
||||
|
||||
_Other cool tools_
|
||||
|
||||
- [sveltekit-modal](https://github.com/semicognitive/sveltekit-modal) lets you write Python endpoints in SvelteKit using Modal
|
||||
- [svelte-kit-bot-block](https://www.npmjs.com/package/svelte-kit-bot-block) is a server hook to handle spam requests with SvelteKit
|
||||
- [Svelte Email](https://github.com/carstenlebek/svelte-email) lets you write and design email templates with Svelte and render them to HTML or plain text
|
||||
- [Inertia.js](https://github.com/inertiajs/inertia) lets you quickly build modern single-page React, Vue and Svelte apps using classic server-side routing and controllers
|
||||
- [svelte-adapter-bun](https://github.com/gornostay25/svelte-adapter-bun) is an adapter for SvelteKit apps that generates a standalone Bun server
|
||||
- [React in Svelte](https://github.com/frontline-hq/react-in-svelte) is a library that enables you to use React components in Svelte
|
||||
- [SvelteKit Redis Session Manager](https://github.com/etherCorps/SK-Redis-SessionManager) is a Redis integration in SvelteKit for Session Management
|
||||
|
||||
Thanks for reading! Don't forget to try your hand at the [Svelte Hackathon](https://hack.sveltesociety.dev/)!
|
||||
|
||||
Feel free to let us know if we missed anything on [Reddit](https://www.reddit.com/r/sveltejs/) or [Discord](https://discord.gg/svelte)
|
164
site/content/blog/2023-03-09-zero-config-type-safety.md
Normal file
164
site/content/blog/2023-03-09-zero-config-type-safety.md
Normal file
@ -0,0 +1,164 @@
|
||||
---
|
||||
title: Zero-effort type safety
|
||||
description: More convenience and correctness, less boilerplate
|
||||
author: Simon Holthausen
|
||||
authorURL: https://twitter.com/dummdidumm_
|
||||
---
|
||||
|
||||
By sprinkling type annotations into your SvelteKit apps, you can get full type safety across the network — the `data` in your page has a type that's inferred from the return values of the `load` functions that generated that data, without you having to explicitly declare anything. It's one of those things that you come to wonder how you ever lived without.
|
||||
|
||||
But what if we didn't even need the annotations? Since `load` and `data` are part of the framework, can't the framework type them for us? This is, after all, what computers are for — doing the boring bits so we can focus on the creative stuff.
|
||||
|
||||
As of today, yes: it can.
|
||||
|
||||
<video src="https://sveltejs.github.io/assets/video/zero-config-types.mp4" controls muted playsinline></video>
|
||||
|
||||
If you're using VSCode, just upgrade the Svelte extension to the latest version, and you'll never have to annotate your `load` functions or `data` props again. Extensions for other editors can also use this feature, as long as they support the Language Server Protocol and TypeScript plugins. It even works with the latest version of our CLI diagnostics tool `svelte-check`!
|
||||
|
||||
Before we dive in, let's recap how type safety works in SvelteKit.
|
||||
|
||||
## Generated types
|
||||
|
||||
In SvelteKit, you get the data for a page in a `load` function. You _could_ type the event by using `ServerLoadEvent` from `@sveltejs/kit`:
|
||||
|
||||
```ts
|
||||
// src/routes/blog/[slug]/+page.server.ts
|
||||
import type { ServerLoadEvent } from '@sveltejs/kit';
|
||||
|
||||
export async function load(event: ServerLoadEvent) {
|
||||
return {
|
||||
post: await database.getPost(event.params.post)
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
This works, but we can do better. Notice that we accidentally wrote `event.params.post`, even though the parameter is called `slug` (because of the `[slug]` in the filename) rather than `post`. You could type `params` yourself by adding a generic argument to `ServerLoadEvent`, but that's brittle.
|
||||
|
||||
This is where our automatic type generation comes in. Every route directory has a hidden `$types.d.ts` file with route-specific types:
|
||||
|
||||
```diff
|
||||
// src/routes/blog/[slug]/+page.server.ts
|
||||
-import type { ServerLoadEvent } from '@sveltejs/kit';
|
||||
+import type { PageServerLoadEvent } from './$types';
|
||||
|
||||
export async function load(event: PageServerLoadEvent) {
|
||||
return {
|
||||
- post: await database.getPost(event.params.post)
|
||||
+ post: await database.getPost(event.params.slug)
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
This reveals our typo, as it now errors on the `params.post` property access. Besides narrowing the parameter types, it also narrows the types for `await event.parent()` and the `data` passed from a server `load` function to a universal `load` function. Notice that we’re now using `PageServerLoadEvent`, to distinguish it from `LayoutServerLoadEvent`.
|
||||
|
||||
After we have loaded our data, we want to display it in our `+page.svelte`. The same type generation mechanism ensures that the type of `data` is correct:
|
||||
|
||||
```svelte
|
||||
<!-- src/routes/blog/[slug]/+page.svelte -->
|
||||
<script lang="ts">
|
||||
import type { PageData } from './$types';
|
||||
|
||||
export let data: PageData;
|
||||
</script>
|
||||
|
||||
<h1>{data.post.title}</h1>
|
||||
|
||||
<div>{@html data.post.content}</div>
|
||||
```
|
||||
|
||||
## Virtual files
|
||||
|
||||
When running the dev server or the build, types are auto-generated. Thanks to the file-system based routing, SvelteKit is able to infer things like the correct parameters or parent data by traversing the route tree. The result is outputted into one `$types.d.ts` file for each route, which looks roughly like this:
|
||||
|
||||
```ts
|
||||
// $types.d.ts
|
||||
import type * as Kit from '@sveltejs/kit';
|
||||
|
||||
// types inferred from the routing tree
|
||||
type RouteParams = { slug: string };
|
||||
type RouteId = '/blog/[slug]';
|
||||
type PageParentData = {};
|
||||
|
||||
// PageServerLoad type extends the generic Load type and fills its generics with the info we have
|
||||
export type PageServerLoad = Kit.ServerLoad<RouteParams, PageParentData, RouteId>;
|
||||
|
||||
// The input parameter type of the load function
|
||||
export type PageServerLoadEvent = Parameters<PageServerLoad>[0];
|
||||
|
||||
// The return type of the load function
|
||||
export type PageData = Kit.ReturnType<
|
||||
typeof import('../src/routes/blog/[slug]/+page.server.js').load
|
||||
>;
|
||||
```
|
||||
|
||||
We don't actually write `$types.d.ts` into your `src` directory — that would be messy, and no-one likes messy code. Instead, we use a TypeScript feature called [`rootDirs`](https://www.typescriptlang.org/tsconfig#rootDirs), which lets us map ‘virtual’ directories to real ones. By setting `rootDirs` to the project root (the default) and additionally to `.svelte-kit/types` (the output folder of all the generated types) and then mirroring the route structure inside it we get the desired behavior:
|
||||
|
||||
```
|
||||
// on disk:
|
||||
.svelte-kit/
|
||||
├ types/
|
||||
│ ├ src/
|
||||
│ │ ├ routes/
|
||||
│ │ │ ├ blog/
|
||||
│ │ │ │ ├ [slug]/
|
||||
│ │ │ │ │ └ $types.d.ts
|
||||
src/
|
||||
├ routes/
|
||||
│ ├ blog/
|
||||
│ │ ├ [slug]/
|
||||
│ │ │ ├ +page.server.ts
|
||||
│ │ │ └ +page.svelte
|
||||
|
||||
|
||||
// what TypeScript sees:
|
||||
src/
|
||||
├ routes/
|
||||
│ ├ blog/
|
||||
│ │ ├ [slug]/
|
||||
│ │ │ ├ $types.d.ts
|
||||
│ │ │ ├ +page.server.ts
|
||||
│ │ │ └ +page.svelte
|
||||
```
|
||||
|
||||
## Type safety without types
|
||||
|
||||
Thanks to the automatic type generation we get advanced type safety. Wouldn't it be great though if we could just omit writing the types at all? As of today you can do exactly that:
|
||||
|
||||
```diff
|
||||
// src/routes/blog/[slug]/+page.server.ts
|
||||
-import type { PageServerLoadEvent } from './$types';
|
||||
|
||||
-export async function load(event: PageServerLoadEvent) {
|
||||
+export async function load(event) {
|
||||
return {
|
||||
post: await database.getPost(event.params.post)
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
```diff
|
||||
<!-- src/routes/blog/[slug]/+page.svelte -->
|
||||
<script lang="ts">
|
||||
- import type { PageData } from './$types';
|
||||
- export let data: PageData;
|
||||
+ export let data;
|
||||
</script>
|
||||
```
|
||||
|
||||
While this is super convenient, this isn't just about that. It's also about _correctness_: When copying and pasting code it's easy to accidentally get `PageServerLoadEvent` mixed up with `LayoutServerLoadEvent` or `PageLoadEvent`, for example — similar types with subtle differences. Svelte's major insight was that by writing code in a declarative way we can get the machine to do the bulk of the work for us, correctly and efficiently. This is no different — by leveraging strong framework conventions like `+page` files, we can make it easier to do the right thing than to do the wrong thing.
|
||||
|
||||
This works for all exports from SvelteKit files (`+page`, `+layout`, `+server`, `hooks`, `params` and so on) and for `data`, `form` and `snapshot` properties in `+page/layout.svelte` files.
|
||||
|
||||
To use this feature with VS Code install the latest version of the Svelte for VS Code extension. For other IDEs, use the latest versions of the Svelte language server and the Svelte TypeScript plugin. Beyond the editor, our command line tool `svelte-check` also knows how to add these annotations since version 3.1.1.
|
||||
|
||||
## How does it work?
|
||||
|
||||
Getting this to work required changes to both the language server (which powers the IntelliSense in Svelte files) and the TypeScript plugin (which makes TypeScript understand Svelte files from within `.ts/js` files). In both we auto-insert the correct types at the correct positions and tell TypeScript to use our virtual augmented file instead of the original untyped file. That in combination with mapping the generated and original positions back and forth gives the desired result. Since `svelte-check` reuses parts of the language server under the hood, it gets that feature for free without further adjustments.
|
||||
|
||||
We'd like to thank the Next.js team for [inspiring](https://twitter.com/shuding_/status/1625263297573400578) this feature.
|
||||
|
||||
## What's next
|
||||
|
||||
For the future we want to look into making even more areas of SvelteKit type-safe — links for example, be it in your HTML or through programmatically calling `goto`.
|
||||
|
||||
TypeScript is eating the JavaScript world — and we're here for it! We care deeply about first class type safety in SvelteKit, and we provide you the tools to make the experience as smooth as possible — one that also scales beautifully to larger Svelte code bases — regardless of whether you use TypeScript or typed JavaScript through JSDoc.
|
109
site/content/blog/2023-04-01-whats-new-in-svelte-april-2023.md
Normal file
109
site/content/blog/2023-04-01-whats-new-in-svelte-april-2023.md
Normal file
@ -0,0 +1,109 @@
|
||||
---
|
||||
title: "What's new in Svelte: April 2023"
|
||||
description: "Loads of new Svelte compiler features, plus Svelte Summit and SvelteHack"
|
||||
author: Dani Sandoval
|
||||
authorURL: https://dreamindani.com
|
||||
---
|
||||
|
||||
Happy April, everyone! This month, we're covering all the new features in the Svelte compiler, some quality-of-life improvements in SvelteKit and a huge showcase (like always).
|
||||
|
||||
In core team news, Dominic Gannaway has joined Vercel to work on Svelte full-time! Dominic is a world-class expert on wringing performance out of javascript engines, on the DOM, on reactivity, on accessibility, and more! You might know him as the creator of the [Inferno](https://www.infernojs.org/) UI framework or [Lexical](https://lexical.dev/), Meta's WYSIWYG editor. It'll be great to see his talents at work across the Svelte ecosystem 🌱
|
||||
|
||||
Don't forget! Svelte Summit Spring, Svelte's 6th virtual conference, will be happening on May 6th. Also, there's just two weeks left until the end of [SvelteHack](https://hack.sveltesociety.dev/)... It's a great opportunity to share your creations with the community and maybe even earn a prize!
|
||||
|
||||
Now let's jump into this month's changes...
|
||||
|
||||
## What's new in Svelte
|
||||
- A bunch of new features are now available as of **3.56.0**!
|
||||
- Add `|stopImmediatePropagation` event modifier for `on:eventname` ([#5085](https://github.com/sveltejs/svelte/issues/5085), [Docs](https://svelte.dev/docs#template-syntax-element-directives-on-eventname))
|
||||
- Add `axis` parameter to `slide` transition ([#6182](https://github.com/sveltejs/svelte/issues/6182), [Docs](https://svelte.dev/docs#run-time-svelte-transition-slide))
|
||||
- Add `readonly` utility to convert `writable` store to readonly ([#6518](https://github.com/sveltejs/svelte/pull/6518), [Docs](https://svelte.dev/docs#run-time-svelte-store-writable))
|
||||
- Add `readyState` binding for media elements ([#6666](https://github.com/sveltejs/svelte/issues/6666), [Docs](https://svelte.dev/docs#template-syntax-element-directives-bind-property-media-element-bindings))
|
||||
- Add `naturalWidth` and `naturalHeight` bindings to images ([#7771](https://github.com/sveltejs/svelte/issues/7771), [Docs](https://svelte.dev/docs#template-syntax-element-directives-bind-property-image-element-bindings))
|
||||
- Support `<!-- svelte-ignore ... -->` on components ([#8082](https://github.com/sveltejs/svelte/issues/8082))
|
||||
- Inputs in a `bind:group` will clear when their value is set to `undefined` (**3.56.0**, [#8214](https://github.com/sveltejs/svelte/issues/8214))
|
||||
- `<input>` values will now persist when swapping elements with spread attributes in an `{#each}` block (**3.56.0**, [#7578](https://github.com/sveltejs/svelte/issues/7578))
|
||||
- Better warnings across the board - from `noreferrer` to `aria` rules (**3.56.0**)
|
||||
- Add <svelte:document> (**3.57.0**, [#3310](https://github.com/sveltejs/svelte/issues/3310))
|
||||
- The `style:` directive will now take precedence over a `style=` attribute (**3.57.0**, [#7475](https://github.com/sveltejs/svelte/issues/7475))
|
||||
- CSS units are now supported in the `fly` and `blur` transitions (**3.57.0**, [#7623](https://github.com/sveltejs/svelte/pull/7623), [Docs](https://svelte.dev/docs#run-time-svelte-transition))
|
||||
|
||||
For all the changes to the Svelte compiler, including unreleased changes, check out the [CHANGELOG](https://github.com/sveltejs/svelte/blob/master/CHANGELOG.md).
|
||||
|
||||
## What's new in SvelteKit
|
||||
- You can now get all cookies for a request with `cookies.getAll` (**1.10.0**, [#9287](https://github.com/sveltejs/kit/pull/9287), [Docs](https://kit.svelte.dev/docs/types#public-types-cookies))
|
||||
- Easily manage the submission status of (multiple) forms with the new exposed `submitter` parameter in `use:enhance` (**1.12.0**, [#9425](https://github.com/sveltejs/kit/pull/9425), [Docs](https://kit.svelte.dev/docs/types#public-types-submitfunction))
|
||||
- The default error page now has dark mode styles (**1.13.0**, [#9460](https://github.com/sveltejs/kit/pull/9460))
|
||||
- You can now omit types on all methods and variables with special meaning to SvelteKit and still benefit from full type safety! Read more about it in the [announcement blog post](https://svelte.dev/blog/zero-config-type-safety)
|
||||
---
|
||||
|
||||
## Community Showcase
|
||||
|
||||
**Apps & Sites built with Svelte**
|
||||
- [Peerbeer](https://peer.beer/) lets you share files peer-to-peer (p2p) without any third parties or data limits
|
||||
- [unplaneted](https://unplaneted.com/) is an interface for exploring very large space images
|
||||
- [PokeBook](https://github.com/pokegh0st/pokebook) is a digital notebook for writing poetry that provides a beautiful distraction-free environment and autosave
|
||||
- [papi](https://papi.run/) lets you create prompts for AI models and share them with others with a unique link
|
||||
- [Mathesar](https://github.com/centerofci/mathesar) is a straightforward open source tool that provides a spreadsheet-like interface to a PostgreSQL database
|
||||
- [SQLite Playground](https://neil.macmunn.com/sqlite#) lets you learn how SQLite runs and stores data in the browser
|
||||
- [svgl](https://github.com/pheralb/svgl) is a beautiful library with SVG logos
|
||||
- [Swehl](https://swehl.com/) is an eCommerce store, community and tutorial site for breastfeeding mothers
|
||||
- [Codeverter](https://github.com/TGlide/codeverter) is a GPT-powered code converter, allowing you to convert between different languages and frameworks
|
||||
- [Game On Or Not](https://gameonornot.com/) is a free web app that helps you organize sports with your friends
|
||||
- [Sveltia CMS](https://github.com/sveltia/sveltia-cms) is a Git-based lightweight headless CMS
|
||||
|
||||
**Learning Resources**
|
||||
|
||||
_Featuring Svelte Contributors and Ambassadors_
|
||||
- [Streaming, snapshots, and other new features since SvelteKit 1.0](https://svelte.dev/blog/streaming-snapshots-sveltekit) by Geoff Rich on the svelte.dev Blog
|
||||
- [Dev Vlog: Rich Harris shows us what's new in Svelte and Kit, March 2023](https://www.youtube.com/watch?v=vgXgex5E-8g) from Svelte Society
|
||||
- If you missed this one live, check out [the next one](https://www.youtube.com/watch?v=MJHO6FSioPI) - scheduled for April 5th
|
||||
- [Svelte Society - London February 2023](https://www.youtube.com/watch?v=RkQ_f7XxdMI)
|
||||
- Svelte Radio episodes from this month:
|
||||
- [We all live in a Svelte Submarine](https://www.svelteradio.com/episodes/we-all-live-in-a-svelte-submarine)
|
||||
- [Building furniture using Svelte with Bert Bengtson](https://www.svelteradio.com/episodes/building-furniture-using-svelte-with-bert-bengtson)
|
||||
- [Svelte Hackathon Announcement](https://www.svelteradio.com/episodes/svelte-hackathon-announcement)
|
||||
- [LevelUpTuts 6 months later with Scott Tolinski](https://www.svelteradio.com/episodes/leveluptuts-6-months-later-with-scott-tolinski)
|
||||
- [I got a cold and had fever dreams about React 😱](https://www.svelteradio.com/episodes/i-got-a-cold-and-had-fever-dreams-about-react)
|
||||
- This Week In Svelte videos:
|
||||
- [2023 March 10 - New prompts! Underline your links!](https://www.youtube.com/watch?v=WiCjQVoE-3k)
|
||||
- [2023 March 17 - More a11y warnings! How to: Dynamic Form Actions!](https://www.youtube.com/watch?v=sRhZQ-2VxVU)
|
||||
- [2023 March 23 - SvelteKit 1.13.0, Vitest and Playwright overview](https://www.youtube.com/watch?v=vpbhsbg2otg)
|
||||
|
||||
_To Watch or Hear_
|
||||
- [Full Stack SvelteKit App Deployment Using Vercel And Supabase For $0](https://www.youtube.com/watch?v=uAF4Yd-gddo) by Joy of Code
|
||||
- [Why Is Svelte.js so Popular?](https://www.youtube.com/watch?v=73Y8Yyg54zc) by Prismic
|
||||
- [Interactive Tables in SvelteKit with TanStack Table](https://www.youtube.com/watch?v=-Zuo3UWjjI8) by hartenfellerdev
|
||||
- [SvelteKit + GraphQL with Houdini](https://www.youtube.com/watch?v=ADnaRwQZfqw&list=PLm0ILX0LGQk_220vvpsbyXH2VesRlCm-E) by Aftab Alam
|
||||
|
||||
|
||||
_To Read_
|
||||
- [Thoughts on Svelte](https://tyhopp.com/notes/thoughts-on-svelte) by Ty Hopp
|
||||
- [Storybook](https://storybook.js.org/blog/storybook-for-sveltekit/) on why (and how) it supports SvelteKit
|
||||
- [Svelte Authentication Tutorial with Authorizer](https://thethinks.vercel.app/blog/svelte-authorizer) by The Thinks
|
||||
- [Use Zod to Validate Forms on the Server with SvelteKit](https://blog.robino.dev/posts/svelte-zod-error) by Ross Robino
|
||||
- [Do I need a sitemap for my SvelteKit app, and how do I create it?](https://maier.tech/posts/do-i-need-a-sitemap-for-my-sveltekit-app-and-how-do-i-create-it) and [Complement zero-effort type safety in SvelteKit with Zod for even more type safety](https://maier.tech/posts/complement-zero-effort-type-safety-in-sveltekit-with-zod-for-even-more-type-safety) and [Configuring Turborepo for a SvelteKit monorepo](https://maier.tech/posts/configuring-turborepo-for-a-sveltekit-monorepo) by Thilo Maier
|
||||
- [Adding page transitions in SvelteKit](https://joshcollinsworth.com/blog/sveltekit-page-transitions) by Josh Collinsworth
|
||||
- [E2E testing with SvelteKit and Playwright](https://www.okupter.com/blog/e2e-testing-with-sveltekit-and-playwright) and [Why you should use TypeScript in your next SvelteKit projects](https://www.okupter.com/blog/sveltekit-with-typescript) by Justin Ahinon
|
||||
- [Understanding the structure of a SvelteKit project](https://www.inow.dev/understanding-the-structure-of-a-svelte-kit-project/) by Igor Nowosad
|
||||
- [Secure Authentication in Svelte using Hooks](https://dev.to/brewhousedigital/secure-authentication-in-svelte-using-hooks-k5j) by Brewhouse Digital
|
||||
|
||||
**Libraries, Tools & Components**
|
||||
- [@vavite/node-loader](https://github.com/cyco130/vavite/tree/main/packages/node-loader) is a Node ESM loader that uses Vite to transpile modules to enable sourcemap and breakpoints support in SvelteKit (or any Vite) project
|
||||
- [Inlang](https://github.com/inlang/inlang) is building i18n for SvelteKit and is [looking for feedback](https://www.reddit.com/r/sveltejs/comments/11ydtui/sveltekit_and_i18n_lets_finally_solve_this_never/)
|
||||
- [Skeleton](https://www.skeleton.dev/) - the UI toolkit for Svelte and Tailwind - is now 1.0 🎉
|
||||
- [SvelteKit-integrated-WebSocket](https://github.com/suhaildawood/SvelteKit-integrated-WebSocket) provides first-class support for WebSockets within SvelteKit by attaching a WebSocket server to the global state
|
||||
- [Svelte Legos](https://github.com/ankurrsinghal/svelte-legos) is a collection of essential Svelte Composition Utilities
|
||||
- [svelte-stored-writable](https://github.com/efstajas/svelte-stored-writable) is a drop-in extension of Svelte's writable that additionally stores and restores its contents using localStorage.
|
||||
- [svelte-virtual](https://github.com/ghostebony/svelte-virtual) provides Svelte components for efficiently rendering large lists.
|
||||
- ChatGPT Clones and Starters
|
||||
- [chatwithme.chat](https://github.com/kierangilliam/chatwithme.chat) is an open source ChatGPT UI
|
||||
- [SlickGPT](https://github.com/ShipBit/slickgpt) is a light-weight "use-your-own-API-key" web client for the OpenAI API written in Svelte
|
||||
- [AI Chat Bestie](https://github.com/KTruong008/aichatbestie) is an unofficial ChatGPT app
|
||||
- [chatgpt-svelte](https://github.com/ichbtrv/chatgpt-svelte) is a simple UI for the ChatGPT Open AI API
|
||||
|
||||
Thanks for reading! And don't forget to try your hand at the [Svelte Hackathon](https://hack.sveltesociety.dev/) 🧑💻
|
||||
|
||||
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).
|
||||
|
||||
See ya next time!
|
@ -7,6 +7,7 @@ title: Getting started
|
||||
To try Svelte in an interactive online environment you can try [the REPL](https://svelte.dev/repl) or [StackBlitz](https://node.new/svelte).
|
||||
|
||||
To create a project locally we recommend using [SvelteKit](https://kit.svelte.dev/), the official application framework from the Svelte team:
|
||||
|
||||
```
|
||||
npm create svelte@latest myapp
|
||||
cd myapp
|
||||
@ -16,7 +17,7 @@ npm run dev
|
||||
|
||||
SvelteKit will handle calling [the Svelte compiler](https://www.npmjs.com/package/svelte) to convert your `.svelte` files into `.js` files that create the DOM and `.css` files that style it. It also provides all the other pieces you need to build a web application such as a development server, routing, and deployment. [SvelteKit](https://kit.svelte.dev/) utilizes [Vite](https://vitejs.dev/) to build your code and handle server-side rendering (SSR). There are [plugins for all the major web bundlers](https://sveltesociety.dev/tools#bundling) to handle Svelte compilation, which will output `.js` and `.css` that you can insert into your HTML, but most others won't handle SSR.
|
||||
|
||||
If you don't need a full-fledged app framework and instead want to build a simple frontend-only site/app, you can also use Svelte (without Kit) with Vite by running `npm init vite` and selecting the `svelte` option. With this, `npm run build` will generate HTML, JS and CSS files inside the `dist` directory.
|
||||
If you don't need a full-fledged app framework and instead want to build a simple frontend-only site/app, you can also use Svelte (without Kit) with Vite by running `npm init vite` and selecting the `svelte` option. With this, `npm run build` will generate HTML, JS and CSS files inside the `dist` directory.
|
||||
|
||||
The Svelte team maintains a [VS Code extension](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode) and there are integrations with various other [editors](https://sveltesociety.dev/tools#editor-support) and tools as well.
|
||||
|
||||
|
@ -28,7 +28,7 @@ A `<script>` block contains JavaScript that runs when a component instance is cr
|
||||
|
||||
---
|
||||
|
||||
Svelte uses the `export` keyword to mark a variable declaration as a *property* or *prop*, which means it becomes accessible to consumers of the component (see the section on [attributes and props](/docs#template-syntax-attributes-and-props) for more information).
|
||||
Svelte uses the `export` keyword to mark a variable declaration as a _property_ or _prop_, which means it becomes accessible to consumers of the component (see the section on [attributes and props](/docs/template-syntax#attributes-and-props) for more information).
|
||||
|
||||
```sv
|
||||
<script>
|
||||
@ -44,7 +44,7 @@ Svelte uses the `export` keyword to mark a variable declaration as a *property*
|
||||
|
||||
You can specify a default initial value for a prop. It will be used if the component's consumer doesn't specify the prop on the component (or if its initial value is `undefined`) when instantiating the component. Note that whenever a prop is removed by the consumer, its value is set to `undefined` rather than the initial value.
|
||||
|
||||
In development mode (see the [compiler options](/docs#compile-time-svelte-compile)), a warning will be printed if no default initial value is provided and the consumer does not specify a value. To squelch this warning, ensure that a default initial value is specified, even if it is `undefined`.
|
||||
In development mode (see the [compiler options](/docs/compile-time#svelte-compile)), a warning will be printed if no default initial value is provided and the consumer does not specify a value. To squelch this warning, ensure that a default initial value is specified, even if it is `undefined`.
|
||||
|
||||
```sv
|
||||
<script>
|
||||
@ -71,7 +71,7 @@ If you export a `const`, `class` or `function`, it is readonly from outside the
|
||||
</script>
|
||||
```
|
||||
|
||||
Readonly props can be accessed as properties on the element, tied to the component using [`bind:this` syntax](/docs#template-syntax-component-directives-bind-this).
|
||||
Readonly props can be accessed as properties on the element, tied to the component using [`bind:this` syntax](/docs/template-syntax#component-directives-bind-this).
|
||||
|
||||
---
|
||||
|
||||
@ -174,11 +174,11 @@ Only values which directly appear within the `$:` block will become dependencies
|
||||
<script>
|
||||
let x = 0;
|
||||
let y = 0;
|
||||
|
||||
|
||||
function yPlusAValue(value) {
|
||||
return value + y;
|
||||
}
|
||||
|
||||
|
||||
$: total = yPlusAValue(x);
|
||||
</script>
|
||||
|
||||
@ -193,17 +193,18 @@ Total: {total}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
It is important to note that the reactive blocks are ordered via simple static analysis at compile time, and all the compiler looks at are the variables that are assigned to and used within the block itself, not in any functions called by them. This means that `yDependent` will not be updated when `x` is updated in the following example:
|
||||
|
||||
```sv
|
||||
<script>
|
||||
let x = 0;
|
||||
let y = 0;
|
||||
|
||||
|
||||
const setY = (value) => {
|
||||
y = value;
|
||||
}
|
||||
|
||||
|
||||
$: yDependent = y;
|
||||
$: setY(x);
|
||||
</script>
|
||||
@ -230,7 +231,7 @@ If a statement consists entirely of an assignment to an undeclared variable, Sve
|
||||
|
||||
---
|
||||
|
||||
A *store* is an object that allows reactive access to a value via a simple *store contract*. The [`svelte/store` module](/docs#run-time-svelte-store) contains minimal store implementations which fulfil this contract.
|
||||
A _store_ is an object that allows reactive access to a value via a simple _store contract_. The [`svelte/store` module](/docs/run-time#svelte-store) contains minimal store implementations which fulfil this contract.
|
||||
|
||||
Any time you have a reference to a store, you can access its value inside a component by prefixing it with the `$` character. This causes Svelte to declare the prefixed variable, subscribe to the store at component initialization and unsubscribe when appropriate.
|
||||
|
||||
@ -238,7 +239,7 @@ Assignments to `$`-prefixed variables require that the variable be a writable st
|
||||
|
||||
Note that the store must be declared at the top level of the component — not inside an `if` block or a function, for example.
|
||||
|
||||
Local variables (that do not represent store values) must *not* have a `$` prefix.
|
||||
Local variables (that do not represent store values) must _not_ have a `$` prefix.
|
||||
|
||||
```sv
|
||||
<script>
|
||||
@ -261,15 +262,14 @@ Local variables (that do not represent store values) must *not* have a `$` prefi
|
||||
store = { subscribe: (subscription: (value: any) => void) => (() => void), set?: (value: any) => void }
|
||||
```
|
||||
|
||||
You can create your own stores without relying on [`svelte/store`](/docs#run-time-svelte-store), by implementing the *store contract*:
|
||||
You can create your own stores without relying on [`svelte/store`](/docs/run-time#svelte-store), by implementing the _store contract_:
|
||||
|
||||
1. A store must contain a `.subscribe` method, which must accept as its argument a subscription function. This subscription function must be immediately and synchronously called with the store's current value upon calling `.subscribe`. All of a store's active subscription functions must later be synchronously called whenever the store's value changes.
|
||||
2. The `.subscribe` method must return an unsubscribe function. Calling an unsubscribe function must stop its subscription, and its corresponding subscription function must not be called again by the store.
|
||||
3. A store may *optionally* contain a `.set` method, which must accept as its argument a new value for the store, and which synchronously calls all of the store's active subscription functions. Such a store is called a *writable store*.
|
||||
3. A store may _optionally_ contain a `.set` method, which must accept as its argument a new value for the store, and which synchronously calls all of the store's active subscription functions. Such a store is called a _writable store_.
|
||||
|
||||
For interoperability with RxJS Observables, the `.subscribe` method is also allowed to return an object with an `.unsubscribe` method, rather than return the unsubscription function directly. Note however that unless `.subscribe` synchronously calls the subscription (which is not required by the Observable spec), Svelte will see the value of the store as `undefined` until it does.
|
||||
|
||||
|
||||
### <script context="module">
|
||||
|
||||
---
|
||||
@ -280,7 +280,7 @@ You can `export` bindings from this block, and they will become exports of the c
|
||||
|
||||
You cannot `export default`, since the default export is the component itself.
|
||||
|
||||
> Variables defined in `module` scripts are not reactive — reassigning them will not trigger a rerender even though the variable itself will update. For values shared between multiple components, consider using a [store](/docs#run-time-svelte-store).
|
||||
> Variables defined in `module` scripts are not reactive — reassigning them will not trigger a rerender even though the variable itself will update. For values shared between multiple components, consider using a [store](/docs/run-time#svelte-store).
|
||||
|
||||
```sv
|
||||
<script context="module">
|
||||
@ -299,7 +299,6 @@ You cannot `export default`, since the default export is the component itself.
|
||||
</script>
|
||||
```
|
||||
|
||||
|
||||
### <style>
|
||||
|
||||
---
|
||||
@ -336,11 +335,11 @@ To apply styles to a selector globally, use the `:global(...)` modifier.
|
||||
}
|
||||
|
||||
p:global(.red) {
|
||||
/* this will apply to all <p> elements belonging to this
|
||||
/* this will apply to all <p> elements belonging to this
|
||||
component with a class of red, even if class="red" does
|
||||
not initially appear in the markup, and is instead
|
||||
added at runtime. This is useful when the class
|
||||
of the element is dynamically applied, for instance
|
||||
not initially appear in the markup, and is instead
|
||||
added at runtime. This is useful when the class
|
||||
of the element is dynamically applied, for instance
|
||||
when updating the element's classList property directly. */
|
||||
}
|
||||
</style>
|
||||
@ -352,9 +351,11 @@ If you want to make @keyframes that are accessible globally, you need to prepend
|
||||
|
||||
The `-global-` part will be removed when compiled, and the keyframe then be referenced using just `my-animation-name` elsewhere in your code.
|
||||
|
||||
```html
|
||||
```svelte
|
||||
<style>
|
||||
@keyframes -global-my-animation-name {...}
|
||||
@keyframes -global-my-animation-name {
|
||||
/* code goes here */
|
||||
}
|
||||
</style>
|
||||
```
|
||||
|
||||
@ -366,7 +367,7 @@ However, it is possible to have `<style>` tag nested inside other elements or lo
|
||||
|
||||
In that case, the `<style>` tag will be inserted as-is into the DOM, no scoping or processing will be done on the `<style>` tag.
|
||||
|
||||
```html
|
||||
```svelte
|
||||
<div>
|
||||
<style>
|
||||
/* this style tag will be inserted as-is */
|
||||
|
@ -2,12 +2,11 @@
|
||||
title: Template syntax
|
||||
---
|
||||
|
||||
|
||||
### Tags
|
||||
|
||||
---
|
||||
|
||||
A lowercase tag, like `<div>`, denotes a regular HTML element. A capitalised tag, such as `<Widget>` or `<Namespace.Widget>`, indicates a *component*.
|
||||
A lowercase tag, like `<div>`, denotes a regular HTML element. A capitalised tag, such as `<Widget>` or `<Namespace.Widget>`, indicates a _component_.
|
||||
|
||||
```sv
|
||||
<script>
|
||||
@ -19,7 +18,6 @@ A lowercase tag, like `<div>`, denotes a regular HTML element. A capitalised tag
|
||||
</div>
|
||||
```
|
||||
|
||||
|
||||
### Attributes and props
|
||||
|
||||
---
|
||||
@ -50,7 +48,7 @@ Attribute values can contain JavaScript expressions.
|
||||
|
||||
---
|
||||
|
||||
Or they can *be* JavaScript expressions.
|
||||
Or they can _be_ JavaScript expressions.
|
||||
|
||||
```sv
|
||||
<button disabled={!clickable}>...</button>
|
||||
@ -62,8 +60,8 @@ Boolean attributes are included on the element if their value is [truthy](https:
|
||||
|
||||
All other attributes are included unless their value is [nullish](https://developer.mozilla.org/en-US/docs/Glossary/Nullish) (`null` or `undefined`).
|
||||
|
||||
```html
|
||||
<input required={false} placeholder="This input field is not required">
|
||||
```svelte
|
||||
<input required={false} placeholder="This input field is not required" />
|
||||
<div title={null}>This div has no title attribute</div>
|
||||
```
|
||||
|
||||
@ -87,7 +85,7 @@ When the attribute name and value match (`name={name}`), they can be replaced wi
|
||||
|
||||
---
|
||||
|
||||
By convention, values passed to components are referred to as *properties* or *props* rather than *attributes*, which are a feature of the DOM.
|
||||
By convention, values passed to components are referred to as _properties_ or _props_ rather than _attributes_, which are a feature of the DOM.
|
||||
|
||||
As with elements, `name={name}` can be replaced with the `{name}` shorthand.
|
||||
|
||||
@ -97,7 +95,7 @@ As with elements, `name={name}` can be replaced with the `{name}` shorthand.
|
||||
|
||||
---
|
||||
|
||||
*Spread attributes* allow many attributes or properties to be passed to an element or component at once.
|
||||
_Spread attributes_ allow many attributes or properties to be passed to an element or component at once.
|
||||
|
||||
An element or component can have multiple spread attributes, interspersed with regular ones.
|
||||
|
||||
@ -107,7 +105,7 @@ An element or component can have multiple spread attributes, interspersed with r
|
||||
|
||||
---
|
||||
|
||||
*`$$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.
|
||||
_`$$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.
|
||||
|
||||
```sv
|
||||
<Widget {...$$props}/>
|
||||
@ -115,13 +113,12 @@ An element or component can have multiple spread attributes, interspersed with r
|
||||
|
||||
---
|
||||
|
||||
*`$$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.
|
||||
_`$$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.
|
||||
|
||||
```html
|
||||
<input {...$$restProps}>
|
||||
```svelte
|
||||
<input {...$$restProps} />
|
||||
```
|
||||
|
||||
|
||||
> The `value` attribute of an `input` element or its children `option` elements must not be set with spread attributes when using `bind:group` or `bind:checked`. Svelte needs to be able to see the element's `value` directly in the markup in these cases so that it can link it to the bound variable.
|
||||
|
||||
> Sometimes, the attribute order matters as Svelte sets attributes sequentially in JavaScript. For example, `<input type="range" min="0" max="1" value={0.5} step="0.1"/>`, Svelte will attempt to set the value to `1` (rounding up from 0.5 as the step by default is 1), and then set the step to `0.1`. To fix this, change it to `<input type="range" min="0" max="1" step="0.1" value={0.5}/>`.
|
||||
@ -169,15 +166,16 @@ Comments beginning with `svelte-ignore` disable warnings for the next block of m
|
||||
<input bind:value={name} autofocus>
|
||||
```
|
||||
|
||||
|
||||
### {#if ...}
|
||||
|
||||
```sv
|
||||
{#if expression}...{/if}
|
||||
```
|
||||
|
||||
```sv
|
||||
{#if expression}...{:else if expression}...{/if}
|
||||
```
|
||||
|
||||
```sv
|
||||
{#if expression}...{:else}...{/if}
|
||||
```
|
||||
@ -213,15 +211,19 @@ Additional conditions can be added with `{:else if expression}`, optionally endi
|
||||
```sv
|
||||
{#each expression as name}...{/each}
|
||||
```
|
||||
|
||||
```sv
|
||||
{#each expression as name, index}...{/each}
|
||||
```
|
||||
|
||||
```sv
|
||||
{#each expression as name (key)}...{/each}
|
||||
```
|
||||
|
||||
```sv
|
||||
{#each expression as name, index (key)}...{/each}
|
||||
```
|
||||
|
||||
```sv
|
||||
{#each expression as name}...{:else}...{/each}
|
||||
```
|
||||
@ -243,7 +245,7 @@ You can use each blocks to iterate over any array or array-like value — that i
|
||||
|
||||
---
|
||||
|
||||
An each block can also specify an *index*, equivalent to the second argument in an `array.map(...)` callback:
|
||||
An each block can also specify an _index_, equivalent to the second argument in an `array.map(...)` callback:
|
||||
|
||||
```sv
|
||||
{#each items as item, i}
|
||||
@ -253,7 +255,7 @@ An each block can also specify an *index*, equivalent to the second argument in
|
||||
|
||||
---
|
||||
|
||||
If a *key* expression is provided — which must uniquely identify each list item — Svelte will use it to diff the list when data changes, rather than adding or removing items at the end. The key can be any object, but strings and numbers are recommended since they allow identity to persist when the objects themselves change.
|
||||
If a _key_ expression is provided — which must uniquely identify each list item — Svelte will use it to diff the list when data changes, rather than adding or removing items at the end. The key can be any object, but strings and numbers are recommended since they allow identity to persist when the objects themselves change.
|
||||
|
||||
```sv
|
||||
{#each items as item (item.id)}
|
||||
@ -296,18 +298,20 @@ An each block can also have an `{:else}` clause, which is rendered if the list i
|
||||
{/each}
|
||||
```
|
||||
|
||||
|
||||
### {#await ...}
|
||||
|
||||
```sv
|
||||
{#await expression}...{:then name}...{:catch name}...{/await}
|
||||
```
|
||||
|
||||
```sv
|
||||
{#await expression}...{:then name}...{/await}
|
||||
```
|
||||
|
||||
```sv
|
||||
{#await expression then name}...{/await}
|
||||
```
|
||||
|
||||
```sv
|
||||
{#await expression catch name}...{/await}
|
||||
```
|
||||
@ -401,7 +405,7 @@ When used around components, this will cause them to be reinstantiated and reini
|
||||
|
||||
In a text expression, characters like `<` and `>` are escaped; however, with HTML expressions, they're not.
|
||||
|
||||
The expression should be valid standalone HTML — `{@html "<div>"}content{@html "</div>"}` will *not* work, because `</div>` is not valid HTML. It also will *not* compile Svelte code.
|
||||
The expression should be valid standalone HTML — `{@html "<div>"}content{@html "</div>"}` will _not_ work, because `</div>` is not valid HTML. It also will _not_ compile Svelte code.
|
||||
|
||||
> Svelte does not sanitize expressions before injecting HTML. If the data comes from an untrusted source, you must sanitize it, or you are exposing your users to an XSS vulnerability.
|
||||
|
||||
@ -412,12 +416,12 @@ The expression should be valid standalone HTML — `{@html "<div>"}content{@html
|
||||
</div>
|
||||
```
|
||||
|
||||
|
||||
### {@debug ...}
|
||||
|
||||
```sv
|
||||
{@debug}
|
||||
```
|
||||
|
||||
```sv
|
||||
{@debug var1, var2, ..., varN}
|
||||
```
|
||||
@ -455,8 +459,7 @@ The `{@debug ...}` tag offers an alternative to `console.log(...)`. It logs the
|
||||
{@debug typeof user === 'object'}
|
||||
```
|
||||
|
||||
The `{@debug}` tag without any arguments will insert a `debugger` statement that gets triggered when *any* state changes, as opposed to the specified variables.
|
||||
|
||||
The `{@debug}` tag without any arguments will insert a `debugger` statement that gets triggered when _any_ state changes, as opposed to the specified variables.
|
||||
|
||||
### {@const ...}
|
||||
|
||||
@ -481,17 +484,16 @@ The `{@const ...}` tag defines a local constant.
|
||||
|
||||
`{@const}` is only allowed as direct child of `{#if}`, `{:else if}`, `{:else}`, `{#each}`, `{:then}`, `{:catch}`, `<Component />` or `<svelte:fragment />`.
|
||||
|
||||
|
||||
### Element directives
|
||||
|
||||
As well as attributes, elements can have *directives*, which control the element's behaviour in some way.
|
||||
As well as attributes, elements can have _directives_, which control the element's behaviour in some way.
|
||||
|
||||
|
||||
#### on:*eventname*
|
||||
#### on:_eventname_
|
||||
|
||||
```sv
|
||||
on:eventname={handler}
|
||||
```
|
||||
|
||||
```sv
|
||||
on:eventname|modifiers={handler}
|
||||
```
|
||||
@ -526,7 +528,7 @@ Handlers can be declared inline with no performance penalty. As with attributes,
|
||||
|
||||
---
|
||||
|
||||
Add *modifiers* to DOM events with the `|` character.
|
||||
Add _modifiers_ to DOM events with the `|` character.
|
||||
|
||||
```sv
|
||||
<form on:submit|preventDefault={handleSubmit}>
|
||||
@ -537,21 +539,21 @@ Add *modifiers* to DOM events with the `|` character.
|
||||
|
||||
The following modifiers are available:
|
||||
|
||||
* `preventDefault` — calls `event.preventDefault()` before running the handler
|
||||
* `stopPropagation` — calls `event.stopPropagation()`, preventing the event reaching the next element
|
||||
* `stopImmediatePropagation` - calls `event.stopImmediatePropagation()`, preventing other listeners of the same event from being fired.
|
||||
* `passive` — improves scrolling performance on touch/wheel events (Svelte will add it automatically where it's safe to do so)
|
||||
* `nonpassive` — explicitly set `passive: false`
|
||||
* `capture` — fires the handler during the *capture* phase instead of the *bubbling* phase
|
||||
* `once` — remove the handler after the first time it runs
|
||||
* `self` — only trigger handler if `event.target` is the element itself
|
||||
* `trusted` — only trigger handler if `event.isTrusted` is `true`. I.e. if the event is triggered by a user action.
|
||||
- `preventDefault` — calls `event.preventDefault()` before running the handler
|
||||
- `stopPropagation` — calls `event.stopPropagation()`, preventing the event reaching the next element
|
||||
- `stopImmediatePropagation` - calls `event.stopImmediatePropagation()`, preventing other listeners of the same event from being fired.
|
||||
- `passive` — improves scrolling performance on touch/wheel events (Svelte will add it automatically where it's safe to do so)
|
||||
- `nonpassive` — explicitly set `passive: false`
|
||||
- `capture` — fires the handler during the _capture_ phase instead of the _bubbling_ phase
|
||||
- `once` — remove the handler after the first time it runs
|
||||
- `self` — only trigger handler if `event.target` is the element itself
|
||||
- `trusted` — only trigger handler if `event.isTrusted` is `true`. I.e. if the event is triggered by a user action.
|
||||
|
||||
Modifiers can be chained together, e.g. `on:click|once|capture={...}`.
|
||||
|
||||
---
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
```sv
|
||||
<button on:click>
|
||||
@ -578,7 +580,7 @@ It's possible to have multiple event listeners for the same event:
|
||||
<button on:click={increment} on:click={track}>Click me!</button>
|
||||
```
|
||||
|
||||
#### bind:*property*
|
||||
#### bind:_property_
|
||||
|
||||
```sv
|
||||
bind:property={variable}
|
||||
@ -692,6 +694,7 @@ When the value of an `<option>` matches its text content, the attribute can be o
|
||||
---
|
||||
|
||||
Elements with the `contenteditable` attribute support the following bindings:
|
||||
|
||||
- [`innerHTML`](https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML)
|
||||
- [`innerText`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/innerText)
|
||||
- [`textContent`](https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent)
|
||||
@ -719,23 +722,23 @@ There are slight differences between each of these, read more about them [here](
|
||||
|
||||
---
|
||||
|
||||
Media elements (`<audio>` and `<video>`) have their own set of bindings — seven *readonly* ones...
|
||||
Media elements (`<audio>` and `<video>`) have their own set of bindings — seven _readonly_ ones...
|
||||
|
||||
* `duration` (readonly) — the total duration of the video, in seconds
|
||||
* `buffered` (readonly) — an array of `{start, end}` objects
|
||||
* `played` (readonly) — ditto
|
||||
* `seekable` (readonly) — ditto
|
||||
* `seeking` (readonly) — boolean
|
||||
* `ended` (readonly) — boolean
|
||||
* `readyState` (readonly) — number between (and including) 0 and 4
|
||||
- `duration` (readonly) — the total duration of the video, in seconds
|
||||
- `buffered` (readonly) — an array of `{start, end}` objects
|
||||
- `played` (readonly) — ditto
|
||||
- `seekable` (readonly) — ditto
|
||||
- `seeking` (readonly) — boolean
|
||||
- `ended` (readonly) — boolean
|
||||
- `readyState` (readonly) — number between (and including) 0 and 4
|
||||
|
||||
...and five *two-way* bindings:
|
||||
...and five _two-way_ bindings:
|
||||
|
||||
* `currentTime` — the current playback time in the video, in seconds
|
||||
* `playbackRate` — how fast or slow to play the video, where 1 is 'normal'
|
||||
* `paused` — this one should be self-explanatory
|
||||
* `volume` — a value between 0 and 1
|
||||
* `muted` — a boolean value indicating whether the player is muted
|
||||
- `currentTime` — the current playback time in the video, in seconds
|
||||
- `playbackRate` — how fast or slow to play the video, where 1 is 'normal'
|
||||
- `paused` — this one should be self-explanatory
|
||||
- `volume` — a value between 0 and 1
|
||||
- `muted` — a boolean value indicating whether the player is muted
|
||||
|
||||
Videos additionally have readonly `videoWidth` and `videoHeight` bindings.
|
||||
|
||||
@ -765,8 +768,8 @@ Videos additionally have readonly `videoWidth` and `videoHeight` bindings.
|
||||
|
||||
Image elements (`<img>`) have two readonly bindings:
|
||||
|
||||
* `naturalWidth` (readonly) — the original width of the image, available after the image has loaded
|
||||
* `naturalHeight` (readonly) — the original height of the image, available after the image has loaded
|
||||
- `naturalWidth` (readonly) — the original width of the image, available after the image has loaded
|
||||
- `naturalHeight` (readonly) — the original height of the image, available after the image has loaded
|
||||
|
||||
```sv
|
||||
<img
|
||||
@ -781,10 +784,10 @@ Image elements (`<img>`) have two readonly bindings:
|
||||
|
||||
Block-level elements have 4 read-only bindings, measured using a technique similar to [this one](http://www.backalleycoder.com/2013/03/18/cross-browser-event-based-element-resize-detection/):
|
||||
|
||||
* `clientWidth`
|
||||
* `clientHeight`
|
||||
* `offsetWidth`
|
||||
* `offsetHeight`
|
||||
- `clientWidth`
|
||||
- `clientHeight`
|
||||
- `offsetWidth`
|
||||
- `offsetHeight`
|
||||
|
||||
```sv
|
||||
<div
|
||||
@ -848,12 +851,12 @@ To get a reference to a DOM node, use `bind:this`.
|
||||
<canvas bind:this={canvasElement}></canvas>
|
||||
```
|
||||
|
||||
|
||||
#### class:*name*
|
||||
#### class:_name_
|
||||
|
||||
```sv
|
||||
class:name={value}
|
||||
```
|
||||
|
||||
```sv
|
||||
class:name
|
||||
```
|
||||
@ -874,14 +877,16 @@ A `class:` directive provides a shorter way of toggling a class on an element.
|
||||
<div class:active class:inactive={!active} class:isAdmin>...</div>
|
||||
```
|
||||
|
||||
#### style:*property*
|
||||
#### style:_property_
|
||||
|
||||
```sv
|
||||
style:property={value}
|
||||
```
|
||||
|
||||
```sv
|
||||
style:property="value"
|
||||
```
|
||||
|
||||
```sv
|
||||
style:property
|
||||
```
|
||||
@ -916,13 +921,12 @@ When `style:` directives are combined with `style` attributes, the directives wi
|
||||
<div style="color: blue;" style:color="red">This will be red</div>
|
||||
```
|
||||
|
||||
|
||||
|
||||
#### use:*action*
|
||||
#### use:_action_
|
||||
|
||||
```sv
|
||||
use:action
|
||||
```
|
||||
|
||||
```sv
|
||||
use:action={parameters}
|
||||
```
|
||||
@ -982,23 +986,24 @@ An action can have a parameter. If the returned value has an `update` method, it
|
||||
<div use:foo={bar}></div>
|
||||
```
|
||||
|
||||
|
||||
#### transition:*fn*
|
||||
#### transition:_fn_
|
||||
|
||||
```sv
|
||||
transition:fn
|
||||
```
|
||||
|
||||
```sv
|
||||
transition:fn={params}
|
||||
```
|
||||
|
||||
```sv
|
||||
transition:fn|local
|
||||
```
|
||||
|
||||
```sv
|
||||
transition:fn|local={params}
|
||||
```
|
||||
|
||||
|
||||
```js
|
||||
transition = (node: HTMLElement, params: any, options: { direction: 'in' | 'out' | 'both' }) => {
|
||||
delay?: number,
|
||||
@ -1015,7 +1020,7 @@ A transition is triggered by an element entering or leaving the DOM as a result
|
||||
|
||||
When a block is transitioning out, all elements inside the block, including those that do not have their own transitions, are kept in the DOM until every transition in the block has been completed.
|
||||
|
||||
The `transition:` directive indicates a *bidirectional* transition, which means it can be smoothly reversed while the transition is in progress.
|
||||
The `transition:` directive indicates a _bidirectional_ transition, which means it can be smoothly reversed while the transition is in progress.
|
||||
|
||||
```sv
|
||||
{#if visible}
|
||||
@ -1025,7 +1030,7 @@ The `transition:` directive indicates a *bidirectional* transition, which means
|
||||
{/if}
|
||||
```
|
||||
|
||||
> By default intro transitions will not play on first render. You can modify this behaviour by setting `intro: true` when you [create a component](/docs#run-time-client-side-component-api).
|
||||
> By default intro transitions will not play on first render. You can modify this behaviour by setting `intro: true` when you [create a component](/docs/run-time#client-side-component-api).
|
||||
|
||||
##### Transition parameters
|
||||
|
||||
@ -1049,9 +1054,9 @@ Like actions, transitions can have parameters.
|
||||
|
||||
Transitions can use custom functions. If the returned object has a `css` function, Svelte will create a CSS animation that plays on the element.
|
||||
|
||||
The `t` argument passed to `css` is a value between `0` and `1` after the `easing` function has been applied. *In* transitions run from `0` to `1`, *out* transitions run from `1` to `0` — in other words, `1` is the element's natural state, as though no transition had been applied. The `u` argument is equal to `1 - t`.
|
||||
The `t` argument passed to `css` is a value between `0` and `1` after the `easing` function has been applied. _In_ transitions run from `0` to `1`, _out_ transitions run from `1` to `0` — in other words, `1` is the element's natural state, as though no transition had been applied. The `u` argument is equal to `1 - t`.
|
||||
|
||||
The function is called repeatedly *before* the transition begins, with different `t` and `u` arguments.
|
||||
The function is called repeatedly _before_ the transition begins, with different `t` and `u` arguments.
|
||||
|
||||
```sv
|
||||
<script>
|
||||
@ -1080,7 +1085,7 @@ The function is called repeatedly *before* the transition begins, with different
|
||||
|
||||
---
|
||||
|
||||
A custom transition function can also return a `tick` function, which is called *during* the transition with the same `t` and `u` arguments.
|
||||
A custom transition function can also return a `tick` function, which is called _during_ the transition with the same `t` and `u` arguments.
|
||||
|
||||
> If it's possible to use `css` instead of `tick`, do so — CSS animations can run off the main thread, preventing jank on slower devices.
|
||||
|
||||
@ -1124,7 +1129,7 @@ Transition functions also receive a third argument, `options`, which contains in
|
||||
|
||||
Available values in the `options` object are:
|
||||
|
||||
* `direction` - one of `in`, `out`, or `both` depending on the type of transition
|
||||
- `direction` - one of `in`, `out`, or `both` depending on the type of transition
|
||||
|
||||
##### Transition events
|
||||
|
||||
@ -1132,10 +1137,10 @@ Available values in the `options` object are:
|
||||
|
||||
An element with transitions will dispatch the following events in addition to any standard DOM events:
|
||||
|
||||
* `introstart`
|
||||
* `introend`
|
||||
* `outrostart`
|
||||
* `outroend`
|
||||
- `introstart`
|
||||
- `introend`
|
||||
- `outrostart`
|
||||
- `outroend`
|
||||
|
||||
```sv
|
||||
{#if visible}
|
||||
@ -1153,7 +1158,7 @@ An element with transitions will dispatch the following events in addition to an
|
||||
|
||||
---
|
||||
|
||||
Local transitions only play when the block they belong to is created or destroyed, *not* when parent blocks are created or destroyed.
|
||||
Local transitions only play when the block they belong to is created or destroyed, _not_ when parent blocks are created or destroyed.
|
||||
|
||||
```sv
|
||||
{#if x}
|
||||
@ -1169,18 +1174,20 @@ Local transitions only play when the block they belong to is created or destroye
|
||||
{/if}
|
||||
```
|
||||
|
||||
|
||||
#### in:*fn*/out:*fn*
|
||||
#### in:_fn_/out:_fn_
|
||||
|
||||
```sv
|
||||
in:fn
|
||||
```
|
||||
|
||||
```sv
|
||||
in:fn={params}
|
||||
```
|
||||
|
||||
```sv
|
||||
in:fn|local
|
||||
```
|
||||
|
||||
```sv
|
||||
in:fn|local={params}
|
||||
```
|
||||
@ -1188,12 +1195,15 @@ in:fn|local={params}
|
||||
```sv
|
||||
out:fn
|
||||
```
|
||||
|
||||
```sv
|
||||
out:fn={params}
|
||||
```
|
||||
|
||||
```sv
|
||||
out:fn|local
|
||||
```
|
||||
|
||||
```sv
|
||||
out:fn|local={params}
|
||||
```
|
||||
@ -1212,9 +1222,7 @@ Unlike with `transition:`, transitions applied with `in:` and `out:` are not bid
|
||||
{/if}
|
||||
```
|
||||
|
||||
|
||||
|
||||
#### animate:*fn*
|
||||
#### animate:_fn_
|
||||
|
||||
```sv
|
||||
animate:name
|
||||
@ -1249,9 +1257,9 @@ DOMRect {
|
||||
|
||||
---
|
||||
|
||||
An animation is triggered when the contents of a [keyed each block](/docs#template-syntax-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.
|
||||
An animation is triggered when the contents of a [keyed each block](/docs/template-syntax#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.
|
||||
|
||||
Animations can be used with Svelte's [built-in animation functions](/docs#run-time-svelte-animate) or [custom animation functions](/docs#template-syntax-element-directives-animate-fn-custom-animation-functions).
|
||||
Animations can be used with Svelte's [built-in animation functions](/docs/run-time#svelte-animate) or [custom animation functions](/docs/template-syntax#element-directives-animate-fn-custom-animation-functions).
|
||||
|
||||
```sv
|
||||
<!-- When `list` is reordered the animation will run-->
|
||||
@ -1284,8 +1292,7 @@ If the returned object has a `css` method, Svelte will create a CSS animation th
|
||||
|
||||
The `t` argument passed to `css` is a value that goes from `0` and `1` after the `easing` function has been applied. The `u` argument is equal to `1 - t`.
|
||||
|
||||
The function is called repeatedly *before* the animation begins, with different `t` and `u` arguments.
|
||||
|
||||
The function is called repeatedly _before_ the animation begins, with different `t` and `u` arguments.
|
||||
|
||||
```sv
|
||||
<script>
|
||||
@ -1315,8 +1322,7 @@ The function is called repeatedly *before* the animation begins, with different
|
||||
|
||||
---
|
||||
|
||||
|
||||
A custom animation function can also return a `tick` function, which is called *during* the animation with the same `t` and `u` arguments.
|
||||
A custom animation function can also return a `tick` function, which is called _during_ the animation with the same `t` and `u` arguments.
|
||||
|
||||
> If it's possible to use `css` instead of `tick`, do so — CSS animations can run off the main thread, preventing jank on slower devices.
|
||||
|
||||
@ -1348,7 +1354,7 @@ A custom animation function can also return a `tick` function, which is called *
|
||||
|
||||
### Component directives
|
||||
|
||||
#### on:*eventname*
|
||||
#### on:_eventname_
|
||||
|
||||
```sv
|
||||
on:eventname={handler}
|
||||
@ -1356,7 +1362,7 @@ on:eventname={handler}
|
||||
|
||||
---
|
||||
|
||||
Components can emit events using [createEventDispatcher](/docs#run-time-svelte-createeventdispatcher), or by forwarding DOM events. Listening for component events looks the same as listening for DOM events:
|
||||
Components can emit events using [createEventDispatcher](/docs/run-time#svelte-createeventdispatcher), or by forwarding DOM events. Listening for component events looks the same as listening for DOM events:
|
||||
|
||||
```sv
|
||||
<SomeComponent on:whatever={handler}/>
|
||||
@ -1364,7 +1370,7 @@ Components can emit events using [createEventDispatcher](/docs#run-time-svelte-c
|
||||
|
||||
---
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
```sv
|
||||
<SomeComponent on:whatever/>
|
||||
@ -1443,7 +1449,7 @@ So you can set a high-level theme color:
|
||||
```css
|
||||
/* global.css */
|
||||
html {
|
||||
--theme-color: black;
|
||||
--theme-color: black;
|
||||
}
|
||||
```
|
||||
|
||||
@ -1455,7 +1461,7 @@ Or override it at the consumer level:
|
||||
<Slider --rail-color="goldenrod"/>
|
||||
```
|
||||
|
||||
#### bind:*property*
|
||||
#### bind:_property_
|
||||
|
||||
```sv
|
||||
bind:property={variable}
|
||||
@ -1489,16 +1495,16 @@ Components also support `bind:this`, allowing you to interact with component ins
|
||||
</button>
|
||||
```
|
||||
|
||||
|
||||
|
||||
### `<slot>`
|
||||
|
||||
```sv
|
||||
<slot><!-- optional fallback --></slot>
|
||||
```
|
||||
|
||||
```sv
|
||||
<slot name="x"><!-- optional fallback --></slot>
|
||||
```
|
||||
|
||||
```sv
|
||||
<slot prop={value}></slot>
|
||||
```
|
||||
@ -1527,7 +1533,9 @@ The content is exposed in the child component using the `<slot>` element, which
|
||||
|
||||
Note: If you want to render regular `<slot>` element, You can use `<svelte:element this="slot" />`.
|
||||
|
||||
#### `<slot name="`*name*`">`
|
||||
Note: If you want to render regular `<slot>` element, You can use `<svelte:element this="slot" />`.
|
||||
|
||||
#### `<slot name="`_name_`">`
|
||||
|
||||
---
|
||||
|
||||
@ -1569,7 +1577,6 @@ In order to place content in a slot without using a wrapper element, you can use
|
||||
</Widget>
|
||||
```
|
||||
|
||||
|
||||
#### `$$slots`
|
||||
|
||||
---
|
||||
@ -1596,11 +1603,11 @@ Note that explicitly passing in an empty named slot will add that slot's name to
|
||||
</Card>
|
||||
```
|
||||
|
||||
#### `<slot key={`*value*`}>`
|
||||
#### `<slot key={`_value_`}>`
|
||||
|
||||
---
|
||||
|
||||
Slots can be rendered zero or more times and can pass values *back* to the parent using props. The parent exposes the values to the slot template using the `let:` directive.
|
||||
Slots can be rendered zero or more times and can pass values _back_ to the parent using props. The parent exposes the values to the slot template using the `let:` directive.
|
||||
|
||||
The usual shorthand rules apply — `let:item` is equivalent to `let:item={item}`, and `<slot {item}>` is equivalent to `<slot item={item}>`.
|
||||
|
||||
@ -1643,7 +1650,6 @@ Named slots can also expose values. The `let:` directive goes on the element wit
|
||||
</FancyList>
|
||||
```
|
||||
|
||||
|
||||
### `<svelte:self>`
|
||||
|
||||
---
|
||||
@ -1711,6 +1717,7 @@ If `this` is the name of a [void element](https://developer.mozilla.org/en-US/do
|
||||
```sv
|
||||
<svelte:window on:event={handler}/>
|
||||
```
|
||||
|
||||
```sv
|
||||
<svelte:window bind:prop={value}/>
|
||||
```
|
||||
@ -1735,13 +1742,13 @@ Unlike `<svelte:self>`, this element may only appear at the top level of your co
|
||||
|
||||
You can also bind to the following properties:
|
||||
|
||||
* `innerWidth`
|
||||
* `innerHeight`
|
||||
* `outerWidth`
|
||||
* `outerHeight`
|
||||
* `scrollX`
|
||||
* `scrollY`
|
||||
* `online` — an alias for `window.navigator.onLine`
|
||||
- `innerWidth`
|
||||
- `innerHeight`
|
||||
- `outerWidth`
|
||||
- `outerHeight`
|
||||
- `scrollX`
|
||||
- `scrollY`
|
||||
- `online` — an alias for `window.navigator.onLine`
|
||||
|
||||
All except `scrollX` and `scrollY` are readonly.
|
||||
|
||||
@ -1759,7 +1766,7 @@ All except `scrollX` and `scrollY` are readonly.
|
||||
|
||||
---
|
||||
|
||||
Similarly to `<svelte:window>`, this element allows you to add listeners to events on `document`, such as `visibilitychange`, which don't fire on `window`. It also lets you use [actions](/docs#template-syntax-element-directives-use-action) on `document`.
|
||||
Similarly to `<svelte:window>`, this element allows you to add listeners to events on `document`, such as `visibilitychange`, which don't fire on `window`. It also lets you use [actions](/docs/template-syntax#element-directives-use-action) on `document`.
|
||||
|
||||
As with `<svelte:window>`, this element may only appear the top level of your component and must never be inside a block or element.
|
||||
|
||||
@ -1778,7 +1785,7 @@ As with `<svelte:window>`, this element may only appear the top level of your co
|
||||
|
||||
---
|
||||
|
||||
Similarly to `<svelte:window>`, this element allows you to add listeners to events on `document.body`, such as `mouseenter` and `mouseleave`, which don't fire on `window`. It also lets you use [actions](/docs#template-syntax-element-directives-use-action) on the `<body>` element.
|
||||
Similarly to `<svelte:window>`, this element allows you to add listeners to events on `document.body`, such as `mouseenter` and `mouseleave`, which don't fire on `window`. It also lets you use [actions](/docs/template-syntax#element-directives-use-action) on the `<body>` element.
|
||||
|
||||
As with `<svelte:window>` and `<svelte:document>`, this element may only appear the top level of your component and must never be inside a block or element.
|
||||
|
||||
@ -1790,7 +1797,6 @@ As with `<svelte:window>` and `<svelte:document>`, this element may only appear
|
||||
/>
|
||||
```
|
||||
|
||||
|
||||
### `<svelte:head>`
|
||||
|
||||
```sv
|
||||
@ -1809,7 +1815,6 @@ As with `<svelte:window>`, `<svelte:document>` and `<svelte:body>`, this element
|
||||
</svelte:head>
|
||||
```
|
||||
|
||||
|
||||
### `<svelte:options>`
|
||||
|
||||
```sv
|
||||
@ -1818,14 +1823,14 @@ As with `<svelte:window>`, `<svelte:document>` and `<svelte:body>`, this element
|
||||
|
||||
---
|
||||
|
||||
The `<svelte:options>` element provides a place to specify per-component compiler options, which are detailed in the [compiler section](/docs#compile-time-svelte-compile). The possible options are:
|
||||
The `<svelte:options>` element provides a place to specify per-component compiler options, which are detailed in the [compiler section](/docs/compile-time#svelte-compile). The possible options are:
|
||||
|
||||
* `immutable={true}` — you never use mutable data, so the compiler can do simple referential equality checks to determine if values have changed
|
||||
* `immutable={false}` — the default. Svelte will be more conservative about whether or not mutable objects have changed
|
||||
* `accessors={true}` — adds getters and setters for the component's props
|
||||
* `accessors={false}` — the default
|
||||
* `namespace="..."` — the namespace where this component will be used, most commonly "svg"; use the "foreign" namespace to opt out of case-insensitive attribute names and HTML-specific warnings
|
||||
* `tag="..."` — the name to use when compiling this component as a custom element
|
||||
- `immutable={true}` — you never use mutable data, so the compiler can do simple referential equality checks to determine if values have changed
|
||||
- `immutable={false}` — the default. Svelte will be more conservative about whether or not mutable objects have changed
|
||||
- `accessors={true}` — adds getters and setters for the component's props
|
||||
- `accessors={false}` — the default
|
||||
- `namespace="..."` — the namespace where this component will be used, most commonly "svg"; use the "foreign" namespace to opt out of case-insensitive attribute names and HTML-specific warnings
|
||||
- `tag="..."` — the name to use when compiling this component as a custom element
|
||||
|
||||
```sv
|
||||
<svelte:options tag="my-custom-element"/>
|
||||
@ -1833,7 +1838,7 @@ The `<svelte:options>` element provides a place to specify per-component compile
|
||||
|
||||
### `<svelte:fragment>`
|
||||
|
||||
The `<svelte:fragment>` element allows you to place content in a [named slot](/docs#template-syntax-slot-slot-name-name) without wrapping it in a container DOM element. This keeps the flow layout of your document intact.
|
||||
The `<svelte:fragment>` element allows you to place content in a [named slot](/docs/template-syntax#slot-slot-name-name) without wrapping it in a container DOM element. This keeps the flow layout of your document intact.
|
||||
|
||||
```sv
|
||||
<!-- Widget.svelte -->
|
||||
|
@ -2,7 +2,6 @@
|
||||
title: Run time
|
||||
---
|
||||
|
||||
|
||||
### `svelte`
|
||||
|
||||
The `svelte` package exposes [lifecycle functions](/tutorial/onmount) and the [context API](/tutorial/context-api).
|
||||
@ -12,15 +11,16 @@ The `svelte` package exposes [lifecycle functions](/tutorial/onmount) and the [c
|
||||
```js
|
||||
onMount(callback: () => void)
|
||||
```
|
||||
|
||||
```js
|
||||
onMount(callback: () => () => void)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
The `onMount` function schedules a callback to run as soon as the component has been mounted to the DOM. It must be called during the component's initialisation (but doesn't need to live *inside* the component; it can be called from an external module).
|
||||
The `onMount` function schedules a callback to run as soon as the component has been mounted to the DOM. It must be called during the component's initialisation (but doesn't need to live _inside_ the component; it can be called from an external module).
|
||||
|
||||
`onMount` does not run inside a [server-side component](/docs#run-time-server-side-component-api).
|
||||
`onMount` does not run inside a [server-side component](/docs/run-time#server-side-component-api).
|
||||
|
||||
```sv
|
||||
<script>
|
||||
@ -50,7 +50,7 @@ If a function is returned from `onMount`, it will be called when the component i
|
||||
</script>
|
||||
```
|
||||
|
||||
> This behaviour will only work when the function passed to `onMount` *synchronously* returns a value. `async` functions always return a `Promise`, and as such cannot *synchronously* return a function.
|
||||
> This behaviour will only work when the function passed to `onMount` _synchronously_ returns a value. `async` functions always return a `Promise`, and as such cannot _synchronously_ return a function.
|
||||
|
||||
#### `beforeUpdate`
|
||||
|
||||
@ -121,7 +121,7 @@ Out of `onMount`, `beforeUpdate`, `afterUpdate` and `onDestroy`, this is the onl
|
||||
#### `tick`
|
||||
|
||||
```js
|
||||
promise: Promise = tick()
|
||||
promise: Promise = tick();
|
||||
```
|
||||
|
||||
---
|
||||
@ -160,7 +160,7 @@ Like lifecycle functions, this must be called during component initialisation.
|
||||
</script>
|
||||
```
|
||||
|
||||
> Context is not inherently reactive. If you need reactive values in context then you can pass a store into context, which *will* be reactive.
|
||||
> Context is not inherently reactive. If you need reactive values in context then you can pass a store into context, which _will_ be reactive.
|
||||
|
||||
#### `getContext`
|
||||
|
||||
@ -226,7 +226,7 @@ dispatch: ((name: string, detail?: any, options?: DispatchOptions) => boolean) =
|
||||
|
||||
---
|
||||
|
||||
Creates an event dispatcher that can be used to dispatch [component events](/docs#template-syntax-component-directives-on-eventname). Event dispatchers are functions that can take two arguments: `name` and `detail`.
|
||||
Creates an event dispatcher that can be used to dispatch [component events](/docs/template-syntax#component-directives-on-eventname). Event dispatchers are functions that can take two arguments: `name` and `detail`.
|
||||
|
||||
Component events created with `createEventDispatcher` create a [CustomEvent](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent). These events do not [bubble](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/Events#Event_bubbling_and_capture). The `detail` argument corresponds to the [CustomEvent.detail](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/detail) property and can contain any type of data.
|
||||
|
||||
@ -277,17 +277,18 @@ Events can be cancelable by passing a third parameter to the dispatch function.
|
||||
|
||||
### `svelte/store`
|
||||
|
||||
The `svelte/store` module exports functions for creating [readable](/docs#run-time-svelte-store-readable), [writable](/docs#run-time-svelte-store-writable) and [derived](/docs#run-time-svelte-store-derived) stores.
|
||||
The `svelte/store` module exports functions for creating [readable](/docs/run-time#svelte-store-readable), [writable](/docs/run-time#svelte-store-writable) and [derived](/docs/run-time#svelte-store-derived) stores.
|
||||
|
||||
Keep in mind that you don't *have* to use these functions to enjoy the [reactive `$store` syntax](/docs#component-format-script-4-prefix-stores-with-$-to-access-their-values) in your components. Any object that correctly implements `.subscribe`, unsubscribe, and (optionally) `.set` is a valid store, and will work both with the special syntax, and with Svelte's built-in [`derived` stores](/docs#run-time-svelte-store-derived).
|
||||
Keep in mind that you don't _have_ to use these functions to enjoy the [reactive `$store` syntax](/docs/component-format#script-4-prefix-stores-with-$-to-access-their-values) in your components. Any object that correctly implements `.subscribe`, unsubscribe, and (optionally) `.set` is a valid store, and will work both with the special syntax, and with Svelte's built-in [`derived` stores](/docs/run-time#svelte-store-derived).
|
||||
|
||||
This makes it possible to wrap almost any other reactive state handling library for use in Svelte. Read more about the [store contract](/docs#component-format-script-4-prefix-stores-with-$-to-access-their-values-store-contract) to see what a correct implementation looks like.
|
||||
This makes it possible to wrap almost any other reactive state handling library for use in Svelte. Read more about the [store contract](/docs/component-format#script-4-prefix-stores-with-$-to-access-their-values-store-contract) to see what a correct implementation looks like.
|
||||
|
||||
#### `writable`
|
||||
|
||||
```js
|
||||
store = writable(value?: any)
|
||||
```
|
||||
|
||||
```js
|
||||
store = writable(value?: any, start?: (set: (value: any) => void) => () => void)
|
||||
```
|
||||
@ -305,13 +306,13 @@ import { writable } from 'svelte/store';
|
||||
|
||||
const count = writable(0);
|
||||
|
||||
count.subscribe(value => {
|
||||
count.subscribe((value) => {
|
||||
console.log(value);
|
||||
}); // logs '0'
|
||||
|
||||
count.set(1); // logs '1'
|
||||
|
||||
count.update(n => n + 1); // logs '2'
|
||||
count.update((n) => n + 1); // logs '2'
|
||||
```
|
||||
|
||||
---
|
||||
@ -328,7 +329,7 @@ const count = writable(0, () => {
|
||||
|
||||
count.set(1); // does nothing
|
||||
|
||||
const unsubscribe = count.subscribe(value => {
|
||||
const unsubscribe = count.subscribe((value) => {
|
||||
console.log(value);
|
||||
}); // logs 'got a subscriber', then '1'
|
||||
|
||||
@ -350,7 +351,7 @@ Creates a store whose value cannot be set from 'outside', the first argument is
|
||||
```js
|
||||
import { readable } from 'svelte/store';
|
||||
|
||||
const time = readable(null, set => {
|
||||
const time = readable(null, (set) => {
|
||||
set(new Date());
|
||||
|
||||
const interval = setInterval(() => {
|
||||
@ -366,12 +367,15 @@ const time = readable(null, set => {
|
||||
```js
|
||||
store = derived(a, callback: (a: any) => any)
|
||||
```
|
||||
|
||||
```js
|
||||
store = derived(a, callback: (a: any, set: (value: any) => void) => void | () => void, initial_value: any)
|
||||
```
|
||||
|
||||
```js
|
||||
store = derived([a, ...b], callback: ([a: any, ...b: any[]]) => any)
|
||||
```
|
||||
|
||||
```js
|
||||
store = derived([a, ...b], callback: ([a: any, ...b: any[]], set: (value: any) => void) => void | () => void, initial_value: any)
|
||||
```
|
||||
@ -385,7 +389,7 @@ In the simplest version, `derived` takes a single store, and the callback return
|
||||
```js
|
||||
import { derived } from 'svelte/store';
|
||||
|
||||
const doubled = derived(a, $a => $a * 2);
|
||||
const doubled = derived(a, ($a) => $a * 2);
|
||||
```
|
||||
|
||||
---
|
||||
@ -397,9 +401,13 @@ In this case, you can also pass a third argument to `derived` — the initial va
|
||||
```js
|
||||
import { derived } from 'svelte/store';
|
||||
|
||||
const delayed = derived(a, ($a, set) => {
|
||||
setTimeout(() => set($a), 1000);
|
||||
}, 'one moment...');
|
||||
const delayed = derived(
|
||||
a,
|
||||
($a, set) => {
|
||||
setTimeout(() => set($a), 1000);
|
||||
},
|
||||
'one moment...'
|
||||
);
|
||||
```
|
||||
|
||||
---
|
||||
@ -409,15 +417,19 @@ If you return a function from the callback, it will be called when a) the callba
|
||||
```js
|
||||
import { derived } from 'svelte/store';
|
||||
|
||||
const tick = derived(frequency, ($frequency, set) => {
|
||||
const interval = setInterval(() => {
|
||||
set(Date.now());
|
||||
}, 1000 / $frequency);
|
||||
const tick = derived(
|
||||
frequency,
|
||||
($frequency, set) => {
|
||||
const interval = setInterval(() => {
|
||||
set(Date.now());
|
||||
}, 1000 / $frequency);
|
||||
|
||||
return () => {
|
||||
clearInterval(interval);
|
||||
};
|
||||
}, 'one moment...');
|
||||
return () => {
|
||||
clearInterval(interval);
|
||||
};
|
||||
},
|
||||
'one moment...'
|
||||
);
|
||||
```
|
||||
|
||||
---
|
||||
@ -437,7 +449,7 @@ const delayed = derived([a, b], ([$a, $b], set) => {
|
||||
#### `get`
|
||||
|
||||
```js
|
||||
value: any = get(store)
|
||||
value: any = get(store);
|
||||
```
|
||||
|
||||
---
|
||||
@ -462,7 +474,6 @@ readableStore = readonly(writableStore);
|
||||
|
||||
This simple helper function makes a store readonly. You can still subscribe to the changes from the original one using this new readable store.
|
||||
|
||||
|
||||
```js
|
||||
import { readonly } from 'svelte/store';
|
||||
|
||||
@ -475,7 +486,6 @@ writableStore.set(2); // console: 2
|
||||
readableStore.set(2); // ERROR
|
||||
```
|
||||
|
||||
|
||||
### `svelte/motion`
|
||||
|
||||
The `svelte/motion` module exports two functions, `tweened` and `spring`, for creating writable stores whose values change over time after `set` and `update`, rather than immediately.
|
||||
@ -488,10 +498,10 @@ store = tweened(value: any, options)
|
||||
|
||||
Tweened stores update their values over a fixed duration. The following options are available:
|
||||
|
||||
* `delay` (`number`, default 0) — milliseconds before starting
|
||||
* `duration` (`number` | `function`, default 400) — milliseconds the tween lasts
|
||||
* `easing` (`function`, default `t => t`) — an [easing function](/docs#run-time-svelte-easing)
|
||||
* `interpolate` (`function`) — see below
|
||||
- `delay` (`number`, default 0) — milliseconds before starting
|
||||
- `duration` (`number` | `function`, default 400) — milliseconds the tween lasts
|
||||
- `easing` (`function`, default `t => t`) — an [easing function](/docs/run-time#svelte-easing)
|
||||
- `interpolate` (`function`) — see below
|
||||
|
||||
`store.set` and `store.update` can accept a second `options` argument that will override the options passed in upon instantiation.
|
||||
|
||||
@ -538,18 +548,14 @@ $: $size = big ? 100 : 10;
|
||||
|
||||
---
|
||||
|
||||
The `interpolate` option allows you to tween between *any* arbitrary values. It must be an `(a, b) => t => value` function, where `a` is the starting value, `b` is the target value, `t` is a number between 0 and 1, and `value` is the result. For example, we can use the [d3-interpolate](https://github.com/d3/d3-interpolate) package to smoothly interpolate between two colours.
|
||||
The `interpolate` option allows you to tween between _any_ arbitrary values. It must be an `(a, b) => t => value` function, where `a` is the starting value, `b` is the target value, `t` is a number between 0 and 1, and `value` is the result. For example, we can use the [d3-interpolate](https://github.com/d3/d3-interpolate) package to smoothly interpolate between two colours.
|
||||
|
||||
```sv
|
||||
```svelte
|
||||
<script>
|
||||
import { interpolateLab } from 'd3-interpolate';
|
||||
import { tweened } from 'svelte/motion';
|
||||
|
||||
const colors = [
|
||||
'rgb(255, 62, 0)',
|
||||
'rgb(64, 179, 255)',
|
||||
'rgb(103, 103, 120)'
|
||||
];
|
||||
const colors = ['rgb(255, 62, 0)', 'rgb(64, 179, 255)', 'rgb(103, 103, 120)'];
|
||||
|
||||
const color = tweened(colors[0], {
|
||||
duration: 800,
|
||||
@ -558,10 +564,9 @@ The `interpolate` option allows you to tween between *any* arbitrary values. It
|
||||
</script>
|
||||
|
||||
{#each colors as c}
|
||||
<button
|
||||
style="background-color: {c}; color: white; border: none;"
|
||||
on:click="{e => color.set(c)}"
|
||||
>{c}</button>
|
||||
<button style="background-color: {c}; color: white; border: none;" on:click={(e) => color.set(c)}>
|
||||
{c}
|
||||
</button>
|
||||
{/each}
|
||||
|
||||
<h1 style="color: {$color}">{$color}</h1>
|
||||
@ -575,9 +580,9 @@ store = spring(value: any, options)
|
||||
|
||||
A `spring` store gradually changes to its target value based on its `stiffness` and `damping` parameters. Whereas `tweened` stores change their values over a fixed duration, `spring` stores change over a duration that is determined by their existing velocity, allowing for more natural-seeming motion in many situations. The following options are available:
|
||||
|
||||
* `stiffness` (`number`, default `0.15`) — a value between 0 and 1 where higher means a 'tighter' spring
|
||||
* `damping` (`number`, default `0.8`) — a value between 0 and 1 where lower means a 'springier' spring
|
||||
* `precision` (`number`, default `0.01`) — determines the threshold at which the spring is considered to have 'settled', where lower means more precise
|
||||
- `stiffness` (`number`, default `0.15`) — a value between 0 and 1 where higher means a 'tighter' spring
|
||||
- `damping` (`number`, default `0.8`) — a value between 0 and 1 where lower means a 'springier' spring
|
||||
- `precision` (`number`, default `0.01`) — determines the threshold at which the spring is considered to have 'settled', where lower means more precise
|
||||
|
||||
---
|
||||
|
||||
@ -592,7 +597,7 @@ size.precision = 0.005;
|
||||
|
||||
---
|
||||
|
||||
As with [`tweened`](/docs#run-time-svelte-motion-tweened) stores, `set` and `update` return a Promise that resolves if the spring settles.
|
||||
As with [`tweened`](/docs/run-time#svelte-motion-tweened) stores, `set` and `update` return a Promise that resolves if the spring settles.
|
||||
|
||||
Both `set` and `update` can take a second argument — an object with `hard` or `soft` properties. `{ hard: true }` sets the target value immediately; `{ soft: n }` preserves existing momentum for `n` seconds before settling. `{ soft: true }` is equivalent to `{ soft: 0.5 }`.
|
||||
|
||||
@ -633,16 +638,18 @@ $: $size = big ? 100 : 10;
|
||||
|
||||
### `svelte/transition`
|
||||
|
||||
The `svelte/transition` module exports seven functions: `fade`, `blur`, `fly`, `slide`, `scale`, `draw` and `crossfade`. They are for use with Svelte [`transitions`](/docs#template-syntax-element-directives-transition-fn).
|
||||
The `svelte/transition` module exports seven functions: `fade`, `blur`, `fly`, `slide`, `scale`, `draw` and `crossfade`. They are for use with Svelte [`transitions`](/docs/template-syntax#element-directives-transition-fn).
|
||||
|
||||
#### `fade`
|
||||
|
||||
```sv
|
||||
transition:fade={params}
|
||||
```
|
||||
|
||||
```sv
|
||||
in:fade={params}
|
||||
```
|
||||
|
||||
```sv
|
||||
out:fade={params}
|
||||
```
|
||||
@ -653,9 +660,9 @@ Animates the opacity of an element from 0 to the current opacity for `in` transi
|
||||
|
||||
`fade` accepts the following parameters:
|
||||
|
||||
* `delay` (`number`, default 0) — milliseconds before starting
|
||||
* `duration` (`number`, default 400) — milliseconds the transition lasts
|
||||
* `easing` (`function`, default `linear`) — an [easing function](/docs#run-time-svelte-easing)
|
||||
- `delay` (`number`, default 0) — milliseconds before starting
|
||||
- `duration` (`number`, default 400) — milliseconds the transition lasts
|
||||
- `easing` (`function`, default `linear`) — an [easing function](/docs/run-time#svelte-easing)
|
||||
|
||||
You can see the `fade` transition in action in the [transition tutorial](/tutorial/transition).
|
||||
|
||||
@ -676,9 +683,11 @@ You can see the `fade` transition in action in the [transition tutorial](/tutori
|
||||
```sv
|
||||
transition:blur={params}
|
||||
```
|
||||
|
||||
```sv
|
||||
in:blur={params}
|
||||
```
|
||||
|
||||
```sv
|
||||
out:blur={params}
|
||||
```
|
||||
@ -689,11 +698,11 @@ Animates a `blur` filter alongside an element's opacity.
|
||||
|
||||
`blur` accepts the following parameters:
|
||||
|
||||
* `delay` (`number`, default 0) — milliseconds before starting
|
||||
* `duration` (`number`, default 400) — milliseconds the transition lasts
|
||||
* `easing` (`function`, default `cubicInOut`) — an [easing function](/docs#run-time-svelte-easing)
|
||||
* `opacity` (`number`, default 0) - the opacity value to animate out to and in from
|
||||
* `amount` (`number | string`, default 5) - the size of the blur. Supports css units (for example: `"4rem"`). The default unit is `px`
|
||||
- `delay` (`number`, default 0) — milliseconds before starting
|
||||
- `duration` (`number`, default 400) — milliseconds the transition lasts
|
||||
- `easing` (`function`, default `cubicInOut`) — an [easing function](/docs/run-time#svelte-easing)
|
||||
- `opacity` (`number`, default 0) - the opacity value to animate out to and in from
|
||||
- `amount` (`number | string`, default 5) - the size of the blur. Supports css units (for example: `"4rem"`). The default unit is `px`
|
||||
|
||||
```sv
|
||||
<script>
|
||||
@ -712,9 +721,11 @@ Animates a `blur` filter alongside an element's opacity.
|
||||
```sv
|
||||
transition:fly={params}
|
||||
```
|
||||
|
||||
```sv
|
||||
in:fly={params}
|
||||
```
|
||||
|
||||
```sv
|
||||
out:fly={params}
|
||||
```
|
||||
@ -725,12 +736,12 @@ Animates the x and y positions and the opacity of an element. `in` transitions a
|
||||
|
||||
`fly` accepts the following parameters:
|
||||
|
||||
* `delay` (`number`, default 0) — milliseconds before starting
|
||||
* `duration` (`number`, default 400) — milliseconds the transition lasts
|
||||
* `easing` (`function`, default `cubicOut`) — an [easing function](/docs#run-time-svelte-easing)
|
||||
* `x` (`number | string`, default 0) - the x offset to animate out to and in from
|
||||
* `y` (`number | string`, default 0) - the y offset to animate out to and in from
|
||||
* `opacity` (`number`, default 0) - the opacity value to animate out to and in from
|
||||
- `delay` (`number`, default 0) — milliseconds before starting
|
||||
- `duration` (`number`, default 400) — milliseconds the transition lasts
|
||||
- `easing` (`function`, default `cubicOut`) — an [easing function](/docs/run-time#svelte-easing)
|
||||
- `x` (`number | string`, default 0) - the x offset to animate out to and in from
|
||||
- `y` (`number | string`, default 0) - the y offset to animate out to and in from
|
||||
- `opacity` (`number`, default 0) - the opacity value to animate out to and in from
|
||||
|
||||
x and y use `px` by default but support css units, for example `x: '100vw'` or `y: '50%'`.
|
||||
You can see the `fly` transition in action in the [transition tutorial](/tutorial/adding-parameters-to-transitions).
|
||||
@ -753,9 +764,11 @@ You can see the `fly` transition in action in the [transition tutorial](/tutoria
|
||||
```sv
|
||||
transition:slide={params}
|
||||
```
|
||||
|
||||
```sv
|
||||
in:slide={params}
|
||||
```
|
||||
|
||||
```sv
|
||||
out:slide={params}
|
||||
```
|
||||
@ -766,10 +779,11 @@ Slides an element in and out.
|
||||
|
||||
`slide` accepts the following parameters:
|
||||
|
||||
* `delay` (`number`, default 0) — milliseconds before starting
|
||||
* `duration` (`number`, default 400) — milliseconds the transition lasts
|
||||
* `easing` (`function`, default `cubicOut`) — an [easing function](/docs#run-time-svelte-easing)
|
||||
- `axis` (`x` | `y`, default `y`) — the axis of motion along which the transition occurs
|
||||
- `delay` (`number`, default 0) — milliseconds before starting
|
||||
- `duration` (`number`, default 400) — milliseconds the transition lasts
|
||||
- `easing` (`function`, default `cubicOut`) — an [easing function](/docs/run-time#svelte-easing)
|
||||
|
||||
* `axis` (`x` | `y`, default `y`) — the axis of motion along which the transition occurs
|
||||
|
||||
```sv
|
||||
<script>
|
||||
@ -789,9 +803,11 @@ Slides an element in and out.
|
||||
```sv
|
||||
transition:scale={params}
|
||||
```
|
||||
|
||||
```sv
|
||||
in:scale={params}
|
||||
```
|
||||
|
||||
```sv
|
||||
out:scale={params}
|
||||
```
|
||||
@ -802,11 +818,11 @@ Animates the opacity and scale of an element. `in` transitions animate from an e
|
||||
|
||||
`scale` accepts the following parameters:
|
||||
|
||||
* `delay` (`number`, default 0) — milliseconds before starting
|
||||
* `duration` (`number`, default 400) — milliseconds the transition lasts
|
||||
* `easing` (`function`, default `cubicOut`) — an [easing function](/docs#run-time-svelte-easing)
|
||||
* `start` (`number`, default 0) - the scale value to animate out to and in from
|
||||
* `opacity` (`number`, default 0) - the opacity value to animate out to and in from
|
||||
- `delay` (`number`, default 0) — milliseconds before starting
|
||||
- `duration` (`number`, default 400) — milliseconds the transition lasts
|
||||
- `easing` (`function`, default `cubicOut`) — an [easing function](/docs/run-time#svelte-easing)
|
||||
- `start` (`number`, default 0) - the scale value to animate out to and in from
|
||||
- `opacity` (`number`, default 0) - the opacity value to animate out to and in from
|
||||
|
||||
```sv
|
||||
<script>
|
||||
@ -826,9 +842,11 @@ Animates the opacity and scale of an element. `in` transitions animate from an e
|
||||
```sv
|
||||
transition:draw={params}
|
||||
```
|
||||
|
||||
```sv
|
||||
in:draw={params}
|
||||
```
|
||||
|
||||
```sv
|
||||
out:draw={params}
|
||||
```
|
||||
@ -839,10 +857,10 @@ Animates the stroke of an SVG element, like a snake in a tube. `in` transitions
|
||||
|
||||
`draw` accepts the following parameters:
|
||||
|
||||
* `delay` (`number`, default 0) — milliseconds before starting
|
||||
* `speed` (`number`, default undefined) - the speed of the animation, see below.
|
||||
* `duration` (`number` | `function`, default 800) — milliseconds the transition lasts
|
||||
* `easing` (`function`, default `cubicInOut`) — an [easing function](/docs#run-time-svelte-easing)
|
||||
- `delay` (`number`, default 0) — milliseconds before starting
|
||||
- `speed` (`number`, default undefined) - the speed of the animation, see below.
|
||||
- `duration` (`number` | `function`, default 800) — milliseconds the transition lasts
|
||||
- `easing` (`function`, default `cubicInOut`) — an [easing function](/docs/run-time#svelte-easing)
|
||||
|
||||
The `speed` parameter is a means of setting the duration of the transition relative to the path's length. It is a modifier that is applied to the length of the path: `duration = length / speed`. A path that is 1000 pixels with a speed of 1 will have a duration of `1000ms`, setting the speed to `0.5` will double that duration and setting it to `2` will halve it.
|
||||
|
||||
@ -866,19 +884,18 @@ The `speed` parameter is a means of setting the duration of the transition relat
|
||||
|
||||
```
|
||||
|
||||
|
||||
#### `crossfade`
|
||||
|
||||
The `crossfade` function creates a pair of [transitions](/docs#template-syntax-element-directives-transition-fn) called `send` and `receive`. When an element is 'sent', it looks for a corresponding element being 'received', and generates a transition that transforms the element to its counterpart's position and fades it out. When an element is 'received', the reverse happens. If there is no counterpart, the `fallback` transition is used.
|
||||
The `crossfade` function creates a pair of [transitions](/docs/template-syntax#element-directives-transition-fn) called `send` and `receive`. When an element is 'sent', it looks for a corresponding element being 'received', and generates a transition that transforms the element to its counterpart's position and fades it out. When an element is 'received', the reverse happens. If there is no counterpart, the `fallback` transition is used.
|
||||
|
||||
---
|
||||
|
||||
`crossfade` accepts the following parameters:
|
||||
|
||||
* `delay` (`number`, default 0) — milliseconds before starting
|
||||
* `duration` (`number` | `function`, default 800) — milliseconds the transition lasts
|
||||
* `easing` (`function`, default `cubicOut`) — an [easing function](/docs#run-time-svelte-easing)
|
||||
* `fallback` (`function`) — A fallback [transition](/docs#template-syntax-element-directives-transition-fn) to use for send when there is no matching element being received, and for receive when there is no element being sent.
|
||||
- `delay` (`number`, default 0) — milliseconds before starting
|
||||
- `duration` (`number` | `function`, default 800) — milliseconds the transition lasts
|
||||
- `easing` (`function`, default `cubicOut`) — an [easing function](/docs/run-time#svelte-easing)
|
||||
- `fallback` (`function`) — A fallback [transition](/docs/template-syntax#element-directives-transition-fn) to use for send when there is no matching element being received, and for receive when there is no element being sent.
|
||||
|
||||
```sv
|
||||
<script>
|
||||
@ -898,10 +915,9 @@ The `crossfade` function creates a pair of [transitions](/docs#template-syntax-e
|
||||
{/if}
|
||||
```
|
||||
|
||||
|
||||
### `svelte/animate`
|
||||
|
||||
The `svelte/animate` module exports one function for use with Svelte [animations](/docs#template-syntax-element-directives-animate-fn).
|
||||
The `svelte/animate` module exports one function for use with Svelte [animations](/docs/template-syntax#element-directives-animate-fn).
|
||||
|
||||
#### `flip`
|
||||
|
||||
@ -913,10 +929,9 @@ The `flip` function calculates the start and end position of an element and anim
|
||||
|
||||
`flip` accepts the following parameters:
|
||||
|
||||
* `delay` (`number`, default 0) — milliseconds before starting
|
||||
* `duration` (`number` | `function`, default `d => Math.sqrt(d) * 120`) — see below
|
||||
* `easing` (`function`, default `cubicOut`) — an [easing function](/docs#run-time-svelte-easing)
|
||||
|
||||
- `delay` (`number`, default 0) — milliseconds before starting
|
||||
- `duration` (`number` | `function`, default `d => Math.sqrt(d) * 120`) — see below
|
||||
- `easing` (`function`, default `cubicOut`) — an [easing function](/docs/run-time#svelte-easing)
|
||||
|
||||
`duration` can be provided as either:
|
||||
|
||||
@ -927,7 +942,6 @@ The `flip` function calculates the start and end position of an element and anim
|
||||
|
||||
You can see a full example on the [animations tutorial](/tutorial/animate)
|
||||
|
||||
|
||||
```sv
|
||||
<script>
|
||||
import { flip } from 'svelte/animate';
|
||||
@ -943,28 +957,24 @@ You can see a full example on the [animations tutorial](/tutorial/animate)
|
||||
{/each}
|
||||
```
|
||||
|
||||
|
||||
|
||||
### `svelte/easing`
|
||||
|
||||
Easing functions specify the rate of change over time and are useful when working with Svelte's built-in transitions and animations as well as the tweened and spring utilities. `svelte/easing` contains 31 named exports, a `linear` ease and 3 variants of 10 different easing functions: `in`, `out` and `inOut`.
|
||||
|
||||
You can explore the various eases using the [ease visualiser](/examples/easing) in the [examples section](/examples).
|
||||
|
||||
|
||||
| ease | in | out | inOut |
|
||||
| --- | --- | --- | --- |
|
||||
| **back** | `backIn` | `backOut` | `backInOut` |
|
||||
| **bounce** | `bounceIn` | `bounceOut` | `bounceInOut` |
|
||||
| **circ** | `circIn` | `circOut` | `circInOut` |
|
||||
| **cubic** | `cubicIn` | `cubicOut` | `cubicInOut` |
|
||||
| ease | in | out | inOut |
|
||||
| ----------- | ----------- | ------------ | -------------- |
|
||||
| **back** | `backIn` | `backOut` | `backInOut` |
|
||||
| **bounce** | `bounceIn` | `bounceOut` | `bounceInOut` |
|
||||
| **circ** | `circIn` | `circOut` | `circInOut` |
|
||||
| **cubic** | `cubicIn` | `cubicOut` | `cubicInOut` |
|
||||
| **elastic** | `elasticIn` | `elasticOut` | `elasticInOut` |
|
||||
| **expo** | `expoIn` | `expoOut` | `expoInOut` |
|
||||
| **quad** | `quadIn` | `quadOut` | `quadInOut` |
|
||||
| **quart** | `quartIn` | `quartOut` | `quartInOut` |
|
||||
| **quint** | `quintIn` | `quintOut` | `quintInOut` |
|
||||
| **sine** | `sineIn` | `sineOut` | `sineInOut` |
|
||||
|
||||
| **expo** | `expoIn` | `expoOut` | `expoInOut` |
|
||||
| **quad** | `quadIn` | `quadOut` | `quadInOut` |
|
||||
| **quart** | `quartIn` | `quartOut` | `quartInOut` |
|
||||
| **quint** | `quintIn` | `quintOut` | `quintInOut` |
|
||||
| **sine** | `sineIn` | `sineOut` | `sineInOut` |
|
||||
|
||||
### `svelte/register`
|
||||
|
||||
@ -986,18 +996,17 @@ To set compile options, or to use a custom file extension, call the `register` h
|
||||
|
||||
```js
|
||||
require('svelte/register')({
|
||||
extensions: ['.customextension'], // defaults to ['.html', '.svelte']
|
||||
extensions: ['.customextension'], // defaults to ['.html', '.svelte']
|
||||
preserveComments: true
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
### Client-side component API
|
||||
|
||||
#### Creating a component
|
||||
|
||||
```js
|
||||
const component = new Component(options)
|
||||
const component = new Component(options);
|
||||
```
|
||||
|
||||
A client-side component — that is, a component compiled with `generate: 'dom'` (or the `generate` option left unspecified) is a JavaScript class.
|
||||
@ -1017,21 +1026,20 @@ const app = new App({
|
||||
|
||||
The following initialisation options can be provided:
|
||||
|
||||
| option | default | description |
|
||||
| --- | --- | --- |
|
||||
| `target` | **none** | An `HTMLElement` or `ShadowRoot` to render to. This option is required
|
||||
| `anchor` | `null` | A child of `target` to render the component immediately before
|
||||
| `props` | `{}` | An object of properties to supply to the component
|
||||
| `context` | `new Map()` | A `Map` of root-level context key-value pairs to supply to the component
|
||||
| `hydrate` | `false` | See below
|
||||
| `intro` | `false` | If `true`, will play transitions on initial render, rather than waiting for subsequent state changes
|
||||
| option | default | description |
|
||||
| --------- | ----------- | ---------------------------------------------------------------------------------------------------- |
|
||||
| `target` | **none** | An `HTMLElement` or `ShadowRoot` to render to. This option is required |
|
||||
| `anchor` | `null` | A child of `target` to render the component immediately before |
|
||||
| `props` | `{}` | An object of properties to supply to the component |
|
||||
| `context` | `new Map()` | A `Map` of root-level context key-value pairs to supply to the component |
|
||||
| `hydrate` | `false` | See below |
|
||||
| `intro` | `false` | If `true`, will play transitions on initial render, rather than waiting for subsequent state changes |
|
||||
|
||||
Existing children of `target` are left where they are.
|
||||
|
||||
|
||||
---
|
||||
|
||||
The `hydrate` option instructs Svelte to upgrade existing DOM (usually from server-side rendering) rather than creating new elements. It will only work if the component was compiled with the [`hydratable: true` option](/docs#compile-time-svelte-compile). Hydration of `<head>` elements only works properly if the server-side rendering code was also compiled with `hydratable: true`, which adds a marker to each element in the `<head>` so that the component knows which elements it's responsible for removing during hydration.
|
||||
The `hydrate` option instructs Svelte to upgrade existing DOM (usually from server-side rendering) rather than creating new elements. It will only work if the component was compiled with the [`hydratable: true` option](/docs/compile-time#svelte-compile). Hydration of `<head>` elements only works properly if the server-side rendering code was also compiled with `hydratable: true`, which adds a marker to each element in the `<head>` so that the component knows which elements it's responsible for removing during hydration.
|
||||
|
||||
Whereas children of `target` are normally left alone, `hydrate: true` will cause any children to be removed. For that reason, the `anchor` option cannot be used alongside `hydrate: true`.
|
||||
|
||||
@ -1049,14 +1057,14 @@ const app = new App({
|
||||
#### `$set`
|
||||
|
||||
```js
|
||||
component.$set(props)
|
||||
component.$set(props);
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Programmatically sets props on an instance. `component.$set({ x: 1 })` is equivalent to `x = 1` inside the component's `<script>` block.
|
||||
|
||||
Calling this method schedules an update for the next microtask — the DOM is *not* updated synchronously.
|
||||
Calling this method schedules an update for the next microtask — the DOM is _not_ updated synchronously.
|
||||
|
||||
```js
|
||||
component.$set({ answer: 42 });
|
||||
@ -1065,7 +1073,7 @@ component.$set({ answer: 42 });
|
||||
#### `$on`
|
||||
|
||||
```js
|
||||
component.$on(event, callback)
|
||||
component.$on(event, callback);
|
||||
```
|
||||
|
||||
---
|
||||
@ -1075,7 +1083,7 @@ Causes the `callback` function to be called whenever the component dispatches an
|
||||
A function is returned that will remove the event listener when called.
|
||||
|
||||
```js
|
||||
const off = app.$on('selected', event => {
|
||||
const off = app.$on('selected', (event) => {
|
||||
console.log(event.detail.selection);
|
||||
});
|
||||
|
||||
@ -1085,7 +1093,7 @@ off();
|
||||
#### `$destroy`
|
||||
|
||||
```js
|
||||
component.$destroy()
|
||||
component.$destroy();
|
||||
```
|
||||
|
||||
Removes a component from the DOM and triggers any `onDestroy` handlers.
|
||||
@ -1093,15 +1101,16 @@ Removes a component from the DOM and triggers any `onDestroy` handlers.
|
||||
#### Component props
|
||||
|
||||
```js
|
||||
component.prop
|
||||
component.prop;
|
||||
```
|
||||
|
||||
```js
|
||||
component.prop = value
|
||||
component.prop = value;
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
If a component is compiled with `accessors: true`, each instance will have getters and setters corresponding to each of the component's props. Setting a value will cause a *synchronous* update, rather than the default async update caused by `component.$set(...)`.
|
||||
If a component is compiled with `accessors: true`, each instance will have getters and setters corresponding to each of the component's props. Setting a value will cause a _synchronous_ update, rather than the default async update caused by `component.$set(...)`.
|
||||
|
||||
By default, `accessors` is `false`, unless you're compiling as a custom element.
|
||||
|
||||
@ -1110,12 +1119,11 @@ console.log(app.count);
|
||||
app.count += 1;
|
||||
```
|
||||
|
||||
|
||||
### Custom element API
|
||||
|
||||
---
|
||||
|
||||
Svelte components can also be compiled to custom elements (aka web components) using the `customElement: true` compiler option. You should specify a tag name for the component using the `<svelte:options>` [element](/docs#template-syntax-svelte-options).
|
||||
Svelte components can also be compiled to custom elements (aka web components) using the `customElement: true` compiler option. You should specify a tag name for the component using the `<svelte:options>` [element](/docs/template-syntax#svelte-options).
|
||||
|
||||
```sv
|
||||
<svelte:options tag="my-element" />
|
||||
@ -1152,7 +1160,7 @@ document.body.innerHTML = `
|
||||
|
||||
---
|
||||
|
||||
By default, custom elements are compiled with `accessors: true`, which means that any [props](/docs#template-syntax-attributes-and-props) are exposed as properties of the DOM element (as well as being readable/writable as attributes, where possible).
|
||||
By default, custom elements are compiled with `accessors: true`, which means that any [props](/docs/template-syntax#attributes-and-props) are exposed as properties of the DOM element (as well as being readable/writable as attributes, where possible).
|
||||
|
||||
To prevent this, add `accessors={false}` to `<svelte:options>`.
|
||||
|
||||
@ -1168,14 +1176,12 @@ el.name = 'everybody';
|
||||
|
||||
Custom elements can be a useful way to package components for consumption in a non-Svelte app, as they will work with vanilla HTML and JavaScript as well as [most frameworks](https://custom-elements-everywhere.com/). There are, however, some important differences to be aware of:
|
||||
|
||||
* Styles are *encapsulated*, rather than merely *scoped*. This means that any non-component styles (such as you might have in a `global.css` file) will not apply to the custom element, including styles with the `:global(...)` modifier
|
||||
* Instead of being extracted out as a separate .css file, styles are inlined into the component as a JavaScript string
|
||||
* Custom elements are not generally suitable for server-side rendering, as the shadow DOM is invisible until JavaScript loads
|
||||
* In Svelte, slotted content renders *lazily*. In the DOM, it renders *eagerly*. In other words, it will always be created even if the component's `<slot>` element is inside an `{#if ...}` block. Similarly, including a `<slot>` in an `{#each ...}` block will not cause the slotted content to be rendered multiple times
|
||||
* The `let:` directive has no effect
|
||||
* Polyfills are required to support older browsers
|
||||
|
||||
|
||||
- Styles are _encapsulated_, rather than merely _scoped_. This means that any non-component styles (such as you might have in a `global.css` file) will not apply to the custom element, including styles with the `:global(...)` modifier
|
||||
- Instead of being extracted out as a separate .css file, styles are inlined into the component as a JavaScript string
|
||||
- Custom elements are not generally suitable for server-side rendering, as the shadow DOM is invisible until JavaScript loads
|
||||
- In Svelte, slotted content renders _lazily_. In the DOM, it renders _eagerly_. In other words, it will always be created even if the component's `<slot>` element is inside an `{#if ...}` block. Similarly, including a `<slot>` in an `{#each ...}` block will not cause the slotted content to be rendered multiple times
|
||||
- The `let:` directive has no effect
|
||||
- Polyfills are required to support older browsers
|
||||
|
||||
### Server-side component API
|
||||
|
||||
@ -1189,7 +1195,7 @@ Unlike client-side components, server-side components don't have a lifespan afte
|
||||
|
||||
A server-side component exposes a `render` method that can be called with optional props. It returns an object with `head`, `html`, and `css` properties, where `head` contains the contents of any `<svelte:head>` elements encountered.
|
||||
|
||||
You can import a Svelte component directly into Node using [`svelte/register`](/docs#run-time-svelte-register).
|
||||
You can import a Svelte component directly into Node using [`svelte/register`](/docs/run-time#svelte-register).
|
||||
|
||||
```js
|
||||
require('svelte/register');
|
||||
@ -1205,16 +1211,16 @@ const { head, html, css } = App.render({
|
||||
|
||||
The `.render()` method accepts the following parameters:
|
||||
|
||||
| parameter | default | description |
|
||||
| --- | --- | --- |
|
||||
| `props` | `{}` | An object of properties to supply to the component
|
||||
| `options` | `{}` | An object of options
|
||||
| parameter | default | description |
|
||||
| --------- | ------- | -------------------------------------------------- |
|
||||
| `props` | `{}` | An object of properties to supply to the component |
|
||||
| `options` | `{}` | An object of options |
|
||||
|
||||
The `options` object takes in the following options:
|
||||
|
||||
| option | default | description |
|
||||
| --- | --- | --- |
|
||||
| `context` | `new Map()` | A `Map` of root-level context key-value pairs to supply to the component
|
||||
| option | default | description |
|
||||
| --------- | ----------- | ------------------------------------------------------------------------ |
|
||||
| `context` | `new Map()` | A `Map` of root-level context key-value pairs to supply to the component |
|
||||
|
||||
```js
|
||||
const { head, html, css } = App.render(
|
||||
|
@ -6,8 +6,6 @@ Typically, you won't interact with the Svelte compiler directly, but will instea
|
||||
|
||||
Nonetheless, it's useful to understand how to use the compiler, since bundler plugins generally expose compiler options to you.
|
||||
|
||||
|
||||
|
||||
### `svelte.compile`
|
||||
|
||||
```js
|
||||
@ -58,69 +56,61 @@ The following options can be passed to the compiler. None are required:
|
||||
| `cssOutputFilename` | string | `null`
|
||||
| `sveltePath` | string | `"svelte"` -->
|
||||
|
||||
| option | default | description |
|
||||
| --- | --- | --- |
|
||||
| `filename` | `null` | `string` used for debugging hints and sourcemaps. Your bundler plugin will set it automatically.
|
||||
| `name` | `"Component"` | `string` that sets the name of the resulting JavaScript class (though the compiler will rename it if it would otherwise conflict with other variables in scope). It will normally be inferred from `filename`.
|
||||
| `format` | `"esm"` | If `"esm"`, creates a JavaScript module (with `import` and `export`). If `"cjs"`, creates a CommonJS module (with `require` and `module.exports`), which is useful in some server-side rendering situations or for testing.
|
||||
| `generate` | `"dom"` | If `"dom"`, Svelte emits a JavaScript class for mounting to the DOM. If `"ssr"`, Svelte emits an object with a `render` method suitable for server-side rendering. If `false`, no JavaScript or CSS is returned; just metadata.
|
||||
| `errorMode` | `"throw"` | If `"throw"`, Svelte throws when a compilation error occurred. If `"warn"`, Svelte will treat errors as warnings and add them to the warning report.
|
||||
| `varsReport` | `"strict"` | If `"strict"`, Svelte returns a variables report with only variables that are not globals nor internals. If `"full"`, Svelte returns a variables report with all detected variables. If `false`, no variables report is returned.
|
||||
| `dev` | `false` | If `true`, causes extra code to be added to components that will perform runtime checks and provide debugging information during development.
|
||||
| `immutable` | `false` | If `true`, tells the compiler that you promise not to mutate any objects. This allows it to be less conservative about checking whether values have changed.
|
||||
| `hydratable` | `false` | If `true` when generating DOM code, enables the `hydrate: true` runtime option, which allows a component to upgrade existing DOM rather than creating new DOM from scratch. When generating SSR code, this adds markers to `<head>` elements so that hydration knows which to replace.
|
||||
| `legacy` | `false` | If `true`, generates code that will work in IE9 and IE10, which don't support things like `element.dataset`.
|
||||
| `accessors` | `false` | If `true`, getters and setters will be created for the component's props. If `false`, they will only be created for readonly exported values (i.e. those declared with `const`, `class` and `function`). If compiling with `customElement: true` this option defaults to `true`.
|
||||
| `customElement` | `false` | If `true`, tells the compiler to generate a custom element constructor instead of a regular Svelte component.
|
||||
| `tag` | `null` | A `string` that tells Svelte what tag name to register the custom element with. It must be a lowercase alphanumeric string with at least one hyphen, e.g. `"my-element"`.
|
||||
| `css` | `'injected'` | If `'injected'` (formerly `true`), styles will be included in the JavaScript class and injected at runtime for the components actually rendered. If `'external'` (formerly `false`), the CSS will be returned in the `css` field of the compilation result. Most Svelte bundler plugins will set this to `'external'` and use the CSS that is statically generated for better performance, as it will result in smaller JavaScript bundles and the output can be served as cacheable `.css` files. If `'none'`, styles are completely avoided and no CSS output is generated.
|
||||
| `cssHash` | See right | A function that takes a `{ hash, css, name, filename }` argument and returns the string that is used as a classname for scoped CSS. It defaults to returning `svelte-${hash(css)}`
|
||||
| `loopGuardTimeout` | 0 | A `number` that tells Svelte to break the loop if it blocks the thread for more than `loopGuardTimeout` ms. This is useful to prevent infinite loops. **Only available when `dev: true`**
|
||||
| `preserveComments` | `false` | If `true`, your HTML comments will be preserved during server-side rendering. By default, they are stripped out.
|
||||
| `preserveWhitespace` | `false` | If `true`, whitespace inside and between elements is kept as you typed it, rather than removed or collapsed to a single space where possible.
|
||||
| `sourcemap` | `object \| string` | An initial sourcemap that will be merged into the final output sourcemap. This is usually the preprocessor sourcemap.
|
||||
| `enableSourcemap` | `boolean \| { js: boolean; css: boolean; }` | If `true`, Svelte generate sourcemaps for components. Use an object with `js` or `css` for more granular control of sourcemap generation. By default, this is `true`.
|
||||
| `outputFilename` | `null` | A `string` used for your JavaScript sourcemap.
|
||||
| `cssOutputFilename` | `null` | A `string` used for your CSS sourcemap.
|
||||
| `sveltePath` | `"svelte"` | The location of the `svelte` package. Any imports from `svelte` or `svelte/[module]` will be modified accordingly.
|
||||
| `namespace` | `"html"` | The namespace of the element; e.g., `"mathml"`, `"svg"`, `"foreign"`.
|
||||
| option | default | description |
|
||||
| -------------------- | ------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `filename` | `null` | `string` used for debugging hints and sourcemaps. Your bundler plugin will set it automatically. |
|
||||
| `name` | `"Component"` | `string` that sets the name of the resulting JavaScript class (though the compiler will rename it if it would otherwise conflict with other variables in scope). It will normally be inferred from `filename`. |
|
||||
| `format` | `"esm"` | If `"esm"`, creates a JavaScript module (with `import` and `export`). If `"cjs"`, creates a CommonJS module (with `require` and `module.exports`), which is useful in some server-side rendering situations or for testing. |
|
||||
| `generate` | `"dom"` | If `"dom"`, Svelte emits a JavaScript class for mounting to the DOM. If `"ssr"`, Svelte emits an object with a `render` method suitable for server-side rendering. If `false`, no JavaScript or CSS is returned; just metadata. |
|
||||
| `errorMode` | `"throw"` | If `"throw"`, Svelte throws when a compilation error occurred. If `"warn"`, Svelte will treat errors as warnings and add them to the warning report. |
|
||||
| `varsReport` | `"strict"` | If `"strict"`, Svelte returns a variables report with only variables that are not globals nor internals. If `"full"`, Svelte returns a variables report with all detected variables. If `false`, no variables report is returned. |
|
||||
| `dev` | `false` | If `true`, causes extra code to be added to components that will perform runtime checks and provide debugging information during development. |
|
||||
| `immutable` | `false` | If `true`, tells the compiler that you promise not to mutate any objects. This allows it to be less conservative about checking whether values have changed. |
|
||||
| `hydratable` | `false` | If `true` when generating DOM code, enables the `hydrate: true` runtime option, which allows a component to upgrade existing DOM rather than creating new DOM from scratch. When generating SSR code, this adds markers to `<head>` elements so that hydration knows which to replace. |
|
||||
| `legacy` | `false` | If `true`, generates code that will work in IE9 and IE10, which don't support things like `element.dataset`. |
|
||||
| `accessors` | `false` | If `true`, getters and setters will be created for the component's props. If `false`, they will only be created for readonly exported values (i.e. those declared with `const`, `class` and `function`). If compiling with `customElement: true` this option defaults to `true`. |
|
||||
| `customElement` | `false` | If `true`, tells the compiler to generate a custom element constructor instead of a regular Svelte component. |
|
||||
| `tag` | `null` | A `string` that tells Svelte what tag name to register the custom element with. It must be a lowercase alphanumeric string with at least one hyphen, e.g. `"my-element"`. |
|
||||
| `css` | `'injected'` | If `'injected'` (formerly `true`), styles will be included in the JavaScript class and injected at runtime for the components actually rendered. If `'external'` (formerly `false`), the CSS will be returned in the `css` field of the compilation result. Most Svelte bundler plugins will set this to `'external'` and use the CSS that is statically generated for better performance, as it will result in smaller JavaScript bundles and the output can be served as cacheable `.css` files. If `'none'`, styles are completely avoided and no CSS output is generated. |
|
||||
| `cssHash` | See right | A function that takes a `{ hash, css, name, filename }` argument and returns the string that is used as a classname for scoped CSS. It defaults to returning `svelte-${hash(css)}` |
|
||||
| `loopGuardTimeout` | 0 | A `number` that tells Svelte to break the loop if it blocks the thread for more than `loopGuardTimeout` ms. This is useful to prevent infinite loops. **Only available when `dev: true`** |
|
||||
| `preserveComments` | `false` | If `true`, your HTML comments will be preserved during server-side rendering. By default, they are stripped out. |
|
||||
| `preserveWhitespace` | `false` | If `true`, whitespace inside and between elements is kept as you typed it, rather than removed or collapsed to a single space where possible. |
|
||||
| `sourcemap` | `object \| string` | An initial sourcemap that will be merged into the final output sourcemap. This is usually the preprocessor sourcemap. |
|
||||
| `enableSourcemap` | `boolean \| { js: boolean; css: boolean; }` | If `true`, Svelte generate sourcemaps for components. Use an object with `js` or `css` for more granular control of sourcemap generation. By default, this is `true`. |
|
||||
| `outputFilename` | `null` | A `string` used for your JavaScript sourcemap. |
|
||||
| `cssOutputFilename` | `null` | A `string` used for your CSS sourcemap. |
|
||||
| `sveltePath` | `"svelte"` | The location of the `svelte` package. Any imports from `svelte` or `svelte/[module]` will be modified accordingly. |
|
||||
| `namespace` | `"html"` | The namespace of the element; e.g., `"mathml"`, `"svg"`, `"foreign"`. |
|
||||
|
||||
---
|
||||
|
||||
The returned `result` object contains the code for your component, along with useful bits of metadata.
|
||||
|
||||
```js
|
||||
const {
|
||||
js,
|
||||
css,
|
||||
ast,
|
||||
warnings,
|
||||
vars,
|
||||
stats
|
||||
} = svelte.compile(source);
|
||||
const { js, css, ast, warnings, vars, stats } = svelte.compile(source);
|
||||
```
|
||||
|
||||
* `js` and `css` are objects with the following properties:
|
||||
* `code` is a JavaScript string
|
||||
* `map` is a sourcemap with additional `toString()` and `toUrl()` convenience methods
|
||||
* `ast` is an abstract syntax tree representing the structure of your component.
|
||||
* `warnings` is an array of warning objects that were generated during compilation. Each warning has several properties:
|
||||
* `code` is a string identifying the category of warning
|
||||
* `message` describes the issue in human-readable terms
|
||||
* `start` and `end`, if the warning relates to a specific location, are objects with `line`, `column` and `character` properties
|
||||
* `frame`, if applicable, is a string highlighting the offending code with line numbers
|
||||
* `vars` is an array of the component's declarations, used by [eslint-plugin-svelte3](https://github.com/sveltejs/eslint-plugin-svelte3) for example. Each variable has several properties:
|
||||
* `name` is self-explanatory
|
||||
* `export_name` is the name the value is exported as, if it is exported (will match `name` unless you do `export...as`)
|
||||
* `injected` is `true` if the declaration is injected by Svelte, rather than in the code you wrote
|
||||
* `module` is `true` if the value is declared in a `context="module"` script
|
||||
* `mutated` is `true` if the value's properties are assigned to inside the component
|
||||
* `reassigned` is `true` if the value is reassigned inside the component
|
||||
* `referenced` is `true` if the value is used in the template
|
||||
* `referenced_from_script` is `true` if the value is used in the `<script>` outside the declaration
|
||||
* `writable` is `true` if the value was declared with `let` or `var` (but not `const`, `class` or `function`)
|
||||
* `stats` is an object used by the Svelte developer team for diagnosing the compiler. Avoid relying on it to stay the same!
|
||||
|
||||
- `js` and `css` are objects with the following properties:
|
||||
- `code` is a JavaScript string
|
||||
- `map` is a sourcemap with additional `toString()` and `toUrl()` convenience methods
|
||||
- `ast` is an abstract syntax tree representing the structure of your component.
|
||||
- `warnings` is an array of warning objects that were generated during compilation. Each warning has several properties:
|
||||
- `code` is a string identifying the category of warning
|
||||
- `message` describes the issue in human-readable terms
|
||||
- `start` and `end`, if the warning relates to a specific location, are objects with `line`, `column` and `character` properties
|
||||
- `frame`, if applicable, is a string highlighting the offending code with line numbers
|
||||
- `vars` is an array of the component's declarations, used by [eslint-plugin-svelte3](https://github.com/sveltejs/eslint-plugin-svelte3) for example. Each variable has several properties:
|
||||
- `name` is self-explanatory
|
||||
- `export_name` is the name the value is exported as, if it is exported (will match `name` unless you do `export...as`)
|
||||
- `injected` is `true` if the declaration is injected by Svelte, rather than in the code you wrote
|
||||
- `module` is `true` if the value is declared in a `context="module"` script
|
||||
- `mutated` is `true` if the value's properties are assigned to inside the component
|
||||
- `reassigned` is `true` if the value is reassigned inside the component
|
||||
- `referenced` is `true` if the value is used in the template
|
||||
- `referenced_from_script` is `true` if the value is used in the `<script>` outside the declaration
|
||||
- `writable` is `true` if the value was declared with `let` or `var` (but not `const`, `class` or `function`)
|
||||
- `stats` is an object used by the Svelte developer team for diagnosing the compiler. Avoid relying on it to stay the same!
|
||||
|
||||
<!--
|
||||
|
||||
@ -159,7 +149,6 @@ compiled: {
|
||||
|
||||
-->
|
||||
|
||||
|
||||
### `svelte.parse`
|
||||
|
||||
```js
|
||||
@ -176,14 +165,12 @@ ast: object = svelte.parse(
|
||||
|
||||
The `parse` function parses a component, returning only its abstract syntax tree. Unlike compiling with the `generate: false` option, this will not perform any validation or other analysis of the component beyond parsing it. Note that the returned AST is not considered public API, so breaking changes could occur at any point in time.
|
||||
|
||||
|
||||
```js
|
||||
const svelte = require('svelte/compiler');
|
||||
|
||||
const ast = svelte.parse(source, { filename: 'App.svelte' });
|
||||
```
|
||||
|
||||
|
||||
### `svelte.preprocess`
|
||||
|
||||
A number of [community-maintained preprocessing plugins](https://sveltesociety.dev/tools#preprocessors) are available to allow you to use Svelte with tools like TypeScript, PostCSS, SCSS, and Less.
|
||||
@ -220,7 +207,7 @@ result: {
|
||||
|
||||
The `preprocess` function provides convenient hooks for arbitrarily transforming component source code. For example, it can be used to convert a `<style lang="sass">` block into vanilla CSS.
|
||||
|
||||
The first argument is the component source code. The second is an array of *preprocessors* (or a single preprocessor, if you only have one), where a preprocessor is an object with `markup`, `script` and `style` functions, each of which is optional.
|
||||
The first argument is the component source code. The second is an array of _preprocessors_ (or a single preprocessor, if you only have one), where a preprocessor is an object with `markup`, `script` and `style` functions, each of which is optional.
|
||||
|
||||
Each `markup`, `script` or `style` function must return an object (or a Promise that resolves to an object) with a `code` property, representing the transformed source code, and an optional array of `dependencies`.
|
||||
|
||||
@ -232,22 +219,26 @@ The `markup` function receives the entire component source text, along with the
|
||||
const svelte = require('svelte/compiler');
|
||||
const MagicString = require('magic-string');
|
||||
|
||||
const { code } = await svelte.preprocess(source, {
|
||||
markup: ({ content, filename }) => {
|
||||
const pos = content.indexOf('foo');
|
||||
if(pos < 0) {
|
||||
return { code: content }
|
||||
}
|
||||
const s = new MagicString(content, { filename })
|
||||
s.overwrite(pos, pos + 3, 'bar', { storeName: true })
|
||||
return {
|
||||
code: s.toString(),
|
||||
map: s.generateMap()
|
||||
const { code } = await svelte.preprocess(
|
||||
source,
|
||||
{
|
||||
markup: ({ content, filename }) => {
|
||||
const pos = content.indexOf('foo');
|
||||
if (pos < 0) {
|
||||
return { code: content };
|
||||
}
|
||||
const s = new MagicString(content, { filename });
|
||||
s.overwrite(pos, pos + 3, 'bar', { storeName: true });
|
||||
return {
|
||||
code: s.toString(),
|
||||
map: s.generateMap()
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
filename: 'App.svelte'
|
||||
}
|
||||
}, {
|
||||
filename: 'App.svelte'
|
||||
});
|
||||
);
|
||||
```
|
||||
|
||||
---
|
||||
@ -261,30 +252,37 @@ const svelte = require('svelte/compiler');
|
||||
const sass = require('node-sass');
|
||||
const { dirname } = require('path');
|
||||
|
||||
const { code, dependencies } = await svelte.preprocess(source, {
|
||||
style: async ({ content, attributes, filename }) => {
|
||||
// only process <style lang="sass">
|
||||
if (attributes.lang !== 'sass') return;
|
||||
const { code, dependencies } = await svelte.preprocess(
|
||||
source,
|
||||
{
|
||||
style: async ({ content, attributes, filename }) => {
|
||||
// only process <style lang="sass">
|
||||
if (attributes.lang !== 'sass') return;
|
||||
|
||||
const { css, stats } = await new Promise((resolve, reject) => sass.render({
|
||||
file: filename,
|
||||
data: content,
|
||||
includePaths: [
|
||||
dirname(filename),
|
||||
],
|
||||
}, (err, result) => {
|
||||
if (err) reject(err);
|
||||
else resolve(result);
|
||||
}));
|
||||
const { css, stats } = await new Promise((resolve, reject) =>
|
||||
sass.render(
|
||||
{
|
||||
file: filename,
|
||||
data: content,
|
||||
includePaths: [dirname(filename)]
|
||||
},
|
||||
(err, result) => {
|
||||
if (err) reject(err);
|
||||
else resolve(result);
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
return {
|
||||
code: css.toString(),
|
||||
dependencies: stats.includedFiles
|
||||
};
|
||||
return {
|
||||
code: css.toString(),
|
||||
dependencies: stats.includedFiles
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
filename: 'App.svelte'
|
||||
}
|
||||
}, {
|
||||
filename: 'App.svelte'
|
||||
});
|
||||
);
|
||||
```
|
||||
|
||||
---
|
||||
@ -294,35 +292,38 @@ Multiple preprocessors can be used together. The output of the first becomes the
|
||||
```js
|
||||
const svelte = require('svelte/compiler');
|
||||
|
||||
const { code } = await svelte.preprocess(source, [
|
||||
{
|
||||
markup: () => {
|
||||
console.log('this runs first');
|
||||
const { code } = await svelte.preprocess(
|
||||
source,
|
||||
[
|
||||
{
|
||||
markup: () => {
|
||||
console.log('this runs first');
|
||||
},
|
||||
script: () => {
|
||||
console.log('this runs third');
|
||||
},
|
||||
style: () => {
|
||||
console.log('this runs fifth');
|
||||
}
|
||||
},
|
||||
script: () => {
|
||||
console.log('this runs third');
|
||||
},
|
||||
style: () => {
|
||||
console.log('this runs fifth');
|
||||
{
|
||||
markup: () => {
|
||||
console.log('this runs second');
|
||||
},
|
||||
script: () => {
|
||||
console.log('this runs fourth');
|
||||
},
|
||||
style: () => {
|
||||
console.log('this runs sixth');
|
||||
}
|
||||
}
|
||||
},
|
||||
],
|
||||
{
|
||||
markup: () => {
|
||||
console.log('this runs second');
|
||||
},
|
||||
script: () => {
|
||||
console.log('this runs fourth');
|
||||
},
|
||||
style: () => {
|
||||
console.log('this runs sixth');
|
||||
}
|
||||
filename: 'App.svelte'
|
||||
}
|
||||
], {
|
||||
filename: 'App.svelte'
|
||||
});
|
||||
);
|
||||
```
|
||||
|
||||
|
||||
### `svelte.walk`
|
||||
|
||||
```js
|
||||
@ -338,7 +339,6 @@ The `walk` function provides a way to walk the abstract syntax trees generated b
|
||||
|
||||
The walker takes an abstract syntax tree to walk and an object with two optional methods: `enter` and `leave`. For each node, `enter` is called (if present). Then, unless `this.skip()` is called during `enter`, each of the children are traversed, and then `leave` is called on the node.
|
||||
|
||||
|
||||
```js
|
||||
const svelte = require('svelte/compiler');
|
||||
svelte.walk(ast, {
|
||||
@ -354,7 +354,6 @@ svelte.walk(ast, {
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
### `svelte.VERSION`
|
||||
|
||||
---
|
||||
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"title": "Hello world"
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"title": "Dynamic attributes"
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"title": "Styling"
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"title": "Nested components"
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"title": "HTML tags"
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"title": "Introduction"
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"title": "Reactive assignments"
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"title": "Reactive declarations"
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"title": "Reactive statements"
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"title": "Reactivity"
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"title": "Declaring props"
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"title": "Default values"
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"title": "Spread props"
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"title": "Props"
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"title": "If blocks"
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"title": "Else blocks"
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"title": "Else-if blocks"
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"title": "Each blocks"
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"title": "Keyed each blocks"
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"title": "Await blocks"
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"title": "Logic"
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"title": "DOM events"
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"title": "Inline handlers"
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"title": "Event modifiers"
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"title": "Component events"
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"title": "Event forwarding"
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"title": "DOM event forwarding"
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"title": "Events"
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"title": "Text inputs"
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"title": "Numeric inputs"
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"title": "Checkbox inputs"
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"title": "Group inputs"
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"title": "Textarea inputs"
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"title": "Select bindings"
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user