From 80d93ae71ddf966c7cd63ffa4c35832c09e74f18 Mon Sep 17 00:00:00 2001 From: Hirotaka Miyagi <31152321+MH4GF@users.noreply.github.com> Date: Mon, 24 Jul 2023 16:30:07 +0900 Subject: [PATCH 1/9] docs(static-deploy): add deployment instructions for AWS Amplify Hosting (#13882) --- guide/static-deploy.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/guide/static-deploy.md b/guide/static-deploy.md index 149995a8..a5c3caea 100644 --- a/guide/static-deploy.md +++ b/guide/static-deploy.md @@ -337,3 +337,7 @@ You can also add a [custom domain](https://render.com/docs/custom-domains) to yo ## Flightcontrol Deploy your static site using [Flightcontrol](https://www.flightcontrol.dev/?ref=docs-vite), by following these [instructions](https://www.flightcontrol.dev/docs/reference/examples/vite?ref=docs-vite) + +## AWS Amplify Hosting + +Deploy your static site using [AWS Amplify Hosting](https://aws.amazon.com/amplify/hosting/), by following these [instructions](https://docs.amplify.aws/guides/hosting/vite/q/platform/js/) From 00eed324d1ca08f62d9e4f62c5ee604ec07317a4 Mon Sep 17 00:00:00 2001 From: Dariusz Czajkowski Date: Mon, 24 Jul 2023 16:43:14 +0200 Subject: [PATCH 2/9] docs: remove note about firefox not supporting ESM imports in Web Workers (#13940) --- guide/features.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guide/features.md b/guide/features.md index 1ce36a97..cebe8005 100644 --- a/guide/features.md +++ b/guide/features.md @@ -559,7 +559,7 @@ import MyWorker from './worker?worker' const worker = new MyWorker() ``` -The worker script can also use ESM `import` statements instead of `importScripts()`. **Note**: During dev this relies on [browser native support](https://caniuse.com/?search=module%20worker) (currently not supported in Firefox), but for the production build it is compiled away. +The worker script can also use ESM `import` statements instead of `importScripts()`. **Note**: During dev this relies on [browser native support](https://caniuse.com/?search=module%20worker), but for the production build it is compiled away. By default, the worker script will be emitted as a separate chunk in the production build. If you wish to inline the worker as base64 strings, add the `inline` query: From f2a97e0ed3a8f1329f11ec157ab91fe5eaa9556a Mon Sep 17 00:00:00 2001 From: ShenQingchuan Date: Wed, 26 Jul 2023 22:51:01 +0800 Subject: [PATCH 3/9] docs: resolve conflicts --- guide/features.md | 6 +----- guide/static-deploy.md | 8 ++------ 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/guide/features.md b/guide/features.md index 5ba86be6..c20510c5 100644 --- a/guide/features.md +++ b/guide/features.md @@ -559,11 +559,7 @@ import MyWorker from './worker?worker' const worker = new MyWorker() ``` -<<<<<<< HEAD -Worker 脚本也可以使用 ESM 的 `import` 语句来替代 `importScripts()` —— **注意**,在开发过程中,这依赖于[浏览器原生支持](https://caniuse.com/?search=module%20worker)(目前在 Firefox 中不支持),而在生产版本中,它已经被编译掉了。 -======= -The worker script can also use ESM `import` statements instead of `importScripts()`. **Note**: During dev this relies on [browser native support](https://caniuse.com/?search=module%20worker), but for the production build it is compiled away. ->>>>>>> 00eed324d1ca08f62d9e4f62c5ee604ec07317a4 +这个 worker 脚本也可以使用 ESM `import` 语句而不是 `importScripts()`。**注意**:在开发时,这依赖于 [浏览器原生支持](https://caniuse.com/?search=module%20worker),但是在生产构建中,它会被编译掉。 默认情况下,worker 脚本将在生产构建中编译成单独的 chunk。如果你想将 worker 内联为 base64 字符串,请添加 `inline` 查询参数: diff --git a/guide/static-deploy.md b/guide/static-deploy.md index a205856b..2f3720e8 100644 --- a/guide/static-deploy.md +++ b/guide/static-deploy.md @@ -336,12 +336,8 @@ $ npx wrangler pages publish dist ## Flightcontrol -<<<<<<< HEAD 使用 [Flightcontrol](https://www.flightcontrol.dev/?ref=docs-vite) 部署静态站点,可以按照 [说明](https://www.flightcontrol.dev/docs/reference/examples/vite?ref=docs-vite) 进行操作。 -======= -Deploy your static site using [Flightcontrol](https://www.flightcontrol.dev/?ref=docs-vite), by following these [instructions](https://www.flightcontrol.dev/docs/reference/examples/vite?ref=docs-vite) -## AWS Amplify Hosting +## AWS Amplify 部署 {#aws-amplify-hoisting} -Deploy your static site using [AWS Amplify Hosting](https://aws.amazon.com/amplify/hosting/), by following these [instructions](https://docs.amplify.aws/guides/hosting/vite/q/platform/js/) ->>>>>>> 00eed324d1ca08f62d9e4f62c5ee604ec07317a4 +使用 [AWS Amplify 部署](https://aws.amazon.com/amplify/hosting/) 部署静态站点,可以按照 [说明](https://docs.amplify.aws/guides/hosting/vite/q/platform/js/) 进行操作。 From e11dd91ed894bc7c26f44a144dfc7c9282133b43 Mon Sep 17 00:00:00 2001 From: tommie Date: Mon, 31 Jul 2023 13:19:15 +0200 Subject: [PATCH 4/9] docs(wasm): add sections about Node.js and module access (#13978) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 翠 / green --- guide/features.md | 50 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 4 deletions(-) diff --git a/guide/features.md b/guide/features.md index cebe8005..392bafb8 100644 --- a/guide/features.md +++ b/guide/features.md @@ -500,7 +500,8 @@ Note that variables only represent file names one level deep. If `file` is `'foo ## WebAssembly -Pre-compiled `.wasm` files can be imported with `?init` - the default export will be an initialization function that returns a Promise of the wasm instance: +Pre-compiled `.wasm` files can be imported with `?init`. +The default export will be an initialization function that returns a Promise of the [`WebAssembly.Instance`](https://developer.mozilla.org/en-US/docs/WebAssembly/JavaScript_interface/Instance): ```js import init from './example.wasm?init' @@ -510,7 +511,7 @@ init().then((instance) => { }) ``` -The init function can also take the `imports` object which is passed along to `WebAssembly.instantiate` as its second argument: +The init function can also take an importObject which is passed along to [`WebAssembly.instantiate`](https://developer.mozilla.org/en-US/docs/WebAssembly/JavaScript_interface/instantiate) as its second argument: ```js init({ @@ -524,13 +525,54 @@ init({ }) ``` -In the production build, `.wasm` files smaller than `assetInlineLimit` will be inlined as base64 strings. Otherwise, they will be copied to the dist directory as an asset and fetched on-demand. +In the production build, `.wasm` files smaller than `assetInlineLimit` will be inlined as base64 strings. Otherwise, they will be treated as a [static asset](./assets) and fetched on-demand. -::: warning +::: tip NOTE [ES Module Integration Proposal for WebAssembly](https://github.com/WebAssembly/esm-integration) is not currently supported. Use [`vite-plugin-wasm`](https://github.com/Menci/vite-plugin-wasm) or other community plugins to handle this. ::: +### Accessing the WebAssembly Module + +If you need access to the `Module` object, e.g. to instantiate it multiple times, use an [explicit URL import](./assets#explicit-url-imports) to resolve the asset, and then perform the instantiation: + +```js +import wasmUrl from 'foo.wasm?url' + +const main = async () => { + const responsePromise = fetch(wasmUrl) + const { module, instance } = await WebAssembly.instantiateStreaming( + responsePromise, + ) + /* ... */ +} + +main() +``` + +### Fetching the module in Node.js + +In SSR, the `fetch()` happening as part of the `?init` import, may fail with `TypeError: Invalid URL`. +See the issue [Support wasm in SSR](https://github.com/vitejs/vite/issues/8882). + +Here is an alternative, assuming the project base is the current directory: + +```js +import wasmUrl from 'foo.wasm?url' +import { readFile } from 'node:fs/promises' + +const main = async () => { + const resolvedUrl = (await import('./test/boot.test.wasm?url')).default + const buffer = await readFile('.' + resolvedUrl) + const { instance } = await WebAssembly.instantiate(buffer, { + /* ... */ + }) + /* ... */ +} + +main() +``` + ## Web Workers ### Import with Constructors From 3ac42dbf114bf597ecf231ec6f2229c4ecb71720 Mon Sep 17 00:00:00 2001 From: waynzh Date: Wed, 2 Aug 2023 19:28:24 +0800 Subject: [PATCH 5/9] docs(cn): resolve conflicts --- guide/features.md | 43 ++++++++++++------------------------------- 1 file changed, 12 insertions(+), 31 deletions(-) diff --git a/guide/features.md b/guide/features.md index 3988f0ce..9143e1f4 100644 --- a/guide/features.md +++ b/guide/features.md @@ -500,12 +500,8 @@ const module = await import(`./dir/${file}.js`) ## WebAssembly {#webassembly} -<<<<<<< HEAD -预编译的 `.wasm` 文件可以通过 `?init` 来导入。默认导出一个初始化函数,返回值为所导出 wasm 实例对象的 Promise: -======= -Pre-compiled `.wasm` files can be imported with `?init`. -The default export will be an initialization function that returns a Promise of the [`WebAssembly.Instance`](https://developer.mozilla.org/en-US/docs/WebAssembly/JavaScript_interface/Instance): ->>>>>>> e11dd91ed894bc7c26f44a144dfc7c9282133b43 +预编译的 `.wasm` 文件可以通过 `?init` 来导入。 +默认导出一个初始化函数,返回值为所导出 [`WebAssembly.Instance`](https://developer.mozilla.org/en-US/docs/WebAssembly/JavaScript_interface/Instance) 实例对象的 Promise: ```js import init from './example.wasm?init' @@ -515,11 +511,7 @@ init().then((instance) => { }) ``` -<<<<<<< HEAD -`init` 函数还可以将传递给 `WebAssembly.instantiate` 的导入对象作为其第二个参数: -======= -The init function can also take an importObject which is passed along to [`WebAssembly.instantiate`](https://developer.mozilla.org/en-US/docs/WebAssembly/JavaScript_interface/instantiate) as its second argument: ->>>>>>> e11dd91ed894bc7c26f44a144dfc7c9282133b43 +`init` 函数还可以将传递给 [`WebAssembly.instantiate`](https://developer.mozilla.org/en-US/docs/WebAssembly/JavaScript_interface/instantiate) 的导入对象作为其第二个参数: ```js init({ @@ -533,26 +525,16 @@ init({ }) ``` -<<<<<<< HEAD -在生产构建当中,体积小于 `assetInlineLimit` 的 `.wasm` 文件将会被内联为 base64 字符串。否则,它们将作为资源复制到 `dist` 目录中,并按需获取。 +在生产构建当中,体积小于 `assetInlineLimit` 的 `.wasm` 文件将会被内联为 base64 字符串。否则,它们将被视为 [静态资源](./assets) ,并按需获取。 -::: warning +::: tip 注意 [对 WebAssembly 的 ES 模块集成提案](https://github.com/WebAssembly/esm-integration) 尚未支持。 请使用 [`vite-plugin-wasm`](https://github.com/Menci/vite-plugin-wasm) 或其他社区上的插件来处理。 ::: -## Web Workers {#web-workers} -======= -In the production build, `.wasm` files smaller than `assetInlineLimit` will be inlined as base64 strings. Otherwise, they will be treated as a [static asset](./assets) and fetched on-demand. +### 访问 WebAssembly 模块 {#accessing-the-webassembly-module} -::: tip NOTE -[ES Module Integration Proposal for WebAssembly](https://github.com/WebAssembly/esm-integration) is not currently supported. -Use [`vite-plugin-wasm`](https://github.com/Menci/vite-plugin-wasm) or other community plugins to handle this. -::: - -### Accessing the WebAssembly Module - -If you need access to the `Module` object, e.g. to instantiate it multiple times, use an [explicit URL import](./assets#explicit-url-imports) to resolve the asset, and then perform the instantiation: +如果需要访问 `Module` 对象,例如将它多次实例化,可以使用 [显式 URL 引入](./assets#explicit-url-imports) 来解析资源,然后执行实例化: ```js import wasmUrl from 'foo.wasm?url' @@ -568,12 +550,12 @@ const main = async () => { main() ``` -### Fetching the module in Node.js +### 在 Node.js 中获取模块 {#fetching-the-module-in-node-js} -In SSR, the `fetch()` happening as part of the `?init` import, may fail with `TypeError: Invalid URL`. -See the issue [Support wasm in SSR](https://github.com/vitejs/vite/issues/8882). +在 SSR 中,作为 `?init` 导入的 `fetch()` 可能会失败,导致 `TypeError: Invalid URL` 报错。 +请参见问题 [在 SSR 中支持 wasm](https://github.com/vitejs/vite/issues/8882)。 -Here is an alternative, assuming the project base is the current directory: +以下是一种替代方案,假设项目根目录在当前目录: ```js import wasmUrl from 'foo.wasm?url' @@ -591,8 +573,7 @@ const main = async () => { main() ``` -## Web Workers ->>>>>>> e11dd91ed894bc7c26f44a144dfc7c9282133b43 +## Web Workers {#web-workers} ### 通过构造器导入 {#import-with-constructors} From 7237cc927fe26097732451fe91e8fb4967279095 Mon Sep 17 00:00:00 2001 From: patak Date: Fri, 11 Aug 2023 08:16:54 +0200 Subject: [PATCH 6/9] docs: viteconf 23 link (#14075) --- .vitepress/theme/components/AsideSponsors.vue | 63 +++++++++++++++++++ index.md | 3 + public/viteconf.svg | 25 +++++++- 3 files changed, 90 insertions(+), 1 deletion(-) diff --git a/.vitepress/theme/components/AsideSponsors.vue b/.vitepress/theme/components/AsideSponsors.vue index 90e6adda..dcaf4492 100644 --- a/.vitepress/theme/components/AsideSponsors.vue +++ b/.vitepress/theme/components/AsideSponsors.vue @@ -18,5 +18,68 @@ const sponsors = computed(() => { + + diff --git a/index.md b/index.md index bdf716bc..07d3c0a0 100644 --- a/index.md +++ b/index.md @@ -21,6 +21,9 @@ hero: - theme: alt text: View on GitHub link: https://github.com/vitejs/vite + - theme: brand + text: ViteConf 23! + link: https://viteconf.org/23 features: - icon: 💡 diff --git a/public/viteconf.svg b/public/viteconf.svg index a01c0bd2..2ca20c23 100644 --- a/public/viteconf.svg +++ b/public/viteconf.svg @@ -1 +1,24 @@ - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + From f78f5e3ead9759a8428094c876b9adbd74374eb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaqu=C3=ADn=20S=C3=A1nchez?= Date: Fri, 11 Aug 2023 17:40:33 +0200 Subject: [PATCH 7/9] docs(cli): include `--profile` option (#14079) --- guide/cli.md | 38 ++++++++++++++++++++------------------ guide/troubleshooting.md | 22 ++++++++++++++++++++++ 2 files changed, 42 insertions(+), 18 deletions(-) diff --git a/guide/cli.md b/guide/cli.md index 05061070..497ad661 100644 --- a/guide/cli.md +++ b/guide/cli.md @@ -14,24 +14,25 @@ vite [root] #### Options -| Options | | -| ------------------------ | ----------------------------------------------------------------- | -| `--host [host]` | Specify hostname (`string`) | -| `--port ` | Specify port (`number`) | -| `--https` | Use TLS + HTTP/2 (`boolean`) | -| `--open [path]` | Open browser on startup (`boolean \| string`) | -| `--cors` | Enable CORS (`boolean`) | -| `--strictPort` | Exit if specified port is already in use (`boolean`) | -| `--force` | Force the optimizer to ignore the cache and re-bundle (`boolean`) | -| `-c, --config ` | Use specified config file (`string`) | -| `--base ` | Public base path (default: `/`) (`string`) | -| `-l, --logLevel ` | Info \| warn \| error \| silent (`string`) | -| `--clearScreen` | Allow/disable clear screen when logging (`boolean`) | -| `-d, --debug [feat]` | Show debug logs (`string \| boolean`) | -| `-f, --filter ` | Filter debug logs (`string`) | -| `-m, --mode ` | Set env mode (`string`) | -| `-h, --help` | Display available CLI options | -| `-v, --version` | Display version number | +| Options | | +| ------------------------ | ------------------------------------------------------------------------------------------------------------------ | +| `--host [host]` | Specify hostname (`string`) | +| `--port ` | Specify port (`number`) | +| `--https` | Use TLS + HTTP/2 (`boolean`) | +| `--open [path]` | Open browser on startup (`boolean \| string`) | +| `--cors` | Enable CORS (`boolean`) | +| `--strictPort` | Exit if specified port is already in use (`boolean`) | +| `--force` | Force the optimizer to ignore the cache and re-bundle (`boolean`) | +| `-c, --config ` | Use specified config file (`string`) | +| `--base ` | Public base path (default: `/`) (`string`) | +| `-l, --logLevel ` | Info \| warn \| error \| silent (`string`) | +| `--clearScreen` | Allow/disable clear screen when logging (`boolean`) | +| `--profile` | Start built-in Node.js inspector (check [Performance bottlenecks](/guide/troubleshooting#performance-bottlenecks)) | +| `-d, --debug [feat]` | Show debug logs (`string \| boolean`) | +| `-f, --filter ` | Filter debug logs (`string`) | +| `-m, --mode ` | Set env mode (`string`) | +| `-h, --help` | Display available CLI options | +| `-v, --version` | Display version number | ## Build @@ -65,6 +66,7 @@ vite build [root] | `--base ` | Public base path (default: `/`) (`string`) | | `-l, --logLevel ` | Info \| warn \| error \| silent (`string`) | | `--clearScreen` | Allow/disable clear screen when logging (`boolean`) | +| `--profile` | Start built-in Node.js inspector (check [Performance bottlenecks](/guide/troubleshooting#performance-bottlenecks)) | | `-d, --debug [feat]` | Show debug logs (`string \| boolean`) | | `-f, --filter ` | Filter debug logs (`string`) | | `-m, --mode ` | Set env mode (`string`) | diff --git a/guide/troubleshooting.md b/guide/troubleshooting.md index 41089024..75af887e 100644 --- a/guide/troubleshooting.md +++ b/guide/troubleshooting.md @@ -144,6 +144,28 @@ You will need to access the file with `http` protocol. The easiest way to achiev The hash key used to invalidate optimized dependencies depend on the package lock contents, the patches applied to dependencies, and the options in the Vite config file that affects the bundling of node modules. This means that Vite will detect when a dependency is overridden using a feature as [npm overrides](https://docs.npmjs.com/cli/v9/configuring-npm/package-json#overrides), and re-bundle your dependencies on the next server start. Vite won't invalidate the dependencies when you use a feature like [npm link](https://docs.npmjs.com/cli/v9/commands/npm-link). In case you link or unlink a dependency, you'll need to force re-optimization on the next server start by using `vite --force`. We recommend using overrides instead, which are supported now by every package manager (see also [pnpm overrides](https://pnpm.io/package_json#pnpmoverrides) and [yarn resolutions](https://yarnpkg.com/configuration/manifest/#resolutions)). +## Performance bottlenecks + +If you suffer any application performance bottlenecks resulting in slow load times, you can start the built-in Node.js inspector with your Vite dev server or when building your application to create the CPU profile: + +::: code-group + +```bash [dev server] +vite --profile --open +``` + +```bash [build] +vite build --profile +``` + +::: + +::: tip Vite Dev Server +Once your application is opened in the browser, just await finish loading it and then go back to the terminal and press `p` key (will stop the Node.js inspector) then press `q` key to stop the dev server. +::: + +Node.js inspector will generate `vite-profile-0.cpuprofile` in the root folder, go to https://www.speedscope.app/, and upload the CPU profile using the `BROWSE` button to inspect the result. + ## Others ### Module externalized for browser compatibility From d508009a71058d02563d45e4e519f44453d414c0 Mon Sep 17 00:00:00 2001 From: patak Date: Fri, 11 Aug 2023 20:53:26 +0200 Subject: [PATCH 8/9] docs: icon in ViteConf action --- index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.md b/index.md index 07d3c0a0..fb683307 100644 --- a/index.md +++ b/index.md @@ -22,7 +22,7 @@ hero: text: View on GitHub link: https://github.com/vitejs/vite - theme: brand - text: ViteConf 23! + text: 🎉 ViteConf 23! link: https://viteconf.org/23 features: From fb5f4c2d2d5a3a1fbac117b5f896e42e7a88b858 Mon Sep 17 00:00:00 2001 From: waynzh Date: Sun, 13 Aug 2023 13:35:08 +0800 Subject: [PATCH 9/9] docs(cn): resolve conflicts --- guide/cli.md | 54 +++------------------------------------- guide/troubleshooting.md | 18 ++++++-------- 2 files changed, 11 insertions(+), 61 deletions(-) diff --git a/guide/cli.md b/guide/cli.md index 129348d0..be359d17 100644 --- a/guide/cli.md +++ b/guide/cli.md @@ -14,9 +14,8 @@ vite [root] #### 选项 {#options} -<<<<<<< HEAD -| 选项 | | -| ------------------------ | ------------------------------------------- | +| 选项 | | +| ------------------------ | -------------------------------------------------------------------------------------- | | `--host [host]` | 指定主机名称 (`string`) | | `--port ` | 指定端口 (`number`) | | `--https` | 使用 TLS + HTTP/2 (`boolean`) | @@ -28,32 +27,12 @@ vite [root] | `--base ` | 公共基础路径(默认为:`/`)(`string`) | | `-l, --logLevel ` | Info \| warn \| error \| silent (`string`) | | `--clearScreen` | 允许或禁用打印日志时清除屏幕 (`boolean`) | +| `--profile` | 启动内置的 Node.js 调试器(查看 [性能瓶颈](/guide/troubleshooting#performance-bottlenecks))| | `-d, --debug [feat]` | 显示调试日志 (`string \| boolean`) | | `-f, --filter ` | 过滤调试日志 (`string`) | | `-m, --mode ` | 设置环境模式 (`string`) | | `-h, --help` | 显示可用的 CLI 选项 | | `-v, --version` | 显示版本号 | -======= -| Options | | -| ------------------------ | ------------------------------------------------------------------------------------------------------------------ | -| `--host [host]` | Specify hostname (`string`) | -| `--port ` | Specify port (`number`) | -| `--https` | Use TLS + HTTP/2 (`boolean`) | -| `--open [path]` | Open browser on startup (`boolean \| string`) | -| `--cors` | Enable CORS (`boolean`) | -| `--strictPort` | Exit if specified port is already in use (`boolean`) | -| `--force` | Force the optimizer to ignore the cache and re-bundle (`boolean`) | -| `-c, --config ` | Use specified config file (`string`) | -| `--base ` | Public base path (default: `/`) (`string`) | -| `-l, --logLevel ` | Info \| warn \| error \| silent (`string`) | -| `--clearScreen` | Allow/disable clear screen when logging (`boolean`) | -| `--profile` | Start built-in Node.js inspector (check [Performance bottlenecks](/guide/troubleshooting#performance-bottlenecks)) | -| `-d, --debug [feat]` | Show debug logs (`string \| boolean`) | -| `-f, --filter ` | Filter debug logs (`string`) | -| `-m, --mode ` | Set env mode (`string`) | -| `-h, --help` | Display available CLI options | -| `-v, --version` | Display version number | ->>>>>>> d508009a71058d02563d45e4e519f44453d414c0 ## 构建 {#build} @@ -69,7 +48,6 @@ vite build [root] #### 选项 {#options-1} -<<<<<<< HEAD | 选项 | | | ------------------------------ | -------------------------------------------------------------------------------------------- | | `--target ` | 编译目标(默认为:`"modules"`)(`string`) | @@ -88,35 +66,11 @@ vite build [root] | `--base ` | 公共基础路径(默认为:`/`)(`string`) | | `-l, --logLevel ` | Info \| warn \| error \| silent (`string`) | | `--clearScreen` | 允许或禁用打印日志时清除屏幕 (`boolean`) | +| `--profile` | 启动内置的 Node.js 调试器(查看 [性能瓶颈](/guide/troubleshooting#performance-bottlenecks))| | `-d, --debug [feat]` | 显示调试日志 (`string \| boolean`) | | `-f, --filter ` | 过滤调试日志 (`string`) | | `-m, --mode ` | 设置环境模式 (`string`) | | `-h, --help` | 显示可用的 CLI 选项 | -======= -| Options | | -| ------------------------------ | ------------------------------------------------------------------------------------------------------------------- | -| `--target ` | Transpile target (default: `"modules"`) (`string`) | -| `--outDir ` | Output directory (default: `dist`) (`string`) | -| `--assetsDir ` | Directory under outDir to place assets in (default: `"assets"`) (`string`) | -| `--assetsInlineLimit ` | Static asset base64 inline threshold in bytes (default: `4096`) (`number`) | -| `--ssr [entry]` | Build specified entry for server-side rendering (`string`) | -| `--sourcemap [output]` | Output source maps for build (default: `false`) (`boolean \| "inline" \| "hidden"`) | -| `--minify [minifier]` | Enable/disable minification, or specify minifier to use (default: `"esbuild"`) (`boolean \| "terser" \| "esbuild"`) | -| `--manifest [name]` | Emit build manifest json (`boolean \| string`) | -| `--ssrManifest [name]` | Emit ssr manifest json (`boolean \| string`) | -| `--force` | Force the optimizer to ignore the cache and re-bundle (experimental)(`boolean`) | -| `--emptyOutDir` | Force empty outDir when it's outside of root (`boolean`) | -| `-w, --watch` | Rebuilds when modules have changed on disk (`boolean`) | -| `-c, --config ` | Use specified config file (`string`) | -| `--base ` | Public base path (default: `/`) (`string`) | -| `-l, --logLevel ` | Info \| warn \| error \| silent (`string`) | -| `--clearScreen` | Allow/disable clear screen when logging (`boolean`) | -| `--profile` | Start built-in Node.js inspector (check [Performance bottlenecks](/guide/troubleshooting#performance-bottlenecks)) | -| `-d, --debug [feat]` | Show debug logs (`string \| boolean`) | -| `-f, --filter ` | Filter debug logs (`string`) | -| `-m, --mode ` | Set env mode (`string`) | -| `-h, --help` | Display available CLI options | ->>>>>>> d508009a71058d02563d45e4e519f44453d414c0 ## 其他 {#others} diff --git a/guide/troubleshooting.md b/guide/troubleshooting.md index b17086ab..760cf031 100644 --- a/guide/troubleshooting.md +++ b/guide/troubleshooting.md @@ -144,12 +144,9 @@ import './Foo.js' // 应该为 './foo.js' 在 Vite 中通过一个哈希值来决定优化后的依赖项是否有效,这个值取决于包锁定的内容、应用于依赖项的补丁以及 Vite 配置文件中影响 node_modules 打包的选项。这意味着,当使用像 [npm overrides](https://docs.npmjs.com/cli/v9/configuring-npm/package-json#overrides) 这样的功能覆盖依赖项时,Vite 将检测到,并在下一次服务器启动时重新打包您的依赖项。当您使用像 [npm link](https://docs.npmjs.com/cli/v9/commands/npm-link) 这样的功能时,Vite 不会使依赖项无效。如果您链接或取消链接一个依赖项,那么您需要使用 `vite --force` 在下一次服务器启动时强制重新预构建。我们建议使用 overrides,它们现在被每个包管理器所支持(还可以参见 [pnpm overrides](https://pnpm.io/package_json#pnpmoverrides) 和 [yarn resolutions](https://yarnpkg.com/configuration/manifest/#resolutions))。 -<<<<<<< HEAD -## 其他 {#others} -======= -## Performance bottlenecks +## 性能瓶颈 {#performance-bottlenecks} -If you suffer any application performance bottlenecks resulting in slow load times, you can start the built-in Node.js inspector with your Vite dev server or when building your application to create the CPU profile: +如果你遇到应用程序性能瓶颈导致加载缓慢,可以在启动 Vite 开发服务器或在构建应用程序时使用内置的 Node.js 调试器来创建 CPU 性能分析文件: ::: code-group @@ -163,16 +160,15 @@ vite build --profile ::: -::: tip Vite Dev Server -Once your application is opened in the browser, just await finish loading it and then go back to the terminal and press `p` key (will stop the Node.js inspector) then press `q` key to stop the dev server. +::: tip Vite 开发服务器 +一旦应用程序在浏览器中打开,请等待其完成加载,然后返回终端并按下 `p` 键(将停止 Node.js 调试器),然后按下 `q` 键停止开发服务器。 ::: -Node.js inspector will generate `vite-profile-0.cpuprofile` in the root folder, go to https://www.speedscope.app/, and upload the CPU profile using the `BROWSE` button to inspect the result. +Node.js 调试器将在根文件夹中生成 `vite-profile-0.cpuprofile` 文件,前往 https://www.speedscope.app/,点击 `BROWSE` 按钮上传 CPU 性能分析文件以检查结果。 -## Others ->>>>>>> d508009a71058d02563d45e4e519f44453d414c0 +## 其他 {#others} -### Module externalized for browser compatibility {#module-externalized-for-browser-compatibility} +### 为了浏览器兼容性而模块外部化 {#module-externalized-for-browser-compatibility} 当你在浏览器中使用一个 Node.js 模块时,Vite 会输出以下警告: