Skip to content

Commit

Permalink
release v6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
waynzh authored Nov 27, 2024
2 parents 7a8baea + 7cde508 commit 69b416f
Show file tree
Hide file tree
Showing 16 changed files with 248 additions and 32 deletions.
11 changes: 6 additions & 5 deletions .vitepress/theme/components/AsideSponsors.vue
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
<script setup lang="ts">
import { computed } from 'vue'
import { VPDocAsideSponsors } from 'vitepress/theme'
import { useSponsor } from '../composables/sponsor'
import { useSponsor, voidZero } from '../composables/sponsor'
const { data } = useSponsor()
const sponsors = computed(() => {
return (
data?.value.map((sponsor) => {
return [
{ size: 'small', items: [voidZero] },
...(data?.value.map((sponsor) => {
return {
size: sponsor.size === 'big' ? 'mini' : 'xmini',
items: sponsor.items,
}
}) ?? []
)
}) ?? []),
]
})
</script>

Expand Down
37 changes: 37 additions & 0 deletions .vitepress/theme/components/YouTubeVideo.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<script setup>
defineProps({
videoId: String,
})
</script>

<template>
<div class="full-width-youtube-video">
<iframe
width="560"
height="315"
:src="`https://www.youtube.com/embed/${videoId}`"
title="YouTube video player"
frameborder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
allowfullscreen
></iframe>
</div>
</template>

<style scoped>
.full-width-youtube-video {
position: relative;
padding-bottom: 56.25%;
height: 0;
}
.full-width-youtube-video iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border: none;
border-radius: 0.5rem;
}
</style>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup>
import { useSponsor } from '../../../composables/sponsor'
import { useSponsor, voidZero } from '../../../composables/sponsor'
import { VPSponsors } from 'vitepress/theme'
const { data } = useSponsor()
Expand Down Expand Up @@ -53,8 +53,8 @@ const { data } = useSponsor()

<h4>由以下团队呈现</h4>
<div class="voidzero">
<a href="https://voidzero.dev" target="_blank">
<img src="./voidzero.svg" />
<a :href="voidZero.url" target="_blank">
<img :src="voidZero.img" />
</a>
</div>

Expand Down Expand Up @@ -120,6 +120,7 @@ const { data } = useSponsor()
position: relative;
display: inline-block;
max-width: 260px;
filter: grayscale(1) invert(1);
}
}
Expand Down
6 changes: 6 additions & 0 deletions .vitepress/theme/composables/sponsor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ const data = ref()
const dataHost = 'https://sponsors.vuejs.org'
const dataUrl = `${dataHost}/vite.json`

export const voidZero = {
name: 'VoidZero',
url: 'https://voidzero.dev',
img: '/voidzero.svg',
} satisfies Sponsor

