Skip to content

Commit be0166c

Browse files
committed
docs(cn): resolve conflicts
1 parent 48552d0 commit be0166c

File tree

8 files changed

+7
-67
lines changed

8 files changed

+7
-67
lines changed

config/dep-optimization-options.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,7 @@ export default defineConfig({
8282
- **类型:** `boolean`
8383
- **默认:** `true`
8484

85-
<<<<<<< HEAD
8685
当该功能被启用时,系统会在冷启动时保持第一个优化的依赖结果,直到所有的静态导入都被检索完毕。这样可以避免因为发现新的依赖项而触发新的公共 chunk 生成,从而需要刷新整个页面。如果通过扫描和在 `include` 中明确定义的方式能找到所有的依赖项,那么最好关闭这个功能,这样浏览器可以并行处理更多的请求。
87-
=======
88-
When enabled, it will hold the first optimized deps results until all static imports are crawled on cold start. This avoids the need for full-page reloads when new dependencies are discovered and they trigger the generation of new common chunks. If all dependencies are found by the scanner plus the explicitly defined ones in `include`, it is better to disable this option to let the browser process more requests in parallel.
89-
>>>>>>> cfa53198f6c859029ffa3fd28b08724973a8867b
9086

9187
## optimizeDeps.disabled {#optimizedeps-disabled}
9288

config/ssr-options.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,7 @@ SSR 服务器的构建目标。
3434
- **类型:** `string[]`
3535
- **相关:** [解析情景](./shared-options.md#resolve-conditions)
3636

37-
<<<<<<< HEAD
3837
在 SSR 构建中,包入口的解析条件。默认为 [`resolve.conditions`](./shared-options.md#resolve-conditions)
39-
=======
40-
Defaults to the root [`resolve.conditions`](./shared-options.md#resolve-conditions).
41-
>>>>>>> cfa53198f6c859029ffa3fd28b08724973a8867b
4238

4339
这些条件会在插件管道中使用,并且只会影响 SSR 构建期间的非外部化依赖项。使用 `ssr.resolve.externalConditions` 来影响外部化导入。
4440

guide/env-and-mode.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,7 @@ interface ImportMeta {
9494
}
9595
```
9696
97-
<<<<<<< HEAD
98-
如果你的代码依赖于浏览器环境的类型,比如 [DOM](https://github.com/microsoft/TypeScript/blob/main/lib/lib.dom.d.ts) 和 [WebWorker](https://github.com/microsoft/TypeScript/blob/main/lib/lib.webworker.d.ts),你可以在 `tsconfig.json` 中修改 [lib](https://www.typescriptlang.org/tsconfig#lib) 字段来获取类型支持。
99-
=======
100-
If your code relies on types from browser environments such as [DOM](https://github.com/microsoft/TypeScript/blob/main/src/lib/dom.generated.d.ts) and [WebWorker](https://github.com/microsoft/TypeScript/blob/main/src/lib/webworker.generated.d.ts), you can update the [lib](https://www.typescriptlang.org/tsconfig#lib) field in `tsconfig.json`.
101-
>>>>>>> cfa53198f6c859029ffa3fd28b08724973a8867b
97+
如果你的代码依赖于浏览器环境的类型,比如 [DOM](https://github.com/microsoft/TypeScript/blob/main/src/lib/dom.generated.d.ts) 和 [WebWorker](https://github.com/microsoft/TypeScript/blob/main/src/lib/webworker.generated.d.ts),你可以在 `tsconfig.json` 中修改 [lib](https://www.typescriptlang.org/tsconfig#lib) 字段来获取类型支持。
10298
10399
```json
104100
{

guide/index.md

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,9 @@ npm install
105105
npm run dev
106106
```
107107

108-
<<<<<<< HEAD
109-
## `index.html` 与项目根目录 {#index-html-and-project-root}
110-
=======
111-
## Manual Installation
108+
## 手动安装 {#manual-installation}
112109

113-
In your project, you can install the `vite` CLI using:
110+
在你的项目中,可以用以下方法来安装 `vite` 命令行工具:
114111

115112
::: code-group
116113

@@ -132,22 +129,21 @@ $ bun add -D vite
132129

133130
:::
134131

135-
And create an `index.html` file like this:
132+
并创建一个像这样的 `index.html` 文件:
136133

137134
```html
138135
<p>Hello Vite!</p>
139136
```
140137

141-
Then run the `vite` CLI in your terminal:
138+
然后在终端中运行 `vite`
142139

143140
```bash
144141
vite
145142
```
146143

147-
The `index.html` will be served on `http://localhost:5173`.
144+
`index.html` 将在 `http://localhost:5173` 上被访问。
148145

149-
## `index.html` and Project Root
150-
>>>>>>> cfa53198f6c859029ffa3fd28b08724973a8867b
146+
## `index.html` 与项目根目录 {#index-html-and-project-root}
151147

152148
你可能已经注意到,在一个 Vite 项目中,`index.html` 在项目最外层而不是在 `public` 文件夹内。这是有意而为之的:在开发期间 Vite 是一个服务器,而 `index.html` 是该 Vite 项目的入口文件。
153149

guide/migration.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,9 @@ CJS 的 Node API 已经被废弃。当调用 `require('vite')` 时,将会记
2828

2929
对于其他项目,有几种常见的方法:
3030

31-
<<<<<<< HEAD
3231
- **配置 ESM 为默认,如果需要则选择 CJS:** 在项目 `package.json` 中添加 `"type": "module"`。所有 `*.js` 文件现在都被解释为 ESM,并且需要使用 ESM 语法。你可以将一个文件重命名为 `.cjs` 扩展名来继续使用 CJS。
3332
- **保持 CJS 为默认,如果需要则选择 ESM:** 如果项目 `package.json` 没有 `"type": "module"`,所有 `*.js` 文件都被解释为 CJS。你可以将一个文件重命名为 `.mjs` 扩展名来使用 ESM。
3433
- **动态导入 Vite:** 如果你需要继续使用 CJS,你可以使用 `import('vite')` 动态导入 Vite。这要求你的代码必须在一个 `async` 上下文中编写,但是由于 Vite 的 API 大多是异步的,所以应该还是可以管理的。
35-
=======
36-
- **Configure ESM as default, opt-in to CJS if needed:** Add `"type": "module"` in the project `package.json`. All `*.js` files are now interpreted as ESM and need to use the ESM syntax. You can rename a file with the `.cjs` extension to keep using CJS instead.
37-
- **Keep CJS as default, opt-in to ESM if needed:** If the project `package.json` does not have `"type": "module"`, all `*.js` files are interpreted as CJS. You can rename a file with the `.mjs` extension to use ESM instead.
38-
- **Dynamically import Vite:** If you need to keep using CJS, you can dynamically import Vite using `import('vite')` instead. This requires your code to be written in an `async` context, but should still be manageable as Vite's API is mostly asynchronous.
39-
>>>>>>> cfa53198f6c859029ffa3fd28b08724973a8867b
4034

4135
查看 [排错指南](/guide/troubleshooting.html#vite-cjs-node-api-deprecated) 获取更多信息。
4236

@@ -102,11 +96,7 @@ import * as _foo from 'bar'
10296
const foo = _foo.default
10397
```
10498

105-
<<<<<<< HEAD
10699
注意,这些更改符合 Node.js 的行为,因此也可以在 Node.js 中运行这些导入进行测试。如果你更喜欢坚持使用之前的方式,你可以将 `legacy.proxySsrExternalModules` 设置为 `true`
107-
=======
108-
Note that these changes match the Node.js behaviour, so you can also run the imports in Node.js to test it out. If you prefer to stick with the previous behaviour, you can set `legacy.proxySsrExternalModules` to `true`.
109-
>>>>>>> cfa53198f6c859029ffa3fd28b08724973a8867b
110100

111101
### `worker.plugins` 现在是一个函数 {#worker-plugins-is-now-a-function}
112102

guide/performance.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@
1010

1111
有些浏览器插件可能会干涉请求,对于大型应用,特别是在使用浏览器开发工具时,可能会拖慢启动和刷新速度。我们建议在这种情况下,使用 Vite 的开发服务器时,创建一个专门用于开发且不含插件的配置,或者切换到无痕模式。无痕模式的速度也应该比没有插件的常规模式更快。
1212

13-
<<<<<<< HEAD
1413
Vite 开发服务器对预打包的依赖项进行了强缓存,同时对源代码实现快速的 304 响应。如果在浏览器的开发者工具打开的情况下关闭缓存,可能会大幅影响启动速度和全页刷新的时间。因此,在使用 Vite 服务器的时候,请确保没有启用 "禁用缓存" 功能。
15-
=======
16-
The Vite dev server does hard caching of pre-bundled dependencies and implements fast 304 responses for source code. Disabling the cache while the Browser Dev Tools are open can have a big impact on startup and full-page reload times. Please check that "Disable Cache" isn't enabled while you work with the Vite server.
17-
>>>>>>> cfa53198f6c859029ffa3fd28b08724973a8867b
1814

1915
## 审核配置的 Vite 插件 {#audit-configured-vite-plugins}
2016

guide/philosophy.md

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,11 @@ Vite 的目标不在于满足所有用户的每一个使用场景。Vite 旨在
66

77
## 推动现代 Web 开发 {#pushing-the-modern-web}
88

9-
<<<<<<< HEAD
109
Vite 提供了一系列推动编写现代代码的特定功能。例如:
1110

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

2315
在新增特性时,会遵循这些模式来构建一个具备前瞻性的 API,但请注意,这样的API可能并不总是与其它构建工具兼容。
2416

@@ -28,11 +20,7 @@ Vite 自其诞生之初(详见:[为什么选 Vite](./why.md))就一直致
2820

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

31-
<<<<<<< HEAD
3223
尽管 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 也是一个绝佳选择。
33-
=======
34-
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 framework. 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).
35-
>>>>>>> cfa53198f6c859029ffa3fd28b08724973a8867b
3624

3725
## 活跃的生态系统 {#an-active-ecosystem}
3826

guide/troubleshooting.md

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,9 @@ Vite 的 CJS Node API 构建已经被废弃,并将在 Vite 6 中移除。查
1717

1818
对于其他项目,有几种常见的方法:
1919

20-
<<<<<<< HEAD
2120
- **配置 ESM 为默认,如果需要则选择 CJS:** 在项目 `package.json` 中添加 `"type": "module"`。所有 `*.js` 文件现在都被解释为 ESM,并且需要使用 ESM 语法。你可以将一个文件重命名为 `.cjs` 扩展名来继续使用 CJS。
2221
- **保持 CJS 为默认,如果需要则选择 ESM:** 如果项目 `package.json` 没有 `"type": "module"`,所有 `*.js` 文件都被解释为 CJS。你可以将一个文件重命名为 `.mjs` 扩展名来使用 ESM。
2322
- **动态导入 Vite:** 如果你需要继续使用 CJS,你可以使用 `import('vite')` 动态导入 Vite。这要求你的代码必须在一个 `async` 上下文中编写,但是由于 Vite 的 API 大多是异步的,所以应该还是可以管理的。
24-
=======
25-
- **Configure ESM as default, opt-in to CJS if needed:** Add `"type": "module"` in the project `package.json`. All `*.js` files are now interpreted as ESM and need to use the ESM syntax. You can rename a file with the `.cjs` extension to keep using CJS instead.
26-
- **Keep CJS as default, opt-in to ESM if needed:** If the project `package.json` does not have `"type": "module"`, all `*.js` files are interpreted as CJS. You can rename a file with the `.mjs` extension to use ESM instead.
27-
- **Dynamically import Vite:** If you need to keep using CJS, you can dynamically import Vite using `import('vite')` instead. This requires your code to be written in an `async` context, but should still be manageable as Vite's API is mostly asynchronous.
28-
>>>>>>> cfa53198f6c859029ffa3fd28b08724973a8867b
2923

3024
如果你不确定警告来自哪里,你可以通过 `VITE_CJS_TRACE=true` 标志运行你的脚本来记录堆栈跟踪:
3125

@@ -39,11 +33,7 @@ VITE_CJS_TRACE=true vite dev
3933
VITE_CJS_IGNORE_WARNING=true vite dev
4034
```
4135

42-
<<<<<<< HEAD
4336
请注意,postcss 配置文件还不支持 ESM + TypeScript(`"type": "module"` 中的 `.mts``.ts`)。如果你有带 `.ts` 的 postcss 配置,并在 package.json 中添加了 `"type": "module"`,你还需要将 postcss 配置重命名为 `.cts`
44-
=======
45-
Note that postcss config files do not support ESM + TypeScript (`.mts` or `.ts` in `"type": "module"`) yet. If you have postcss configs with `.ts` and added `"type": "module"` to package.json, you'll also need to rename the postcss config to use `.cts`.
46-
>>>>>>> cfa53198f6c859029ffa3fd28b08724973a8867b
4737

4838
## CLI {#cli}
4939

@@ -179,11 +169,7 @@ import './Foo.js' // 应该为 './foo.js'
179169

180170
### 链接本地包时过期预构建依赖项 {#outdated-pre-bundled-deps-when-linking-to-a-local-package}
181171

182-
<<<<<<< HEAD
183172
在 Vite 中通过一个哈希值来决定优化后的依赖项是否有效,这个值取决于包锁定的内容、应用于依赖项的补丁以及 Vite 配置文件中影响 node_modules 打包的选项。这意味着,当使用像 [npm overrides](https://docs.npmjs.com/cli/v9/configuring-npm/package-json#overrides) 这样的功能覆盖依赖项时,Vite 将检测到,并在下一次服务器启动时重新打包您的依赖项。当您使用像 [npm link](https://docs.npmjs.com/cli/v9/commands/npm-link) 这样的功能时,Vite 不会使依赖项无效。如果您链接或取消链接一个依赖项,那么您需要使用 `vite --force` 在下一次服务器启动时强制重新预构建。我们建议使用 overrides,它们现在被每个包管理器所支持(还可以参见 [pnpm overrides](https://pnpm.io/package_json#pnpmoverrides)[yarn resolutions](https://yarnpkg.com/configuration/manifest/#resolutions))。
184-
=======
185-
The hash key used to invalidate optimized dependencies depends on the package lock contents, the patches applied to dependencies, and the options in the Vite config file that affects the bundling of node modules. This means that Vite will detect when a dependency is overridden using a feature as [npm overrides](https://docs.npmjs.com/cli/v9/configuring-npm/package-json#overrides), and re-bundle your dependencies on the next server start. Vite won't invalidate the dependencies when you use a feature like [npm link](https://docs.npmjs.com/cli/v9/commands/npm-link). In case you link or unlink a dependency, you'll need to force re-optimization on the next server start by using `vite --force`. We recommend using overrides instead, which are supported now by every package manager (see also [pnpm overrides](https://pnpm.io/package_json#pnpmoverrides) and [yarn resolutions](https://yarnpkg.com/configuration/manifest/#resolutions)).
186-
>>>>>>> cfa53198f6c859029ffa3fd28b08724973a8867b
187173

188174
## 性能瓶颈 {#performance-bottlenecks}
189175

@@ -231,11 +217,7 @@ Vite 无法处理、也不支持仅可在非严格模式(sloppy mode)下运
231217
232218
> TypeError: Cannot create property 'foo' on boolean 'false'
233219
234-
<<<<<<< HEAD
235220
如果这些代码是在依赖中被使用的,你应该使用 [`patch-package`](https://github.com/ds300/patch-package)(或者 [`yarn patch`](https://yarnpkg.com/cli/patch)[`pnpm patch`](https://pnpm.io/cli/patch) 工具)来做短期补丁处理。
236-
=======
237-
If these codes are used inside dependencies, you could use [`patch-package`](https://github.com/ds300/patch-package) (or [`yarn patch`](https://yarnpkg.com/cli/patch) or [`pnpm patch`](https://pnpm.io/cli/patch)) for an escape hatch.
238-
>>>>>>> cfa53198f6c859029ffa3fd28b08724973a8867b
239221

240222
### 浏览器扩展程序 {#browser-extensions}
241223

0 commit comments

Comments
 (0)