HMR API Vite 官方中文文档

Vite keeps getting faster with each release, and Vite 5.1 is packed with performance improvements. The preview server now exposes a close method, which will properly teardown the server including all opened socket connections. This new option can be used to force externalize all packages including linked packages too. Worker 选项 Vite 官方中文文档

配置 Vite ​

  • A shout out to the individuals and companies sponsoring Vite development.
  • Vite keeps getting faster with each release, and Vite 5.1 is packed with performance improvements.
  • Build-time pre-bundling, an experimental feature added in Vite 3, is removed.
  • Rolldown may also implement caching in a way that is a lot more efficient during build than deps prebundling.
  • In Vite 4.0, loading 10K modules took 8 seconds on a M1 MAX.
  • This new option can be used to force externalize all packages including linked packages too.
  • The initial idea was proposed by Pooya Parsa and implemented by Anthony Fu as the vite-node package to power Nuxt 3 Dev SSR and later also used as the base for Vitest.
  • In Vite 5.1, we managed to do another performance leap.
Vite 5.1 adds experimental support for a new Vite Runtime API. Vite 5 was released last November, and it represented another big leap for Vite and the ecosystem. 请使用 worker.rolldownOptions 选项代替。

Vite 6 的到来 ​

Historically, Vite externalizes all packages except for linked packages. Import CSS files as URLs now works reliably and correctly. The Vite Runtime API evolved into the Module Runner API, released in Vite 6 as part of the Environment API. The PR was one year in the makings, you can see the evolution and discussions with ecosystem maintainers here. The initial idea was proposed by Pooya Parsa and implemented by Anthony Fu as the vite-node package to power Nuxt 3 Dev SSR and later also used as the base for Vitest. 以字符串形式导入 CSS ​

实验性环境 API ​

It is different from server.ssrLoadModule because the runtime implementation is decoupled from the server. For example, r + Enter to restart the dev server. 当你在 create vite 下选择 Others 选项时,也可以使用 create vite-extra 模板。 你还可以运行 pnpm create vite-extra 以获取其他框架和运行时(Solid、Deno、SSR 和库起始模板)的模板。 重新设计 define 和 import.meta.env.* 的替换策略 ​
Support ssr.external: true to externalize all SSR packages ​
  • So the general idea of vite-node has been battle-tested for quite some time now.
  • Vite is now serving the 10K modules in 5.35 seconds.
  • For example, r + Enter to restart the dev server.
  • From Vite 5, those will be generated in the .vite directory in the build.outDir by default.
  • 你还可以运行 pnpm create vite-extra 以获取其他框架和运行时(Solid、Deno、SSR 和库起始模板)的模板。
  • Vite 5.1 is possible thanks to our community of contributors, maintainers in the ecosystem, and the Vite Team.
  • If you were relying on one of them, please create a feature request.
We measured the loading time for 10K modules (25 level deep tree) using vite-dev-server-perf for all minor versions from Vite 4.0. Instead change the require of index.js in /path/to/vite.config.js to a dynamic import() which is available in all CommonJS modules. The dev server had several incremental performance gains. 重新设计 define 和 import.meta.env.* 的替换策略 ​
worker.rolldownOptions ​
检查 rolldownVersion export 的存在: 检查 this.meta.rolldownVersion 的存在: This package is ESM only but it was tried to load by require.
Manifest 文件现在默认生成到 .vite 目录中 ​
  • In Vite 5.0, accepted modules within circular imports always triggered a full page reload even if they can be handled fine in the client.
  • Vite 5.1 adds experimental support for a new Vite Runtime API.
  • This lets library and framework authors implement their own layer of communication between the server and the runtime.
  • It is different from server.ssrLoadModule because the runtime implementation is decoupled from the server.
  • For a Vuetify 2 project, dev startup time was reduced by 40% with this feature enabled.
  • We are grateful to the 900 contributors to Vite Core, and the maintainers of plugins, integrations, tools, and translations that keeps pushing the ecosystem forward.
CLI shortcuts, like r to restart the dev server, now require an additional Enter press to trigger the shortcut. For a Vuetify 2 project, dev startup time was reduced by 40% with this feature enabled. This lets library and framework authors implement their own layer of communication between the server and the runtime.

