Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions guide/api-hmr.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,8 @@ if (import.meta.hot) {
}
```

<<<<<<< HEAD
## TypeScript 的智能提示 {#intellisense-for-typescript}
Vite 在 [`vite/client.d.ts`](https://github.com/vitejs/vite/blob/main/packages/vite/client.d.ts) 中为 `import.meta.hot` 提供了类型定义。你可以在 `src` 目录中创建一个 `vite-env.d.ts`,以便 TypeScript 获取类型定义:
=======
## IntelliSense for TypeScript

Vite provides type definitions for `import.meta.hot` in [`vite/client.d.ts`](https://github.com/vitejs/vite/blob/main/packages/vite/client.d.ts). You can add "vite/client" in the `tsconfig.json` so TypeScript picks up the type definitions:
>>>>>>> 8885216737ac0478e1ca5271dd1a259d9fdadde3
Vite 在 [`vite/client.d.ts`](https://github.com/vitejs/vite/blob/main/packages/vite/client.d.ts) 中为 `import.meta.hot` 提供了类型定义。你可以在 `tsconfig.json` 中添加 "vite/client",以便 TypeScript 获取这些类型定义:

```json [tsconfig.json]
{
Expand Down
8 changes: 2 additions & 6 deletions guide/env-and-mode.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,18 @@

Vite 在特殊的 `import.meta.env` 对象下暴露了一些常量。这些常量在开发阶段被定义为全局变量,并在构建阶段被静态替换,以使树摇(tree-shaking)更有效。

<<<<<<< HEAD
## 内置常量 {#built-in-constants}
=======
:::details Example

```js
if (import.meta.env.DEV) {
// code inside here will be tree-shaken in production builds
// 这里的代码在生产构建中会被 tree-shaking 优化掉
console.log('Dev mode')
}
```

:::

## Built-in Constants
>>>>>>> 8885216737ac0478e1ca5271dd1a259d9fdadde3
## 内置常量 {#built-in-constants}

一些内置常量在所有情况下都可用:

Expand Down
22 changes: 3 additions & 19 deletions guide/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,19 +113,7 @@ Vite 启动模板默认情况下会设置 `"skipLibCheck": "true"`,以避免

### 客户端类型 {#client-types}

<<<<<<< HEAD
Vite 默认的类型定义是写给它的 Node.js API 的。要将其补充到一个 Vite 应用的客户端代码环境中,请添加一个 `d.ts` 声明文件:

```typescript
/// <reference types="vite/client" />
```

::: details 使用 `compilerOptions.types`

或者,你也可以将 `vite/client` 添加到 `tsconfig.json` 中的 `compilerOptions.types` 下:
=======
Vite's default types are for its Node.js API. To shim the environment of client-side code in a Vite application, you can add `vite/client` to `compilerOptions.types` inside `tsconfig.json`:
>>>>>>> 8885216737ac0478e1ca5271dd1a259d9fdadde3
Vite 默认的类型定义是写给它的 Node.js API 的。要将其补充到一个 Vite 应用的客户端代码环境中,你可以在 `tsconfig.json` 中的 `compilerOptions.types` 添加 `vite/client`:

```json [tsconfig.json]
{
Expand All @@ -135,19 +123,15 @@ Vite's default types are for its Node.js API. To shim the environment of client-
}
```

<<<<<<< HEAD
需要注意的是,如果指定了 [`compilerOptions.types`](https://www.typescriptlang.org/tsconfig#types),则只有这些包会被包含在全局作用域内(而不是所有的“@types”包)。
=======
Note that if [`compilerOptions.types`](https://www.typescriptlang.org/tsconfig#types) is specified, only these packages will be included in the global scope (instead of all visible ”@types” packages). This is recommended since TS 5.9.
需要注意的是,如果指定了 [`compilerOptions.types`](https://www.typescriptlang.org/tsconfig#types),则只有这些包会被包含在全局作用域内(而不是所有的“@types”包)。这是自 TypeScript 5.9 以来推荐的做法。

::: details Using triple-slash directive

Alternatively, you can add a `d.ts` declaration file:
或者,你可以添加一个 `d.ts` 声明文件:

```typescript [vite-env.d.ts]
/// <reference types="vite/client" />
```
>>>>>>> 8885216737ac0478e1ca5271dd1a259d9fdadde3

:::

Expand Down
8 changes: 2 additions & 6 deletions guide/rolldown.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,9 @@ Rolldown 专注于三个主要原则:

在添加 overrides 之后,重新安装你的依赖并像往常一样启动你的开发服务器或构建你的项目即可,无需进一步的配置更改。

<<<<<<< HEAD
## 已知限制 {#known-limitations}
=======
If you are starting a new project, you can use `create-vite` as normal for rolldown-vite, too. The latest version will ask you whether to use `rolldown-vite` or not.
如果你正在启动一个新项目,你也可以像平常一样使用 `create-vite` 来创建 rolldown-vite 项目。最新版本会询问你是否要使用 `rolldown-vite`。

## Known Limitations
>>>>>>> 8885216737ac0478e1ca5271dd1a259d9fdadde3
## 已知限制 {#known-limitations}

虽然 Rolldown 的目标是成为 Rollup 的替代品,但还有一些特性正在实现中,以及一些小的有意的行为差异。需要查看完整的列表,请参考 [这个 GitHub PR](https://github.com/vitejs/rolldown-vite/pull/84#issue-2903144667),它会定期更新。

Expand Down