Skip to content

Commit

Permalink
Merge pull request #926 from HammCn/patch-2
Browse files Browse the repository at this point in the history
docs: Update philosophy.md
  • Loading branch information
waynzh committed Mar 13, 2024
2 parents 6611f7b + fe1337e commit 11b2522
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions guide/philosophy.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
# Project Philosophy
# 项目理念 {#project-philosophy}

## Lean Extendable Core
## 精简且可扩展的核心 {#lean-extendable-core}

Vite doesn't intend to cover every use case for every user. Vite aims to support the most common patterns to build Web apps out-of-the-box, but [Vite core](https://github.com/vitejs/vite) must remain lean with a small API surface to keep the project maintainable long-term. This goal is possible thanks to [Vite's rollup-based plugin system](./api-plugin.md). Features that can be implemented as external plugins will generally not be added to Vite core. [vite-plugin-pwa](https://vite-pwa-org.netlify.app/) is a great example of what can be achieved out of Vite core, and there are a lot of [well maintained plugins](https://github.com/vitejs/awesome-vite#plugins) to cover your needs. Vite works closely with the Rollup project to ensure that plugins can be used in both plain-rollup and Vite projects as much as possible, trying to push needed extensions to the Plugin API upstream when possible.
Vite 的目标不在于满足所有用户的每一个使用场景。Vite 旨在开箱即用地支持构建 Web 应用的最常见的模式,但 [Vite 核心包](https://github.com/vitejs/vite) 必须保持精简并拥有较小的 API 接口,以保证项目长期维护的可行性。这一目标之所以可能实现,得益于 [Vite 基于 Rollup 的插件系统](./api-plugin.md) 。可以作为外部插件实现的功能通常不会添加到 Vite 核心中。 [vite-plugin-pwa](https://vite-pwa-org.netlify.app/) 是一个很好的示例,展示了 Vite 核心之外能实现的强大功能,并且有许多 [维护良好的插件](https://github.com/vitejs/awesome-vite#plugins) 来满足您的需求。Vite 与 Rollup 项目紧密合作,确保插件在尽可能多的情况下既可用于纯 Rollup 项目,也可用于 Vite 项目,并努力将必要的扩展推送到上游 Plugin API 中。

## Pushing the Modern Web
## 推动现代 Web 开发 {#pushing-the-modern-web}

Vite provides opinionated features that pushes writing modern code. For example:
Vite 提供了一系列推动编写现代代码的特定功能。例如:

- The source code can only be written in ESM, where non-ESM dependencies needs to be [pre-bundled as ESM](./dep-pre-bundling) in order to work.
- Web workers are encouraged to be written with the [`new Worker` syntax](./features#web-workers) to follow modern standards.
- Node.js modules cannot be used in the browser.
- 源代码必须采用 ESM 形式编写;对于非 ESM 的依赖项,为了使其正常工作,需要 [预先将其打包为 ESM](./dep-pre-bundling)
- 建议使用 [`new Worker` 语法](./features#web-workers) 来编写 Web Workers,以遵循现代标准。
- 在浏览器环境下,不能直接使用 Node.js 模块。

When adding new features, these patterns are followed to create a future-proof API, which may not always be compatible with other build tools.
在新增特性时,会遵循这些模式来构建一个具备前瞻性的 API,但请注意,这样的API可能并不总是与其它构建工具兼容。

## A Pragmatic Approach to Performance
## 旨在高性能的实用解决方案 {#a-pragmatic-approach-to-performance}

Vite has been focused on performance since its [origins](./why.md). Its dev server architecture allows HMR that stays fast as projects scale. Vite uses native tools like [esbuild](https://esbuild.github.io/) and [SWC](https://github.com/vitejs/vite-plugin-react-swc) to implement intensive tasks but keeps the rest of the code in JS to balance speed with flexibility. When needed, framework plugins will tap into [Babel](https://babeljs.io/) to compile user code. And during build time Vite currently uses [Rollup](https://rollupjs.org/) where bundling size and having access to a wide ecosystem of plugins are more important than raw speed. Vite will continue to evolve internally, using new libraries as they appear to improve DX while keeping its API stable.
Vite 自其诞生之初(详见:[为什么选 Vite](./why.md))就一直致力于性能优化。其开发服务器架构设计确保了随着项目规模扩大,热模块替换(HMR)仍能保持高速运行。Vite 采用类似 [esbuild](https://esbuild.github.io/) [SWC](https://github.com/vitejs/vite-plugin-react-swc) 这样的原生工具处理复杂的任务,同时将其他部分代码保留在 JavaScript 中,以实现速度与灵活性之间的平衡。在需要时,框架插件会利用 [Babel](https://babeljs.io/) 来编译用户代码。构建阶段,Vite 当前使用的是 [Rollup](https://rollupjs.org/) ,此时包体积大小以及能够接入广泛生态系统的插件比原始速度更重要。Vite 将持续内部改进和发展,在新库出现时适时采用以提升开发者体验(DX),同时保持 API 的稳定性。

## Building Frameworks on top of Vite
## 基于 Vite 构建框架 {#building-frameworks-on-top-of-vite}

Although Vite can be used by users directly, it shines as a tool to create frameworks. Vite core is framework agnostic, but there are polished plugins for each UI frameworks. Its [JS API](./api-javascript.md) allows App Framework authors to use Vite features to create tailored experiences for their users. Vite includes support for [SSR primitives](./ssr.md), usually present in higher-level tools but fundamental to building modern web frameworks. And Vite plugins complete the picture by offering a way to share between frameworks. Vite is also a great fit when paired with [Backend frameworks](./backend-integration.md) like [Ruby](https://vite-ruby.netlify.app/) and [Laravel](https://laravel.com/docs/10.x/vite).
尽管 Vite 可以直接供用户使用,但它尤其适合作为创建框架的工具。Vite 核心本身不特定于任何框架,但针对每个 UI 框架都提供了完善的插件支持。其 [JS API](./api-javascript.md) 允许应用框架作者利用 Vite 特性为他们的用户提供定制化的体验。Vite 包含了对 [SSR 基础功能](./ssr.md) 的支持,这些功能通常在更高级别的工具中出现,但对于构建现代 Web 框架至关重要。Vite 插件通过提供一种跨框架共享的方式,使整体方案更为完备。此外,当与诸如 [Ruby](https://vite-ruby.netlify.app/) [Laravel](https://laravel.com/docs/10.x/vite)[后端框架](./backend-integration.md) 结合使用时,Vite 也是一个绝佳选择。

## An Active Ecosystem
## 活跃的生态系统 {#an-active-ecosystem}

Vite evolution is a cooperation between framework and plugin maintainers, users, and the Vite team. We encourage active participation in Vite's Core development once a project adopts Vite. We work closely with the main projects in the ecosystem to minimize regressions on each release, aided by tools like [vite-ecosystem-ci](https://github.com/vitejs/vite-ecosystem-ci). It allows us to run the CI of major projects using Vite on selected PRs and gives us a clear status of how the Ecosystem would react to a release. We strive to fix regressions before they hit users and allow projects to update to the next versions as soon as they are released. If you are working with Vite, we invite you to join [Vite's Discord](https://chat.vitejs.dev) and get involved in the project too.
Vite 的发展是一个由框架和插件维护者、用户以及 Vite 团队共同协作的过程。我们鼓励当项目采用 Vite 时,也可以积极参与 Vite 核心开发。我们借助如 [vite-ecosystem-ci](https://github.com/vitejs/vite-ecosystem-ci) 等工具与生态中的主要项目紧密合作,在每次发布时尽量减少回归问题。该工具允许我们在选定的 PR 上运行使用 Vite 的主要项目的 CI,并让我们清晰了解生态系统对新版本发布的反应情况。我们力求在问题影响到用户之前修复回归问题,确保项目能够尽快更新至最新版本。如果您正在使用 Vite,我们诚邀您加入 [Vite Discord 频道](https://chat.vitejs.dev) ,一同参与项目的发展。

0 comments on commit 11b2522

Please sign in to comment.