Skip to content

Commit 39cd847

Browse files
committed
docs(cn): conflict resolution
1 parent 0ffdfac commit 39cd847

File tree

4 files changed

+12
-28
lines changed

4 files changed

+12
-28
lines changed

changes/shared-plugins-during-build.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,7 @@ function PerEnvironmentCountTransformedModulesPlugin() {
5959
}
6060
```
6161

62-
<<<<<<< HEAD
63-
为了简化这种模式,我们在 Vite 内部使用了 `usePerEnvironmentState` 助手:
64-
=======
65-
To simplify this pattern, Vite exports a `perEnvironmentState` helper:
66-
>>>>>>> ad763748fc34afdadf29b2ac95a909c0eff119e3
62+
为了简化这种模式,Vite 导出了一个 `perEnvironmentState` 助手:
6763

6864
```js
6965
function PerEnvironmentCountTransformedModulesPlugin() {

config/ssr-options.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ SSR 服务器的构建目标。
5656

5757
### ssr.resolve.mainFields
5858

59-
- **Type:** `string[]`
60-
- **Default:** `['module', 'jsnext:main', 'jsnext']`
61-
62-
List of fields in `package.json` to try when resolving a package's entry point. Note this takes lower precedence than conditional exports resolved from the `exports` field: if an entry point is successfully resolved from `exports`, the main field will be ignored. This setting only affect non-externalized dependencies.
59+
- **类型:** `string[]`
60+
- **默认:** `['module', 'jsnext:main', 'jsnext']`
61+
62+
在解析一个包的入口点时可尝试的 `package.json` 中的字段列表。请注意,这比从 `exports` 字段解析出的条件导出的优先级要低:如果能从 `exports` 字段成功解析出入口点,那么 main 字段将会被忽略。此设置仅影响未外部化的依赖项。

guide/api-environment-plugins.md

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ interface HotUpdateContext {
6767
server: ViteDevServer
6868
}
6969
```
70+
7071
- `this.environment` 是当前正在处理文件更新的模块执行环境。
7172
7273
- `modules` 是由于文件更改而受影响的此环境中的模块的数组。它是一个数组,因为一个文件可能映射到多个服务的模块(例如 Vue SFCs)。
@@ -141,14 +142,9 @@ const UnoCssPlugin = () => {
141142
// 正常使用全局钩子
142143
},
143144
applyToEnvironment(environment) {
144-
<<<<<<< HEAD
145-
// 如果这个插件应该在这个环境中激活,则返回 true
145+
// 如果此插件应在此环境中激活,则返回 true
146+
// 或返回一个新插件来替代它。
146147
// 如果不使用这个 hook,则插件在所有环境中都是激活的
147-
=======
148-
// return true if this plugin should be active in this environment,
149-
// or return a new plugin to replace it.
150-
// if the hook is not used, the plugin is active in all environments
151-
>>>>>>> ad763748fc34afdadf29b2ac95a909c0eff119e3
152148
},
153149
resolveId(id, importer) {
154150
// 只对此插件适用的环境进行调用
@@ -157,10 +153,7 @@ const UnoCssPlugin = () => {
157153
}
158154
```
159155
160-
<<<<<<< HEAD
161-
## 构建钩子中的环境 {#environment-in-build-hooks}
162-
=======
163-
If a plugin isn't environment aware and has state that isn't keyed on the current environment, the `applyToEnvironment` hook allows to easily make it per-environment.
156+
如果一个插件没有环境感知功能,并且其状态不是以当前环境为关键的, `applyToEnvironment` 钩子可以轻松地将其设置为针对每个环境。
164157
165158
```js
166159
import { nonShareablePlugin } from 'non-shareable-plugin'
@@ -177,7 +170,7 @@ export default defineConfig({
177170
})
178171
```
179172
180-
Vite exports a `perEnvironmentPlugin` helper to simplify these cases where no other hooks are required:
173+
Vite 输出了一个 `perEnvironmentPlugin` 助手,以简化这些不需要其他钩子的情况:
181174
182175
```js
183176
import { nonShareablePlugin } from 'non-shareable-plugin'
@@ -191,8 +184,7 @@ export default defineConfig({
191184
})
192185
```
193186
194-
## Environment in build hooks
195-
>>>>>>> ad763748fc34afdadf29b2ac95a909c0eff119e3
187+
## 构建钩子中的环境 {#environment-in-build-hooks}
196188
197189
与开发期间一样,插件钩子在构建期间也接收环境实例,取代了 `ssr` 布尔值。
198190
这同样适用于 `renderChunk``generateBundle` 和其他仅在构建时使用的钩子。

guide/migration.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,9 @@ Vite 6 扩展了对更多 HTML 元素的支持。完整列表请参见 [HTML 功
9292
- 这可能会导致包的大小增大,但会使构建更加确定。
9393
- 如果将 CommonJS 文件指定为入口点,则可能需要额外的步骤。阅读 [commonjs plugin 文档](https://github.com/rollup/plugins/blob/master/packages/commonjs/README.md#using-commonjs-files-as-entry-points) 了解更多详情.
9494
- [[#18243] chore(deps)!: migrate `fast-glob` to `tinyglobby`](https://github.com/vitejs/vite/pull/18243)
95-
<<<<<<< HEAD
9695
- globs 中不再支持范围大括号 (`{01..03}``['01', '02', '03']`) 和递增大括号 (`{2..8..2}``['2', '4', '6', '8']`) 。
97-
=======
98-
- Range braces (`{01..03}``['01', '02', '03']`) and incremental braces (`{2..8..2}``['2', '4', '6', '8']`) are no longer supported in globs.
9996
- [[#18395] feat(resolve)!: allow removing conditions](https://github.com/vitejs/vite/pull/18395)
100-
- This PR not only introduces a breaking change mentioned above as "Default value for `resolve.conditions`", but also makes `resolve.mainFields` to not be used for no-externalized dependencies in SSR. If you were using `resolve.mainFields` and want to apply that to no-externalized dependencies in SSR, you can use [`ssr.resolve.mainFields`](/config/ssr-options#ssr-resolve-mainfields).
101-
>>>>>>> ad763748fc34afdadf29b2ac95a909c0eff119e3
97+
- 此 PR 不仅引入了上文提到的 " `resolve.conditions` 的默认值" 这一破坏性变更,还使得在 SSR 中,`resolve.mainFields` 不能用于无外部化依赖关系。如果您正在使用 `resolve.mainFields`,并希望将其应用于 SSR 中的无外部化依赖关系,您可以使用 [`ssr.resolve.mainFields`](/config/ssr-options#ssr-resolve-mainfields)
10298
- [[#18493] refactor!: remove fs.cachedChecks option](https://github.com/vitejs/vite/pull/18493)
10399
- 由于在缓存文件夹中写入文件并立即导入时会出现边缘情况,因此删除了这一选择优化。
104100

0 commit comments

Comments
 (0)