const viteSponsors: Pick<Sponsors, 'special' | 'gold'> = {
special: [
// sponsors patak-dev
Expand Down
2 changes: 2 additions & 0 deletions .vitepress/theme/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import SvgImage from './components/SvgImage.vue'
import WwAds from './components/WwAds.vue'
import ReleaseTag from './components/ReleaseTag.vue'
import './custom.css'
import YouTubeVideo from './components/YouTubeVideo.vue'
import 'virtual:group-icons.css'

export default {
Expand All @@ -23,6 +24,7 @@ export default {
enhanceApp({ app }) {
app.component('SvgImage', SvgImage)
app.component('ReleaseTag', ReleaseTag)
app.component('YouTubeVideo', YouTubeVideo)
app.use(TwoslashFloatingVue)
},
} satisfies Theme
Expand Down
2 changes: 1 addition & 1 deletion .vitepress/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"compilerOptions": {
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "Bundler",
"moduleResolution": "bundler",
"strict": true,
"noImplicitOverride": true,
"noUnusedLocals": true,
Expand Down
115 changes: 115 additions & 0 deletions blog/announcing-vite6.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
---
title: Vite 6.0 is out!
author:
name: The Vite Team
date: 2024-11-26
sidebar: false
head:
- - meta
- property: og:type
content: website
- - meta
- property: og:title
content: Announcing Vite 6
- - meta
- property: og:image
content: https://vite.dev/og-image-announcing-vite6.png
- - meta
- property: og:url
content: https://vite.dev/blog/announcing-vite6
- - meta
- property: og:description
content: Vite 6 Release Announcement
- - meta
- name: twitter:card
content: summary_large_image
---

# Vite 6.0 is out!

_November 26, 2024_

![Vite 6 Announcement Cover Image](/og-image-announcing-vite6.png)

Today, we're taking another big step in Vite's story. The Vite [team](/team), [contributors](https://github.com/vitejs/vite/graphs/contributors), and ecosystem partners are excited to announce the release of Vite 6.

It has been an eventful year. Vite adoption keeps growing, with npm downloads per week jumping from 7.5 million to 17 million since the release of Vite 5 a year ago. [Vitest](https://vitest.dev) is not only being favored more by users but is also starting to form an ecosystem of its own. For example, [Storybook](https://storybook.js.org) has new testing capabilities powered by Vitest.

New frameworks have also joined the Vite ecosystem, including [TanStack Start](https://tanstack.com/start), [One](https://onestack.dev/), [Ember](https://emberjs.com/), and others. Web frameworks are innovating at an increasingly faster pace. You can check out the improvements folks have been doing at [Astro](https://astro.build/), [Nuxt](https://nuxt.com/), [SvelteKit](https://kit.svelte.dev/), [Solid Start](https://www.solidjs.com/blog/introducing-solidstart), [Qwik City](https://qwik.builder.io/qwikcity/overview/), [RedwoodJS](https://redwoodjs.com/), [React Router](https://reactrouter.com/), and the list goes on.

Vite is used by OpenAI, Google, Apple, Microsoft, NASA, Shopify, Cloudflare, GitLab, Reddit, Linear, among many others. Two months ago, we started a list of [companies using Vite](https://github.com/vitejs/companies-using-vite). We're happy to see many developers sending us a PR to add their companies to the list. It's hard to believe how much the ecosystem we built together has grown since Vite gave its first steps.

![Vite weekly npm downloads](/vite6-npm-weekly-downloads.png)

## Speeding up the Vite ecosystem

Last month, the community gathered for the third edition of [ViteConf](https://viteconf.org/24/replay), hosted once more by [StackBlitz](https://stackblitz.com). It was the biggest Vite conference, with a broad representation of builders from the ecosystem. Among other announcements, Evan You announced [VoidZero](https://staging.voidzero.dev/posts/announcing-voidzero-inc), a company dedicated to building an open-source, high-performance, and unified development toolchain for the JavaScript ecosystem. VoidZero is behind [Rolldown](https://rolldown.rs) and [Oxc](https://oxc.rs), and their team is making significant strides, getting them rapidly ready for being adopted by Vite. Watch Evan's keynote to learn more about the next steps for Vite's rust-powered future.

<YouTubeVideo videoId="EKvvptbTx6k?si=EZ-rFJn4pDW3tUvp" />

[Stackblitz](https://stackblitz.com) unveiled [bolt.new](https://bolt.new), a Remix app that combines Claude and WebContainers and lets you prompt, edit, run, and deploy full-stack apps. Nate Weiner announced [One](https://onestack.dev/), a new Vite-powered React framework for web and native. Storybook showcased their latest Vitest-powered [testing features](https://youtu.be/8t5wxrFpCQY?si=PYZoWKf-45goQYDt). And so much more. We encourage you to watch [all 43 talks](https://www.youtube.com/playlist?list=PLqGQbXn_GDmnObDzgjUF4Krsfl6OUKxtp). The speakers made a significant effort to share with us what each project has been up to.

Vite also got a refreshed landing page and a clean domain. You should update your URLs to point to the new [vite.dev](https://vite.dev) domain moving forward. The new design and implementation was done by VoidZero, by the same folks that made their website. Shoutout to [Vicente Rodriguez](https://bento.me/rmoon) and [Simon Le Marchant](https://marchantweb.com/).

## The next Vite major is here

Vite 6 is the most significant major release since Vite 2. We're eager to partner with the ecosystem to keep expanding our shared commons through new APIs and, as usual, a more polished base upon which to build.

Quick links:

- [Docs](/)
- Translations: [简体中文](https://cn.vite.dev/), [日本語](https://ja.vite.dev/), [Español](https://es.vite.dev/), [Português](https://pt.vite.dev/), [한국어](https://ko.vite.dev/), [Deutsch](https://de.vite.dev/)
- [Migration Guide](/guide/migration)
- [GitHub Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md#600-2024-11-26)

If you're new to Vite, we suggest reading the [Getting Started](/guide/) and [Features](/guide/features) guides first.

We want to thank the more than [1K contributors to Vite Core](https://github.com/vitejs/vite/graphs/contributors) and the maintainers and contributors of Vite plugins, integrations, tools, and translations that have helped us craft this new major. We invite you to get involved and help us improve Vite for the whole ecosystem. Learn more at our [Contributing Guide](https://github.com/vitejs/vite/blob/main/CONTRIBUTING.md).

To get started, we suggest helping [triage issues](https://github.com/vitejs/vite/issues), [review PRs](https://github.com/vitejs/vite/pulls), send failing tests PRs based on open issues, and support others in [Discussions](https://github.com/vitejs/vite/discussions) and Vite Land's [help forum](https://discord.com/channels/804011606160703521/1019670660856942652). If you'd like to talk to us, join our [Discord community](http://chat.vite.dev/) and say hi on the [#contributing channel](https://discord.com/channels/804011606160703521/804439875226173480).

For the latest news about the Vite ecosystem and Vite core, follow us on [Bluesky](https://bsky.app/profile/vite.dev), [X](https://twitter.com/vite_js), or [Mastodon](https://webtoo.ls/@vite).

## Getting started with Vite 6

You can use `pnpm create vite` to quickly scaffold a Vite app with your preferred framework or play online with Vite 6 using [vite.new](https://vite.new). You can also run `pnpm create vite-extra` to get access to templates from other frameworks and runtimes (Solid, Deno, SSR, and library starters). `create vite-extra` templates are also available when you run `create vite` under the `Others` option.

The Vite starter templates are intended to be used as a playground to test Vite with different frameworks. When building your next project, you should reach out to the starter recommended by each framework. `create vite` also provides a shortcut to setup proper starters by some frameworks, like `create-vue`, `Nuxt 3`, `SvelteKit`, `Remix`, `Analog`, and `Angular`.

## Node.js Support

Vite 6 supports Node.js 18, 20, and 22+, similar to Vite 5. Node.js 21 support has been dropped. Vite drops Node.js support for older versions after their [EOL](https://endoflife.date/nodejs). The Node.js 18 EOL is at the end of April 2025, after which we may release a new major to bump the required Node.js version.

## Experimental Environment API

Vite is getting more flexible with the new Environment API. These new APIs will allow framework authors to offer a dev experience closer to production and for the Ecosystem to share new building blocks. Nothing changes if you're building a SPA; when you use Vite with a single client environment, everything works as before. And even for custom SSR apps, Vite 6 is backward compatible. The primary target audience for Environment API is framework authors.

For end users who are curious, Sapphi wrote a great [Introduction to Environment API](https://green.sapphi.red/blog/increasing-vites-potential-with-the-environment-api) guide. It is a great place to start and understand why we're trying to make Vite even more flexible.

If you are a framework author or Vite plugin maintainer and would like to leverage the new APIs, you can learn more at the [Environment API Guides](https://main.vite.dev/guide/api-environment).

We want to thank everyone involved in defining and implementing the new APIs. Anthony Fu and Pooya Parsa made vite-node to improve [Nuxt's Dev SSR story](https://antfu.me/posts/dev-ssr-on-nuxt) with Vite. Then Anthony used vite-node to power Vitest, and Vladimir Sheremet kept improving it. At the beginning of 2023, Vladimir started working to upstream vite-node to Vite Core, and we released it as Runtime API in Vite 5.1 a year later. Feedback from ecosystem partners (special shout-out to the Cloudflare team) pushed us to do a more ambitious rework of Vite's environments. You can learn more about the story at [Patak's ViteConf 24 talk](https://www.youtube.com/watch?v=WImor3HDyqU?si=EZ-rFJn4pDW3tUvp).

Everyone on the Vite team participated in defining the new API, which was co-designed with feedback from many projects in the Ecosystem. Thanks to everyone involved! We encourage you to get involved if you're building a framework, plugin, or tool on top of Vite. The new APIs are experimental. We will work with the Ecosystem to review how the new APIs will be used and stabilize them for the next major. If you'd like to ask questions or give feedback, there is an [open GitHub discussion here](https://github.com/vitejs/vite/discussions/16358).

## Main Changes

- [Default value for `resolve.conditions`](/guide/migration#default-value-for-resolve-conditions)
- [JSON stringify](/guide/migration#json-stringify)
- [Extended support of asset references in HTML elements](/guide/migration#extended-support-of-asset-references-in-html-elements)
- [postcss-load-config](/guide/migration#postcss-load-config)
- [Sass now uses modern API by default](/guide/migration#sass-now-uses-modern-api-by-default)
- [Customize CSS output file name in library mode](/guide/migration#customize-css-output-file-name-in-library-mode)
- [And more changes that should only affect a few users](/guide/migration#advanced)

There is also a new [Breaking Changes](/changes/) page that lists all planned, considering, and past changes in Vite.

## Migrating to Vite 6

For most projects, the update to Vite 6 should be straightforward, but we advise reviewing the [detailed Migration Guide](/guide/migration) before upgrading.

The complete list of changes is at the [Vite 6 Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md#500-2024-11-26).

## Acknowledgments

Vite 6 results from long work hours by our community of contributors, downstream maintainers, plugin authors, and the [Vite Team](/team). We appreciate the individuals and companies sponsoring Vite development. Vite is brought to you by [VoidZero](https://voidzero.dev), in partnership with [StackBlitz](https://stackblitz.com/), [Nuxt Labs](https://nuxtlabs.com/), and [Astro](https://astro.build). A shout-out to sponsors on [Vite's GitHub Sponsors](https://github.com/sponsors/vitejs) and [Vite's Open Collective](https://opencollective.com/vite).
8 changes: 4 additions & 4 deletions changes/ssr-using-modulerunner.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
可以在 [环境 API 讨论](https://github.com/vitejs/vite/discussions/16358) 中向我们提供反馈
:::

`server.ssrLoadModule` 已经被 [Module Runner](/guide/api-environment#modulerunner) 取代
`server.ssrLoadModule` 已被从 [Module Runner](/guide/api-environment#modulerunner) 导入所取代

影响范围:`Vite 插件作者`

::: warning 即将废弃
`ModuleRunner` 最初在 `v6.0` 版本中被引入。我们计划在未来的主要版本中废弃 `server.ssrLoadModule`。如果想识别你的使用情况,可以在你的 vite 配置文件中将 `future.removeSrLoadModule` 设置为 `"warn"`
`ModuleRunner` 最初在 `v6.0` 版本中被引入。我们计划在未来的主要版本中废弃 `server.ssrLoadModule`。如果想识别你的使用情况,可以在你的 vite 配置文件中将 `future.removeSsrLoadModule` 设置为 `"warn"`
:::

## 动机 {#motivation}

// TODO: (保持原文)
`server.ssrLoadModule(url)` 仅允许在 `ssr` 环境中导入模块,并且只能在与 Vite 开发服务器相同的进程中执行这些模块。对于具有自定义环境的应用程序,每个环境都关联一个 `ModuleRunner`,该模块可能在单独的线程或进程中运行。为了导入模块,我们现在使用 `moduleRunner.import(url)`

## 迁移指南 {#migration-guide}

// TODO: (保持原文)
请查看 [用于框架的环境 API 指南](../guide/api-environment-frameworks.md)
30 changes: 26 additions & 4 deletions guide/api-environment-instances.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,25 +63,43 @@ class DevEnvironment {
*/
config: ResolvedConfig & ResolvedDevEnvironmentOptions

constructor(name, config, { hot, options }: DevEnvironmentSetup)
constructor(
name: string,
config: ResolvedConfig,
context: DevEnvironmentContext,
)

/**
* 解析 URL 到一个 id,加载它,并使用插件管道
* 处理代码。模块图也会被更新。
*/
async transformRequest(url: string): TransformResult
async transformRequest(url: string): Promise<TransformResult | null>

/**
* 注册一个低优先级处理的请求。这对于避免瀑布效应
* 非常有用。Vite 服务器有关于其他请求导入模块的
* 信息,因此它可以预热模块图,使得当模块被请求时
* 已经处理完毕。
*/
async warmupRequest(url: string): void
async warmupRequest(url: string): Promise<void>
}
```

其中 `TransformResult` 是:
其中 `DevEnvironmentContext`是:

```ts
interface DevEnvironmentContext {
hot: boolean
transport?: HotChannel | WebSocketServer
options?: EnvironmentOptions
remoteRunner?: {
inlineSourceMap?: boolean
}
depsOptimizer?: DepsOptimizer
}
```

`TransformResult` 是:

```ts
interface TransformResult {
Expand Down Expand Up @@ -155,10 +173,14 @@ export class EnvironmentModuleGraph {
rawUrl: string,
): Promise<EnvironmentModuleNode | undefined>

getModuleById(id: string): EnvironmentModuleNode | undefined

getModulesByFile(file: string): Set<EnvironmentModuleNode> | undefined

onFileChange(file: string): void

onFileDelete(file: string): void

invalidateModule(
mod: EnvironmentModuleNode,
seen: Set<EnvironmentModuleNode> = new Set(),
Expand Down
33 changes: 28 additions & 5 deletions guide/api-environment-runtimes.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ function createWorkerdDevEnvironment(
export class ModuleRunner {
constructor(
public options: ModuleRunnerOptions,
public evaluator: ModuleEvaluator,
public evaluator: ModuleEvaluator = new ESModulesEvaluator(),
private debug?: ModuleRunnerDebugger,
) {}
/**
Expand Down Expand Up @@ -165,8 +165,21 @@ await moduleRunner.import('/src/entry-point.js')

## `ModuleRunnerOptions`

```ts
export interface ModuleRunnerOptions {
```ts twoslash
import type {
InterceptorOptions as InterceptorOptionsRaw,
ModuleRunnerHmr as ModuleRunnerHmrRaw,
EvaluatedModules,
} from 'vite/module-runner'
import type { Debug } from '@type-challenges/utils'

type InterceptorOptions = Debug<InterceptorOptionsRaw>
type ModuleRunnerHmr = Debug<ModuleRunnerHmrRaw>
/** 见下文 */
type ModuleRunnerTransport = unknown

// ---cut---
interface ModuleRunnerOptions {
/**
* 项目根目录
*/
Expand Down Expand Up @@ -206,7 +219,13 @@ export interface ModuleRunnerOptions {

**类型签名:**

```ts
```ts twoslash
import type { ModuleRunnerContext as ModuleRunnerContextRaw } from 'vite/module-runner'
import type { Debug } from '@type-challenges/utils'

type ModuleRunnerContext = Debug<ModuleRunnerContextRaw>

// ---cut---
export interface ModuleEvaluator {
/**
* 转换后代码中前缀行的数量。
Expand Down Expand Up @@ -237,7 +256,11 @@ Vite 默认导出了实现此接口的 `ESModulesEvaluator`。它使用 `new Asy

**类型签名:**

```ts
```ts twoslash
import type { ModuleRunnerTransportHandlers } from 'vite/module-runner'
/** 一个对象 */
type HotPayload = unknown
// ---cut---
interface ModuleRunnerTransport {
connect?(handlers: ModuleRunnerTransportHandlers): Promise<void> | void
disconnect?(): Promise<void> | void
Expand Down
2 changes: 1 addition & 1 deletion guide/performance.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Vite 的内部和官方插件已经优化,以在提供与更广泛的生态系
如果你是插件作者,请确保只在需要时调用 [`this.resolve`](https://rollupjs.org/plugin-development/#this-resolve) 以减少上述检查的次数。

::: tip TypeScript
如果你正在使用 TypeScript,启用 `tsconfig.json` 中的 `compilerOptions``"moduleResolution": "Bundler"``"allowImportingTsExtensions": true` 以直接在代码中使用 `.ts``.tsx` 扩展名。
如果你正在使用 TypeScript,启用 `tsconfig.json` 中的 `compilerOptions``"moduleResolution": "bundler"``"allowImportingTsExtensions": true` 以直接在代码中使用 `.ts``.tsx` 扩展名。
:::

## 避免使用桶文件 {#avoid-barrel-files}
Expand Down
Loading

0 comments on commit 69b416f

Please sign in to comment.