Rolldown 是什么? ​

  • The Vite Runtime API evolved into the Module Runner API, released in Vite 6 as part of the Environment API.
  • CLI shortcuts, like r to restart the dev server, now require an additional Enter press to trigger the shortcut.
  • The PR was one year in the makings, you can see the evolution and discussions with ecosystem maintainers here.
  • 检查 rolldownVersion export 的存在:
  • 请使用 worker.rolldownOptions 选项代替。
  • The dev server had several incremental performance gains.
  • There is performance comparison for others setups in the PR.
  • Instead change the require of index.js in /path/to/vite.config.js to a dynamic import() which is available in all CommonJS modules.
  • This package is ESM only but it was tried to load by require.
There is performance comparison for others setups in the PR. They don't represent the time as experienced by users though. In Vite 5.1, we managed to do another performance leap. We had a breakthrough in Vite 4.3 were we focused on performance, and we were able to load them in 6.35 seconds.
  • Vite is now serving the 10K modules in 5.35 seconds.
  • If you were relying on one of them, please create a feature request.
  • 当你在 create vite 下选择 Others 选项时,也可以使用 create vite-extra 模板。
  • Vite 5.1 is possible thanks to our community of contributors, maintainers in the ecosystem, and the Vite Team.
  • For example, r + Enter to restart the dev server.
  • 你还可以运行 pnpm create vite-extra 以获取其他框架和运行时(Solid、Deno、SSR 和库起始模板)的模板。

Request Header Fields Too Large ​

Vite 5.1 is possible thanks to our community of contributors, maintainers in the ecosystem, and the Vite Team. If you're enjoying Vite, we invite you to participate and help us. We are grateful to the 900 contributors to Vite Core, and the maintainers of plugins, integrations, tools, and translations that keeps pushing the ecosystem forward. Rolldown may also implement caching in a way that is a lot more efficient during build than deps prebundling.
  • If you were relying on one of them, please create a feature request.
  • 你还可以运行 pnpm create vite-extra 以获取其他框架和运行时(Solid、Deno、SSR 和库起始模板)的模板。
  • Vite is now serving the 10K modules in 5.35 seconds.
  • We had a breakthrough in Vite 4.3 were we focused on performance, and we were able to load them in 6.35 seconds.
  • So the general idea of vite-node has been battle-tested for quite some time now.
  • For example, r + Enter to restart the dev server.
  • If you're enjoying Vite, we invite you to participate and help us.
  • Vite 5.1 is possible thanks to our community of contributors, maintainers in the ecosystem, and the Vite Team.
Build-time pre-bundling, an experimental feature added in Vite 3, is removed. Vite is now serving the 10K modules in 5.35 seconds. In Vite 4.0, loading 10K modules took 8 seconds on a M1 MAX.
  • There is performance comparison for others setups in the PR.
  • CLI shortcuts, like r to restart the dev server, now require an additional Enter press to trigger the shortcut.
  • 请使用 worker.rolldownOptions 选项代替。
  • The dev server had several incremental performance gains.
  • The PR was one year in the makings, you can see the evolution and discussions with ecosystem maintainers here.
  • This package is ESM only but it was tried to load by require.
  • 检查 rolldownVersion export 的存在:
  • In Vite 5.0, accepted modules within circular imports always triggered a full page reload even if they can be handled fine in the client.
  • Vite 5.1 adds experimental support for a new Vite Runtime API.
  • For a Vuetify 2 project, dev startup time was reduced by 40% with this feature enabled.
  • This lets library and framework authors implement their own layer of communication between the server and the runtime.
  • It is different from server.ssrLoadModule because the runtime implementation is decoupled from the server.
In Vite 5.0, accepted modules within circular imports always triggered a full page reload even if they can be handled fine in the client. So the general idea of vite-node has been battle-tested for quite some time now. From Vite 5, those will be generated in the .vite directory in the build.outDir by default. If you were relying on one of them, please create a feature request. A shout out to the individuals and companies sponsoring Vite development.