From 77f17ba55c99da20f230e38bc4804f2d2d114024 Mon Sep 17 00:00:00 2001 From: Hugohong258 <282228220+Hugohong258@users.noreply.github.com> Date: Wed, 23 Sep 2026 23:53:34 +0800 Subject: [PATCH] docs(zh-CN): update installation guide for current features --- .../current/installation.mdx | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/website/i18n/zh-CN/docusaurus-plugin-content-docs/current/installation.mdx b/website/i18n/zh-CN/docusaurus-plugin-content-docs/current/installation.mdx index 8ed66861..8b570ba4 100644 --- a/website/i18n/zh-CN/docusaurus-plugin-content-docs/current/installation.mdx +++ b/website/i18n/zh-CN/docusaurus-plugin-content-docs/current/installation.mdx @@ -11,10 +11,11 @@ title: 安装 > -Immer 可以作为直接依赖项安装,并且可以在任何 ES5 环境中工作: +Immer 可以作为直接依赖项安装: - Yarn: `yarn add immer` - NPM: `npm install immer` +- Deno: `deno install immer` - CDN: 暴露的全局变量是 `immer` - Unpkg: `` - JSDelivr: `` @@ -30,7 +31,7 @@ _本节仅适用于版本 6 及更高版本_ | 功能 | 描述 | 调用方法 | | --- | --- | --- | -| ES 5 支持 | 如果您的应用程序需要能够在较旧的 JavaScript 环境(例如 Internet Explorer 或 React Native)上运行,请启用此功能。 | `enableES5()` | +| [数组方法优化](./array-methods.md) | 优化数组方法的处理,提升大量数组操作的性能 | `enableArrayMethods()` | | [ES2015 Map and Set 支持](./complex-objects.md) | 要使 Immer 能够对原生 Map 和 Set 集合进行操作,请启用此功能 | `enableMapSet()` | | [JSON 补丁 支持](./patches.mdx) | Immer 可以跟踪您对 draft 对象所做的所有更改。这对于使用 JSON 补丁时传达更改很有用 | `enablePatches()` | @@ -57,17 +58,18 @@ expect(usersById_v1.get("michel").country).toBe("NL") expect(usersById_v2.get("michel").country).toBe("UK") ``` -Immer 以大约 3KB 的 gzip 压缩开始。每个启用的插件都会增加 < 1 KB。细分如下 +基础版 Immer 经 gzip 压缩后约为 3 KB。每启用一个插件,大小约增加 1–2 KB。具体如下: ``` Import size report for immer: ┌───────────────────────┬───────────┬────────────┬───────────┐ -│ (index) │ just this │ cumulative │ increment │ +│ (index) │ just this │ cumulative │ increment │ ├───────────────────────┼───────────┼────────────┼───────────┤ -│ import * from 'immer' │ 5033 │ 0 │ 0 │ -│ produce │ 3324 │ 3324 │ 0 │ -│ enableMapSet │ 4030 │ 4039 │ 715 │ -│ enablePatches │ 4112 │ 4826 │ 787 │ +│ import * from 'immer' │ 6908 │ 0 │ 0 │ +│ produce │ 4183 │ 4183 │ 0 │ +│ enableMapSet │ 4971 │ 4980 │ 797 │ +│ enablePatches │ 5335 │ 6097 │ 1117 │ +│ enableArrayMethods │ 4768 │ 6659 │ 562 │ └───────────────────────┴───────────┴────────────┴───────────┘ (this report was generated by npmjs.com/package/import-size) ``` @@ -77,4 +79,4 @@ Import size report for immer: 默认情况下,`produce` 尝试使用代理以获得最佳性能。但是,在较旧的 JavaScript 引擎上,代理不可用。例如,在 Android 上运行 Microsoft Internet Explorer 或 React Native(如果 React Native < v0.59 或在 React Native < v0.64 上使用 Hermes 引擎)时。在这种情况下,Immer 将回退到与 ES5 兼容的实现,其工作方式相同,但速度稍慢 - 从版本 6 开始,必须通过调用 `enableES5()` 显式启用对回退实现的支持 -- Version 10 drops the fallback implementation fully, and cannot be used in browsers / engines that don't support Proxy. +- 从版本 10 开始,Immer 完全移除了备用实现,因此不能在不支持 `Proxy` 的浏览器或 JavaScript 引擎中使用。