From a6fbf7faf5ce086c73daa4e557e1bdd53036fc36 Mon Sep 17 00:00:00 2001 From: Daniel Sandoval Date: Thu, 1 Jul 2021 06:22:40 -0700 Subject: [PATCH 01/12] [docs] "What's new in Svelte" July newsletter (#6459) --- ...021-07-01-whats-new-in-svelte-july-2021.md | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 site/content/blog/2021-07-01-whats-new-in-svelte-july-2021.md diff --git a/site/content/blog/2021-07-01-whats-new-in-svelte-july-2021.md b/site/content/blog/2021-07-01-whats-new-in-svelte-july-2021.md new file mode 100644 index 0000000000..fa6440ade4 --- /dev/null +++ b/site/content/blog/2021-07-01-whats-new-in-svelte-july-2021.md @@ -0,0 +1,65 @@ +--- +title: What's new in Svelte: July 2021 +description: Keeping cool with fixes, TypeScript tooling and tonnes of new features +author: Daniel Sandoval +authorURL: https://desandoval.net +--- + +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/* +- [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)) + +--- + +## 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 +- [How To Cache Dynamic Pages On Demand With A Service Worker In SvelteKit](https://jochemvogel.medium.com/how-to-cache-dynamic-pages-on-demand-with-a-service-worker-in-sveltekit-4b4a7652583d) walks through the power of service workers when used within SvelteKit for on-demand caching +- [Vue vs Svelte: Comparing Framework Internals](https://www.vuemastery.com/blog/vue-vs-svelte-comparing-framework-internals/) dives deep into the differences between Vue and Svelte from the inside out +- [Setting up a development environment for SvelteKit with Docker and Docker Compose](https://jenyus.web.app/blog/2021-05-30-setting-up-a-development-environment-for-sveltekit-with-docker-and-compose) walks through how to use Docker to create reusable development environments, no matter what kind of device you run your code on +- Scalable Scripts released three videos this month documenting how to deploy dockerized Svelte Apps to [AWS](https://youtu.be/VOs2Od5jYOc), [Azure](https://youtu.be/gdg4ne_uDm8) and [Google Cloud](https://youtu.be/_-uBb61Tikw) +- [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 +- [svelte-stack-router](https://www.npmjs.com/package/svelte-stack-router) Aims to make Svelte apps feel more native by routing with Stacks +- [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)! From 287cccc450afce2f69110f986c0d08f1ceabef7f Mon Sep 17 00:00:00 2001 From: Odee Date: Fri, 2 Jul 2021 23:12:11 +0800 Subject: [PATCH 02/12] [docs] Update auto-subscriptions tutorial to explicitly say that subscribe returns unsubscribe (#6448) --- site/content/tutorial/08-stores/02-auto-subscriptions/text.md | 1 + 1 file changed, 1 insertion(+) diff --git a/site/content/tutorial/08-stores/02-auto-subscriptions/text.md b/site/content/tutorial/08-stores/02-auto-subscriptions/text.md index 33c2358b39..27d3251c6e 100644 --- a/site/content/tutorial/08-stores/02-auto-subscriptions/text.md +++ b/site/content/tutorial/08-stores/02-auto-subscriptions/text.md @@ -11,6 +11,7 @@ const unsubscribe = count.subscribe(value => { count_value = value; }); ``` +> Calling a `subscribe` method returns an `unsubscribe` function. You now declared `unsubscribe`, but it still needs to be called, for example through the `onDestroy` [lifecycle hook](tutorial/ondestroy): From c4f4a3dc2e09d1ddd002e8a0d0cbccb09c89ff0a Mon Sep 17 00:00:00 2001 From: Jatin Hemnani <73883835+jatinhemnani01@users.noreply.github.com> Date: Fri, 2 Jul 2021 20:44:08 +0530 Subject: [PATCH 03/12] [docs] added transition on toggling folder in tutorial (#6453) --- .../17-special-elements/00-svelte-self/Folder.svelte | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/site/content/examples/17-special-elements/00-svelte-self/Folder.svelte b/site/content/examples/17-special-elements/00-svelte-self/Folder.svelte index f5f0a7b194..c65e177983 100644 --- a/site/content/examples/17-special-elements/00-svelte-self/Folder.svelte +++ b/site/content/examples/17-special-elements/00-svelte-self/Folder.svelte @@ -1,6 +1,7 @@ \ No newline at end of file + From f2ca8bc64b6a91a8a7d2bf0fc034658242b54b89 Mon Sep 17 00:00:00 2001 From: Adam Bates Date: Tue, 6 Jul 2021 10:31:42 -0400 Subject: [PATCH 11/12] [docs] Fixed typo 'site-repl' -> 'svelte-repl', with minor change to a sentence's structure (#6498) (used to look like a list of 4, when really it's a list of 2). --- site/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/site/README.md b/site/README.md index 7d8adbd6c5..ca75a89953 100644 --- a/site/README.md +++ b/site/README.md @@ -54,9 +54,9 @@ To build the website, run `npm run build`. The output can be found in `__sapper_ Tests can be run using `npm run test`. -## Linking `@sveltejs/site-kit` and `@sveltejs/site-repl` +## Linking `@sveltejs/site-kit` and `@sveltejs/svelte-repl` -This site depends on `@sveltejs/site-kit`, a collection of styles, components and icons used in common by *.svelte.dev websites, and `@sveltejs/site-repl`. +This site depends on `@sveltejs/site-kit` (a collection of styles, components and icons used in common by *.svelte.dev websites), and `@sveltejs/svelte-repl`. In order to work on features that depend on those packages, you need to [link](https://docs.npmjs.com/cli/link) their repositories: @@ -70,7 +70,7 @@ In order to work on features that depend on those packages, you need to [link](h - `cd /site` - `npm link @sveltejs/site-kit` - `npm link @sveltejs/svelte-repl` - + ## Translating the API docs From b662c7fd41b3b778ea1ae80b0a4d86c239ffcfe7 Mon Sep 17 00:00:00 2001 From: Simon H <5968653+dummdidumm@users.noreply.github.com> Date: Wed, 7 Jul 2021 16:16:35 +0200 Subject: [PATCH 12/12] [chore] move compiler warnings/errors to dedicate files (#6503) --- src/compiler/compile/Component.ts | 144 ++------- src/compiler/compile/compiler_errors.ts | 253 ++++++++++++++++ src/compiler/compile/compiler_warnings.ts | 143 +++++++++ src/compiler/compile/css/Selector.ts | 11 +- src/compiler/compile/css/Stylesheet.ts | 6 +- src/compiler/compile/nodes/Animation.ts | 11 +- src/compiler/compile/nodes/Binding.ts | 26 +- src/compiler/compile/nodes/EachBlock.ts | 6 +- src/compiler/compile/nodes/Element.ts | 282 ++++-------------- src/compiler/compile/nodes/Head.ts | 6 +- src/compiler/compile/nodes/InlineComponent.ts | 21 +- src/compiler/compile/nodes/Let.ts | 6 +- src/compiler/compile/nodes/Slot.ts | 16 +- src/compiler/compile/nodes/SlotTemplate.ts | 16 +- src/compiler/compile/nodes/Title.ts | 11 +- src/compiler/compile/nodes/Transition.ts | 17 +- src/compiler/compile/nodes/Window.ts | 18 +- .../compile/nodes/shared/AbstractBlock.ts | 6 +- .../compile/nodes/shared/Expression.ts | 6 +- .../wrappers/InlineComponent/index.ts | 6 +- tsconfig.json | 3 + 21 files changed, 535 insertions(+), 479 deletions(-) create mode 100644 src/compiler/compile/compiler_errors.ts create mode 100644 src/compiler/compile/compiler_warnings.ts diff --git a/src/compiler/compile/Component.ts b/src/compiler/compile/Component.ts index 241a2c05d4..9001d09f68 100644 --- a/src/compiler/compile/Component.ts +++ b/src/compiler/compile/Component.ts @@ -34,6 +34,8 @@ import { apply_preprocessor_sourcemap } from '../utils/mapped_code'; import Element from './nodes/Element'; import { DecodedSourceMap, RawSourceMap } from '@ampproject/remapping/dist/types/types'; import { clone } from '../utils/clone'; +import compiler_warnings from './compiler_warnings'; +import compiler_errors from './compiler_errors'; interface ComponentOptions { namespace?: string; @@ -161,10 +163,7 @@ export default class Component { const svelteOptions = ast.html.children.find( child => child.name === 'svelte:options' ) || { start: 0, end: 0 }; - this.warn(svelteOptions, { - code: 'custom-element-no-tag', - message: 'No custom element \'tag\' option was specified. To automatically register a custom element, specify a name with a hyphen in it, e.g. . To hide this warning, use ' - }); + this.warn(svelteOptions, compiler_warnings.custom_element_no_tag); } this.tag = this.component_options.tag || compile_options.tag; } else { @@ -478,18 +477,12 @@ export default class Component { extract_exports(node) { if (node.type === 'ExportDefaultDeclaration') { - this.error(node, { - code: 'default-export', - message: 'A component cannot have a default export' - }); + this.error(node, compiler_errors.default_export); } if (node.type === 'ExportNamedDeclaration') { if (node.source) { - this.error(node, { - code: 'not-implemented', - message: 'A component currently cannot have an export ... from' - }); + this.error(node, compiler_errors.not_implemented); } if (node.declaration) { if (node.declaration.type === 'VariableDeclaration') { @@ -498,10 +491,7 @@ export default class Component { const variable = this.var_lookup.get(name); variable.export_name = name; if (variable.writable && !(variable.referenced || variable.referenced_from_script || variable.subscribable)) { - this.warn(declarator, { - code: 'unused-export-let', - message: `${this.name.name} has unused export property '${name}'. If it is for external reference only, please consider using \`export const ${name}\`` - }); + this.warn(declarator, compiler_warnings.unused_export_let(this.name.name, name)); } }); }); @@ -521,10 +511,7 @@ export default class Component { variable.export_name = specifier.exported.name; if (variable.writable && !(variable.referenced || variable.referenced_from_script || variable.subscribable)) { - this.warn(specifier, { - code: 'unused-export-let', - message: `${this.name.name} has unused export property '${specifier.exported.name}'. If it is for external reference only, please consider using \`export const ${specifier.exported.name}\`` - }); + this.warn(specifier, compiler_warnings.unused_export_let(this.name.name, specifier.exported.name)); } } }); @@ -555,10 +542,7 @@ export default class Component { walk(script.content, { enter(node: Node) { if (node.type === 'LabeledStatement' && node.label.name === '$') { - component.warn(node as any, { - code: 'module-script-reactive-declaration', - message: '$: has no effect in a module script' - }); + component.warn(node as any, compiler_warnings.module_script_reactive_declaration); } } }); @@ -568,10 +552,7 @@ export default class Component { scope.declarations.forEach((node, name) => { if (name[0] === '$') { - this.error(node as any, { - code: 'illegal-declaration', - message: 'The $ prefix is reserved, and cannot be used for variable and import names' - }); + this.error(node as any, compiler_errors.illegal_declaration); } const writable = node.type === 'VariableDeclaration' && (node.kind === 'var' || node.kind === 'let'); @@ -586,10 +567,7 @@ export default class Component { globals.forEach((node, name) => { if (name[0] === '$') { - this.error(node as any, { - code: 'illegal-subscription', - message: 'Cannot reference store value inside