Skip to content

Commit

Permalink
Merge pull request #678 from vitejs/release-v4.0.4
Browse files Browse the repository at this point in the history
Ready to publish Release v4.0.4
  • Loading branch information
ShenQingchuan committed Jan 6, 2023
2 parents 6535bc5 + ecb6445 commit f788cac
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 5 deletions.
7 changes: 7 additions & 0 deletions _data/team.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,13 @@ export const core = [
desc: 'Passionate by tooling around TypeScript and React.',
links: [{ icon: 'github', link: 'https://github.com/ArnaudBarre' }],
},
{
avatar: 'https://github.com/dominikg.png',
name: 'Dominik G.',
title: 'Resident CI Expert',
desc: 'Team Member of Vite and Svelte',
links: [{ icon: 'github', link: 'https://github.com/dominikg' }],
},
]

export const emeriti = [
Expand Down
2 changes: 2 additions & 0 deletions config/worker-options.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Worker 选项 {#worker-options}

Options related to Web Workers.

## worker.format

- **类型:** `'es' | 'iife'`
Expand Down
2 changes: 1 addition & 1 deletion guide/api-hmr.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ if (import.meta.hot) {
import.meta.hot.accept(
['./foo.js', './bar.js'],
([newFooModule, newBarModule]) => {
// 只有当更新模块非空时,回调函数接收一个数组
// 只有当所更新的模块非空时,回调函数接收一个数组
// 如果更新不成功(例如语法错误),则该数组为空
}
)
Expand Down
2 changes: 2 additions & 0 deletions guide/assets.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ document.getElementById('hero-img').src = imgUrl

- Git LFS 占位符会自动排除在内联之外,因为它们不包含它们所表示的文件的内容。要获得内联,请确保在构建之前通过 Git LFS 下载文件内容。

- 默认情况下,TypeScript 不会将静态资源导入视为有效的模块。要解决这个问题,需要添加 [`vite/client`](./features#client-types)

### 显式 URL 引入 {#explicit-url-imports}

未被包含在内部列表或 `assetsInclude` 中的资源,可以使用 `?url` 后缀显式导入为一个 URL。这十分有用,例如,要导入 [Houdini Paint Worklets](https://houdini.how/usage) 时:
Expand Down
6 changes: 3 additions & 3 deletions guide/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,14 @@ dist/my-lib.umd.cjs 0.30 KiB / gzip: 0.16 KiB
"type": "module",
"files": ["dist"],
"main": "./dist/my-lib.cjs",
"module": "./dist/my-lib.mjs",
"module": "./dist/my-lib.js",
"exports": {
".": {
"import": "./dist/my-lib.mjs",
"import": "./dist/my-lib.js",
"require": "./dist/my-lib.cjs"
},
"./secondary": {
"import": "./dist/secondary.mjs",
"import": "./dist/secondary.js",
"require": "./dist/secondary.cjs"
}
}
Expand Down
2 changes: 1 addition & 1 deletion guide/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export type { T }

#### `useDefineForClassFields`

从 Vite v2.5.0 开始,如果 TypeScript 的 target 是 `ESNext`,此选项默认值则为 `true`。这与 [`tsc` v4.3.2 及以后版本的行为](https://github.com/microsoft/TypeScript/pull/42663) 一致。这也是标准的 ECMAScript 的运行时行为。
从 Vite v2.5.0 开始,如果 TypeScript 的 target 是 `ESNext``ES2022` 及更新版本,此选项默认值则为 `true`。这与 [`tsc` v4.3.2 及以后版本的行为](https://github.com/microsoft/TypeScript/pull/42663) 一致。这也是标准的 ECMAScript 的运行时行为。

但对于那些习惯其他编程语言或旧版本 TypeScript 的开发者来说,这可能是违反直觉的。
你可以参阅 [TypeScript 3.7 发布日志](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#the-usedefineforclassfields-flag-and-the-declare-property-modifier) 中了解更多关于如何兼容的信息。
Expand Down
8 changes: 8 additions & 0 deletions guide/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ import cssString from './global.css'
import stuff from './global.css?inline'
```

### 默认情况下的生产构建 {#production-builds-by-default}

不管所传递的 `--mode` 是什么,`vite build` 总是构建生产版本。之前,若将 `mode` 改为 `production` 之外的模式会构建开发版本,如果现在希望用于开发构建,可以在 `.env.{mode}` 文件中设置 `NODE_ENV=development`

在本次变动中,如果 `process.env.`<wbr>`NODE_ENV` 已经被定义,`vite dev``vite build` 将不再覆盖它。所以如果在构建前设置了 `process.env.`<wbr>`NODE_ENV = 'development'`,将会构建开发版本。这在并行执行多个构建或开发服务器时提供了更多的控制权。

请参阅更新后的 [`mode` 文档](/guide/env-and-mode.md#modes) 了解更多详细信息。

### 环境变量 {#environment-variables}

Vite 现在使用 `dotenv` 16 和 `dotenv-expand` 9(之前是 `dotenv` 14 和 `dotenv-expand` 5)如果你有一个包含 `#` 或者 `` ` `` 的值,你将需要将它们以双引号包裹起来。
Expand Down
22 changes: 22 additions & 0 deletions guide/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,24 @@

请注意,这些配置会持久作用,但需要 **重新启动**

### 网络请求停止加载 {#network-requests-stop-loading}

使用自签名SSL证书时,Chrome 会忽略所有缓存指令并重新加载内容。而 Vite 依赖于这些缓存指令。

要解决此问题,请使用受信任的SSL证书。

请查看:[缓存问题](https://helpx.adobe.com/mt/experience-manager/kb/cache-problems-on-chrome-with-SSL-certificate-errors.html) 和相关的 [Chrome issue](https://bugs.chromium.org/p/chromium/issues/detail?id=110649#c8)

#### macOS

您可以使用以下命令通过 CLI 安装受信任的证书:

```
security add-trusted-cert -d -r trustRoot -k ~/Library/Keychains/login.keychain-db your-cert.cer
```
或者,通过将其导入 Keychain Access 应用程序并将您的证书的信任更新为“始终信任”。
### 431 Request Header Fields Too Large {#431-request-header-fields-too-large}
当服务器或 WebSocket 服务收到一个较大的 HTTP 头,该请求可能会被遗落并且会显示下面这样的警告。
Expand Down Expand Up @@ -83,6 +101,10 @@ import './Foo.js' // 应该为 './foo.js'

同时如果有依赖环,也会发生完全重载。要解决这个问题,请先尝试解决依赖循环。

### 控制台中大量热更新 {#high-number-of-hmr-updates-in-console}

This can be caused by a circular dependency. To solve this, try breaking the loop.

## 构建 {#build}

### 构建产物因为 CORS 错误无法工作 {#built-file-does-not-work-because-of-cors-error}
Expand Down

1 comment on commit f788cac

@vercel
Copy link

@vercel vercel bot commented on f788cac Jan 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

cn-vitejs-dev – ./

cn-vitejs-dev-vuejs.vercel.app
cn-vitejs-dev-git-main-vuejs.vercel.app
docs-cn.vercel.app
cn.vitejs.dev

Please sign in to comment.