SvelteKit 3 已发布
SvelteKit 3

原始链接: https://svelte.dev/blog/sveltekit-3-is-here

SvelteKit 3.0 现已推出,带来更强的类型安全性、更简洁的代码库以及多项 enhancements。现有项目可通过以下命令自动迁移: `npx sv migrate sveltekit-3 --tasks all --confirm` 新项目可以使用 `sv create` 创建。主要变化包括:将配置迁移到 `vite.config.ts`、用 `#lib` 取代 `$lib` 别名、升级环境变量、减少服务工作线程样板代码,以及改进错误处理。迁移指南介绍了主要的不兼容变更。 用于安全、高效且类型安全的客户端—服务器通信的远程函数尚未准备就绪,仍是团队的首要任务。目前,这些函数需要 Async Svelte 和实验性标志才能使用。 Svelte Summit 将于 11 月 19日至20日在斯洛文尼亚卢布尔雅那举行,庆祝 Svelte 成立十周年。

Hacker News 上关于 SvelteKit 3 的讨论大多充满赞誉,许多开发者称赞 Svelte 的速度、小体积打包、简洁语法、SSR 能力以及出色的开发体验。Rich Harris 则认为,即使 AI 智能体正在生成更多软件,框架的质量仍然很重要:Svelte 能构建更小、更快、无障碍支持更好的应用,同时也能让智能体使用更少的 token。 争论的主要焦点是,React 更大的生态系统和更高的训练数据普及度,是否使其更适合借助大语言模型进行开发。支持 Svelte 的人认为,现代模型已经能够生成合格可靠的 Svelte 代码,尤其是在有当前文档参考的情况下;而 React 的生态中则存在更多过时模式、潜在陷阱和性能问题。另一些人则认为,React 对智能体来说仍然更容易使用,因为模型对它理解得更好,而且相关工具也更成熟。 批评者还指出,Svelte 的生态系统较小,在 JetBrains IDE、Storybook 和代码检查工具等方面的支持较弱,而且从早期版本到 Svelte 5,语法发生了重大变化。被提及的替代方案包括 React、Vue/Nuxt、Solid、Astro、HTMX 以及原生 Web 技术。总体而言,用户对框架未来的看法仍然存在分歧,但一致认为,在智能体主导的编程时代,应用性能、可维护性和验证仍然很重要。
相关文章

原文

Version 3.0 of SvelteKit, the official application framework for Svelte, is now available.

If you’ve used earlier versions of SvelteKit, everything will feel very familiar — it’s the same framework with a little more polish, a little more type safety, and a little less junk. We’ve made migration as seamless as we can with the sv migrate command...

npx sv migrate sveltekit-3 --tasks all --confirm

...which will automatically migrate as much of your codebase as possible, and generate a TODO list for everything else. (If you’re agentically inclined, your robot friends will make short work of it.)

To create a new app, run sv create:

As with any major version bump there are a handful of breaking changes to be aware of, which are covered in the migration guide (or, more briefly, in the recent release candidate announcement).

Quick highlights:

  • configuration now lives in vite.config.ts instead of svelte.config.js
  • the $lib alias is now #lib, making use of standard subpath imports
  • environment variables are more powerful and easier to use
  • service workers are less boilerplatey
  • error handling is improved across the board

Are remote functions ready yet?

Remote functions are a set of utilities for secure, efficient, type-safe client-server communication. You’ve likely seen some version of this idea in other frameworks, but we think you’re going to prefer this one.

Using them requires Async Svelte, which for now requires an experimental flag. Bear with us.

Join us in Ljubljana next month

Svelte Summit is taking place on November 19-20 in the lovely town of Ljubljana, Slovenia. Among other things it will be a celebration of Svelte’s 10th birthday, and we’d love to share some cake with you.

联系我们 contact @ memedata.com