Skip to content

Commit ad0b4d1

Browse files
committed
docs(en): merging all conflicts
2 parents 3cbc31e + ed613bb commit ad0b4d1

File tree

5 files changed

+65
-16
lines changed

5 files changed

+65
-16
lines changed

config/build-options.md

+7
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,17 @@ Git LFS 占位符会自动排除在内联之外,因为它们不包含它们所
145145
146146
## build.lib {#build-lib}
147147
148+
<<<<<<< HEAD
148149
- **类型:** `{ entry: string, name?: string, formats?: ('es' | 'cjs' | 'umd' | 'iife')[], fileName?: string | ((format: ModuleFormat) => string) }`
149150
- **相关内容:** [库模式](/guide/build#library-mode)
150151
151152
构建为库。`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
152159
153160
## build.manifest {#build-manifest}
154161

guide/api-hmr.md

+23
Original file line numberDiff line numberDiff line change
@@ -125,18 +125,41 @@ if (import.meta.hot) {
125125
126126
## `hot.invalidate()` {#hot-invalidate}
127127
128+
<<<<<<< HEAD
128129
现在调用 `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.
132+
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:
134+
135+
```js
136+
import.meta.hot.accept((module) => {
137+
// You may use the new module instance to decide whether to invalidate.
138+
if (cannotHandleUpdate(module)) {
139+
import.meta.hot.invalidate()
140+
}
141+
})
142+
```
143+
>>>>>>> ed613bb5379da4cdd7a3ea6ae152cb2a03c2ec58
129144
130145
## `hot.on(event, cb)` {#hot-onevent-cb}
131146
132147
监听自定义 HMR 事件。
133148
134149
以下 HMR 事件由 Vite 自动触发:
135150
151+
<<<<<<< HEAD
136152
- `'vite:beforeUpdate'` 当更新即将被应用时(例如,一个模块将被替换)
137153
- `'vite:beforeFullReload'` 当完整的重载即将发生时
138154
- `'vite:beforePrune'` 当不再需要的模块即将被剔除时
139155
- `'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
140163
141164
自定义 HMR 事件可以由插件发送。更多细节详见 [handleHotUpdate](./api-plugin#handleHotUpdate)。
142165

guide/api-plugin.md

+6-15
Original file line numberDiff line numberDiff line change
@@ -594,21 +594,12 @@ export default defineConfig({
594594
595595
```ts
596596
// events.d.ts
597-
import 'vite'
598-
import 'vite/client/types'
597+
import 'vite/types/customEvent'
599598
600-
interface MyCustomEventMap {
601-
'custom:foo': { msg: string }
602-
// 'event-key': payload
603-
}
604-
605-
// extend interface for server-side
606-
declare module 'vite' {
607-
interface CustomEventMap extends MyCustomEventMap {}
608-
}
609-
610-
// extend interface for client-side
611-
declare module 'vite/client/types' {
612-
interface CustomEventMap extends MyCustomEventMap {}
599+
declare module 'vite/types/customEvent' {
600+
interface CustomEventMap {
601+
'custom:foo': { msg: string }
602+
// 'event-key': payload
603+
}
613604
}
614605
```

guide/build.md

+28
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ import { defineConfig } from 'vite'
128128
export default defineConfig({
129129
build: {
130130
lib: {
131+
// Could also be a dictionary or array of multiple entry points
131132
entry: resolve(__dirname, 'lib/main.js'),
132133
name: 'MyLib',
133134
// the proper extensions will be added
@@ -183,8 +184,35 @@ dist/my-lib.umd.cjs 0.30 KiB / gzip: 0.16 KiB
183184
}
184185
```
185186

187+
<<<<<<< HEAD
186188
::: tip 注意
187189
如果 `package.json` 不包含 `"type": "module"`,Vite 会生成不同的文件后缀名以兼容 Node.js。`.js` 会变为 `.mjs``.cjs` 会变为 `.js`.
190+
=======
191+
Or, if exposing multiple entry points:
192+
193+
```json
194+
{
195+
"name": "my-lib",
196+
"type": "module",
197+
"files": ["dist"],
198+
"main": "./dist/my-lib.cjs",
199+
"module": "./dist/my-lib.mjs",
200+
"exports": {
201+
".": {
202+
"import": "./dist/my-lib.mjs",
203+
"require": "./dist/my-lib.cjs"
204+
},
205+
"./secondary": {
206+
"import": "./dist/secondary.mjs",
207+
"require": "./dist/secondary.cjs"
208+
}
209+
}
210+
}
211+
```
212+
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
188216
:::
189217

190218
::: tip 环境变量

guide/static-deploy.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ $ npm run preview
8383
# echo 'www.example.com' > CNAME
8484
8585
git init
86-
git checkout -b main
86+
git checkout -B main
8787
git add -A
8888
git commit -m 'deploy'
8989

0 commit comments

Comments
 (0)