Zum Inhalt springen

Svelte Updates & Release Notes

Einträge
109
Quellen
1
Zuletzt aktualisiert

Folge Svelte, um die Release Notes in deinen Feed zu holen.

Svelte

Weniger Code schreiben mit Svelte

Svelte reduziert die Menge an Code, die Entwickler schreiben müssen, was zu weniger Bugs und kürzerer Entwicklungszeit führt.

All code is buggy. It stands to reason, therefore, that the more code you have to write the buggier your apps will be.

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 and bug count 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...

Originalquelle(öffnet in neuem Tab)Problem melden

Svelte

Leitfaden für neue Svelte-Entwickler

Ein Leitfaden hilft neuen Entwicklern ohne viel JavaScript-Build-Tooling-Erfahrung, mit Svelte-Apps zu beginnen.

This short guide is designed to help you — someone who has looked at the tutorial and wants to start creating Svelte apps, but doesn’t have a ton of experience using JavaScript build tooling — get up and running.

If there are things that don’t make sense, or that we’re glossing over, feel free to raise an issue or suggest edits to this page that will help us help more people.

If you get stuck at any point following this guide, the best place to ask for help is in the chatroom.

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.

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. …

Originalquelle(öffnet in neuem Tab)Problem melden

Svelte

Svelte im The-Changelog-Podcast

Rich Harris war im Podcast The Changelog zu Gast und sprach über Svelte 3 sowie die Entwicklung des Frameworks.

Earlier this month, I had the privilege of appearing on The Changelog, 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

...and, most importantly, Svelte 3.

Unless you hang out in our Discord server or follow @sveltejs on BlueSky, 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, Jerod and I talk about some of the changes and why we’re making them. You can listen here or on the podcast page.

The Changelog 332: A UI framework without the framework – Listen on Changelog.com

Originalquelle(öffnet in neuem Tab)Problem melden

Svelte

Virtuelles DOM ist reiner Overhead

Der Blogbeitrag analysiert, warum das virtuelle DOM nicht schneller als das echte DOM ist und wie Svelte darauf verzichtet.

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 component:

function HelloMessagefunction HelloMessage(props: any): div(props(parameter) props: any) {
	return <divtype div = /*unresolved*/ any classNameany="greeting">Helloany {props(parameter) props: any.nameany}</div>;
}

You can do the same thing without JSX...

function HelloMessagefunction HelloMessage(props: any): any(props(parameter) props: any) {
	return Reactany.createElementany('div', { className(property) className: string: 'greeting' }, 'Hello ', props(parameter) props: any.nameany);
}

...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? …

Originalquelle(öffnet in neuem Tab)Problem melden

Svelte

CSS-in-JS mit Svelte nutzen

Der Artikel erklärt, wie man CSS-in-JS-Bibliotheken wie Emotion zusammen mit Sveltes eingebauter CSS-Behandlung verwenden kann.

CSS is a core part of any web app. By extension, a UI framework that doesn’t have a built-in way to add styles to your components is unfinished.

That’s why Svelte allows you to add CSS in a component’s <style> tag. Co-locating your CSS with your markup means we can solve the biggest problems developers face when writing CSS without introducing new ones, all while providing a rather nice development experience.

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 to generate scoped class names that can be used across multiple components:

It’s important to note that most CSS-in-JS libraries have a runtime library, and many don’t support statically extracting styles out into a separate .css file at build time (which is essential for the best performance). You should therefore only use CSS-in-JS if it’s necessary for your application!

Note that you can mix-and-match — you can still use Svelte’s built-in CSS handling alongside a CSS-in-JS library.

Originalquelle(öffnet in neuem Tab)Problem melden

Svelte

Svelte v2 ist veröffentlicht

Svelte Version 2 ist erschienen und bringt neue Templatesyntax sowie weitere Änderungen; ein Upgrade-Tool hilft bei der Migration.

Our motto is 'move slowly and break things'. No, wait, that came out wrong...

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.

  • Install Svelte v2 from npm
  • Upgrade your templates with svelte-upgrade
  • Remove calls to component.observe, or add the observe method from svelte-extras
  • Rewrite calls to component.get('foo') as component.get().foo
  • 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. …

Originalquelle(öffnet in neuem Tab)Problem melden

Svelte

Sapper: Zum idealen Web-App-Framework

Der Artikel stellt Sapper vor, ein Framework für ideale Web-Apps mit Server-Side Rendering, Code-Splitting und Offline-Unterstützung.

Quickstart for the impatient: the Sapper docs, and the starter template

If you had to list the characteristics of the perfect Node.js web application framework, you’d probably come up with something like this:

  1. It should do server-side rendering, for fast initial loads and no caveats around SEO
  2. As a corollary, your app’s codebase should be universal — write once for server and client
  3. The client-side app should hydrate the server-rendered HTML, attaching event listeners (and so on) to existing elements rather than re-rendering them
  4. Navigating to subsequent pages should be instantaneous
  5. Offline, and other Progressive Web App characteristics, must be supported out of the box
  6. Only the JavaScript and CSS required for the first page should load initially. That means the framework should do automatic code-splitting at the route level, and support dynamic import(...) for more granular manual control
  7. No compromise on performance
  8. First-rate developer experience, with hot module reloading and all the trimmings
  9. The resulting codebase should be easy to grok and maintain
  10. It should be possible to understand and customise every aspect of the system — no webpack configs locked up in the framework, and as little hidden ‘plumbing’ as possible
  11. Learning the entire framework in under an hour should be easy, and not just for experienced developers …

Originalquelle(öffnet in neuem Tab)Problem melden

Svelte

Die Kunst, einfach CSS zu schreiben

Der Artikel argumentiert, dass die größten Probleme mit CSS auch ohne CSS-in-JS gelöst werden können und dass das Schreiben von CSS mit Single File Components und echtem CSS angenehm sein kann.

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.

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 …

Originalquelle(öffnet in neuem Tab)Problem melden

Svelte

Frameworks ohne Framework – warum nicht früher?

Der Artikel kritisiert die hohe JavaScript-Last von Frameworks und plädiert für einen Ansatz ohne Laufzeit, der weniger Code an Nutzer ausliefert.

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! – 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.

If you’re not convinced that this is a problem, follow Alex Russell on BlueSky. Alex hasn’t been making many friends in the framework community lately, but he’s not wrong. But the proposed alternative to using frameworks like Angular, React and Ember – Polymer – hasn’t yet gained traction in the front end world, and it’s certainly not for a lack of marketing.

Perhaps we need to rethink the whole thing.

What problem do frameworks really solve? …

Originalquelle(öffnet in neuem Tab)Problem melden