Skip to content

Commit 1c4f981

Browse files
Merge pull request #624 from waynzh/docs/build
docs: add translation
2 parents ad0b4d1 + 3e19326 commit 1c4f981

File tree

3 files changed

+10
-32
lines changed

3 files changed

+10
-32
lines changed

config/build-options.md

+2-9
Original file line numberDiff line numberDiff line change
@@ -145,17 +145,10 @@ Git LFS 占位符会自动排除在内联之外,因为它们不包含它们所
145145
146146
## build.lib {#build-lib}
147147
148-
<<<<<<< HEAD
149-
- **类型:** `{ entry: string, name?: string, formats?: ('es' | 'cjs' | 'umd' | 'iife')[], fileName?: string | ((format: ModuleFormat) => string) }`
148+
- **类型:** `{ entry: string | string[] | { [entryAlias: string]: string }, name?: string, formats?: ('es' | 'cjs' | 'umd' | 'iife')[], fileName?: string | ((format: ModuleFormat, entryName: string) => string) }`
150149
- **相关内容:** [库模式](/guide/build#library-mode)
151150
152-
构建为库。`entry` 是必须的因为库不能使用 HTML 作为入口。`name` 则是暴露的全局变量,在 `formats` 包含 `'umd'``'iife'` 时是必须的。默认 `formats``['es', 'umd']``fileName` 是输出的包文件名,默认 `fileName``package.json``name` 选项,同时,它还可以被定义为参数为 `format` 的函数。
153-
=======
154-
- **Type:** `{ entry: string | string[] | { [entryAlias: string]: string }, name?: string, formats?: ('es' | 'cjs' | 'umd' | 'iife')[], fileName?: string | ((format: ModuleFormat, entryName: string) => string) }`
155-
- **Related:** [Library Mode](/guide/build#library-mode)
156-
157-
Build as a library. `entry` is required since the library cannot use HTML as entry. `name` is the exposed global variable and is required when `formats` includes `'umd'` or `'iife'`. Default `formats` are `['es', 'umd']`. `fileName` is the name of the package file output, default `fileName` is the name option of package.json, it can also be defined as function taking the `format` and `entryAlias` as arguments.
158-
>>>>>>> ed613bb5379da4cdd7a3ea6ae152cb2a03c2ec58
151+
构建为库。`entry` 是必需的,因为库不能使用 HTML 作为入口。`name` 则是暴露的全局变量,在 `formats` 包含 `'umd'``'iife'` 时是必需的。默认 `formats``['es', 'umd']``fileName` 是输出的包文件名,默认 `fileName``package.json``name` 选项,同时,它还可以被定义为参数为 `format``entryAlias` 的函数。
159152
160153
## build.manifest {#build-manifest}
161154

guide/api-hmr.md

+5-15
Original file line numberDiff line numberDiff line change
@@ -125,41 +125,31 @@ if (import.meta.hot) {
125125
126126
## `hot.invalidate()` {#hot-invalidate}
127127
128-
<<<<<<< HEAD
129-
现在调用 `import.meta.hot.invalidate()` 只是重新加载页面。
130-
=======
131-
A self-accepting module may realize during runtime that it can't handle a HMR update, and so the update needs to be forcefully propagated to importers. By calling `import.meta.hot.invalidate()`, the HMR server will invalidate the importers of the caller, as if the caller wasn't self-accepting.
128+
一个接收自身的模块可以在运行时意识到它不能处理 HMR 更新,因此需要将更新强制传递给导入者。通过调用 `import.meta.hot.invalidate()`,HMR 服务将使调用方的导入失效,就像调用方不是接收自身的一样。
129+
130+
请注意,你应该总是调用 `import.meta.hot.accept`,即使你打算随后立即调用 `invalidate`,否则 HMR 客户端将不会监听未来对接收自身模块的更改。为了清楚地表达你的意图,我们建议在 `accept` 回调中调用 `invalidate`,例如:
132131
133-
Note that you should always call `import.meta.hot.accept` even if you plan to call `invalidate` immediately afterwards, or else the HMR client won't listen for future changes to the self-accepting module. To communicate your intent clearly, we recommend calling `invalidate` within the `accept` callback like so:
134132
135133
```js
136134
import.meta.hot.accept((module) => {
137-
// You may use the new module instance to decide whether to invalidate.
135+
// 你可以使用新的模块实例来决定是否使其失效。
138136
if (cannotHandleUpdate(module)) {
139137
import.meta.hot.invalidate()
140138
}
141139
})
142140
```
143-
>>>>>>> ed613bb5379da4cdd7a3ea6ae152cb2a03c2ec58
144141
145142
## `hot.on(event, cb)` {#hot-onevent-cb}
146143
147144
监听自定义 HMR 事件。
148145
149146
以下 HMR 事件由 Vite 自动触发:
150147
151-
<<<<<<< HEAD
152148
- `'vite:beforeUpdate'` 当更新即将被应用时(例如,一个模块将被替换)
153149
- `'vite:beforeFullReload'` 当完整的重载即将发生时
154150
- `'vite:beforePrune'` 当不再需要的模块即将被剔除时
151+
- `'vite:invalidate'` 当使用 `import.meta.hot.invalidate()` 使一个模块失效时
155152
- `'vite:error'` 当发生错误时(例如,语法错误)
156-
=======
157-
- `'vite:beforeUpdate'` when an update is about to be applied (e.g. a module will be replaced)
158-
- `'vite:beforeFullReload'` when a full reload is about to occur
159-
- `'vite:beforePrune'` when modules that are no longer needed are about to be pruned
160-
- `'vite:invalidate'` when a module is invalidated with `import.meta.hot.invalidate()`
161-
- `'vite:error'` when an error occurs (e.g. syntax error)
162-
>>>>>>> ed613bb5379da4cdd7a3ea6ae152cb2a03c2ec58
163153
164154
自定义 HMR 事件可以由插件发送。更多细节详见 [handleHotUpdate](./api-plugin#handleHotUpdate)。
165155

guide/build.md

+3-8
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,7 @@ dist/my-lib.umd.cjs 0.30 KiB / gzip: 0.16 KiB
184184
}
185185
```
186186

187-
<<<<<<< HEAD
188-
::: tip 注意
189-
如果 `package.json` 不包含 `"type": "module"`,Vite 会生成不同的文件后缀名以兼容 Node.js。`.js` 会变为 `.mjs``.cjs` 会变为 `.js`.
190-
=======
191-
Or, if exposing multiple entry points:
187+
或者,如果暴露了多个入口起点:
192188

193189
```json
194190
{
@@ -210,9 +206,8 @@ Or, if exposing multiple entry points:
210206
}
211207
```
212208

213-
::: tip Note
214-
If the `package.json` does not contain `"type": "module"`, Vite will generate different file extensions for Node.js compatibility. `.js` will become `.mjs` and `.cjs` will become `.js`.
215-
>>>>>>> ed613bb5379da4cdd7a3ea6ae152cb2a03c2ec58
209+
::: tip 注意
210+
如果 `package.json` 不包含 `"type": "module"`,Vite 会生成不同的文件后缀名以兼容 Node.js。`.js` 会变为 `.mjs``.cjs` 会变为 `.js`
216211
:::
217212

218213
::: tip 环境变量

0 commit comments

Comments
 (0)