Skip to content

Commit

Permalink
docs(en): merge docs-cn/sync-docs into docs-cn/dev @ 12d05d4 (vitejs#752
Browse files Browse the repository at this point in the history
)

* docs: yarn link and outdated dependencies (#12790)
* docs: fix pnpm link (#12803)
* docs: remove mention to deprecated vue-class-components (#12817)
* docs(cn): resolve all conflicts.
  • Loading branch information
docschina-bot authored Apr 12, 2023
1 parent 1bce2ff commit 8c7a8ad
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion config/shared-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ const obj = {
更高级的自定义解析方法可以通过 [插件](/guide/api-plugin) 实现。

::: warning 在 SSR 中使用
如果你已经为 [SSR 外部化的依赖](/guide/ssr.md#ssr-externals) 配置了别名,你可能想要为真实的 `node_modules` 包配别名. [Yarn](https://classic.yarnpkg.com/en/docs/cli/add/#toc-yarn-add-alias)[pnpm](https://pnpm.js.org/en/aliases) 都支持通过 `npm:` 前缀配置别名。
如果你已经为 [SSR 外部化的依赖](/guide/ssr.md#ssr-externals) 配置了别名,你可能想要为真实的 `node_modules` 包配别名. [Yarn](https://classic.yarnpkg.com/en/docs/cli/add/#toc-yarn-add-alias)[pnpm](https://pnpm.io/aliases/) 都支持通过 `npm:` 前缀配置别名。
:::

## resolve.dedupe {#resolve-dedupe}
Expand Down
2 changes: 1 addition & 1 deletion guide/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export type { T }

如果你正在使用一个严重依赖 class fields 的库,请注意该库对此选项的预期设置。

大多数库都希望 `"useDefineForClassFields": true`,如 [MobX](https://mobx.js.org/installation.html#use-spec-compliant-transpilation-for-class-properties)[Vue Class Components 8.x](https://github.com/vuejs/vue-class-component/issues/465)
大多数库都希望 `"useDefineForClassFields": true`,如 [MobX](https://mobx.js.org/installation.html#use-spec-compliant-transpilation-for-class-properties)

但是有几个库还没有兼容这个新的默认值,其中包括 [`lit-element`](https://github.com/lit/lit-element/issues/1030)。如果遇到这种情况,请将 `useDefineForClassFields` 设置为 `false`

Expand Down
4 changes: 2 additions & 2 deletions guide/ssr.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,10 @@ const html = await vueServerRenderer.renderToString(app, ctx)
当运行 SSR 时依赖会由 Vite 的 SSR 转换模块系统作外部化。这会同时提速开发与构建。
例如,如果依赖项需要通过 Vite 的管道进行转换,因为在这些依赖在管道中使用 Vite 特性时是不转翻译的,则可以将它们添加到 [`ssr.noExternal`](../config/ssr-options.md#ssrnoexternal) 中
对于采用链接的依赖,它们将默认不会被外部化,这是为了能使其利用 Vite HMR 的优势。如果你不需要这一功效,例如,想要把这些依赖当成非链接情况来测试,你可以将其添加到 [`ssr.external`](../config/ssr-options.md#ssr-external)
:::warning 使用别名
如果你为某个包配置了一个别名,为了能使 SSR 外部化依赖功能正常工作,你可能想要使用的别名应该指的是实际的 `node_modules` 中的包。[Yarn](https://classic.yarnpkg.com/en/docs/cli/add/#toc-yarn-add-alias) 和 [pnpm](https://pnpm.js.org/en/aliases) 都支持通过 `npm:` 前缀来设置别名。
如果你为某个包配置了一个别名,为了能使 SSR 外部化依赖功能正常工作,你可能想要使用的别名应该指的是实际的 `node_modules` 中的包。[Yarn](https://classic.yarnpkg.com/en/docs/cli/add/#toc-yarn-add-alias) 和 [pnpm](https://pnpm.io/aliases/) 都支持通过 `npm:` 前缀来设置别名。
:::
## SSR 专有插件逻辑 {#ssr-specific-plugin-logic}
Expand Down
6 changes: 6 additions & 0 deletions guide/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ This can be caused by a circular dependency. To solve this, try breaking the loo

你需要通过 `http` 协议访问该文件。最简单的办法就是使用 `npx vite preview`

## 优化依赖 {#optimize-dependencies}

### 链接本地包时过期预构建依赖项 {#outdated-prebundled-deps-when-linking-to-a-local-package}

在 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))。

## 其他 {#others}

### Module externalized for browser compatibility {#module-externalized-for-browser-compatibility}
Expand Down

0 comments on commit 8c7a8ad

Please sign in to comment.