You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
环境实例首次在 `v6.0` 中引入。计划在 `v7.0` 中废弃现在的 `server.moduleGraph` 和其他方法。我们不建议你现在就放弃 server 方法。要识别你的使用情况,请在你的 vite 配置中设置以下。
22
-
=======
23
-
::: warning Future Deprecation
24
-
The `Environment` instance was first introduced at `v6.0`. The deprecation of `server.moduleGraph` and other methods that are now in environments is planned for `v7.0`. We don't recommend moving away from server methods yet. To identify your usage, set these in your vite config.
25
-
>>>>>>> d8c74e66bba83268fb86bc8aef187cf2a9f1be55
12
+
`环境`实例首次在 `v6.0` 中引入。计划在 `v7.0` 中废弃现在的 `server.moduleGraph` 和其他方法。我们不建议你现在就放弃 server 方法。要识别你的使用情况,请在你的 vite 配置中设置以下。
26
13
27
14
```ts
28
15
future: {
@@ -35,20 +22,12 @@ future: {
35
22
36
23
## 动机 {#motivation}
37
24
38
-
<<<<<<< HEAD
39
-
// TODO: (保持原文)
40
-
=======
41
-
In Vite v5 and before, a single Vite dev server always had two environments (`client` and `ssr`). The `server.moduleGraph` had mixed modules from both of these environments. Nodes were connected through `clientImportedModules` and `ssrImportedModules` lists (but a single `importers` list was maintained for each). A transformed module was represented by an `id` and a `ssr` boolean. This boolean needed to be passed to APIs, for example `server.moduleGraph.getModuleByUrl(url, ssr)` and `server.transformRequest(url, { ssr })`.
25
+
在 Vite v5 及之前的版本中,一个 Vite 开发服务器总是有两个环境(`client` 和 `ssr`)。`server.moduleGraph` 混合了来自这两个环境的模块。节点通过 `clientImportedModules` 和 `ssrImportedModules` 列表连接(但每种环境只维护一个 `importers` 列表)。转换后的模块由一个 `id` 和一个 `ssr` 布尔值表示。该布尔值需要传递给 API,例如 `server.moduleGraph.getModuleByUrl(url, ssr)` 和 `server.transformRequest(url, { ssr })`。
42
26
43
-
In Vite v6, it is now possible to create any number of custom environments (`client`, `ssr`, `edge`, etc). A single `ssr` boolean isn't enough anymore. Instead of changing the APIs to be of the form `server.transformRequest(url, { environment })`, we moved these methods to the environment instance allowing them to be called without a Vite dev server.
44
-
>>>>>>> d8c74e66bba83268fb86bc8aef187cf2a9f1be55
27
+
在 Vite v6 中,现在可以创建任意数量的自定义环境(`client`, `ssr`, `edge`等)。单一的 `ssr` 布尔值已经不够用了。我们没有将 API 改为 `server.transformRequest(url, { environment })`,而是将这些方法移到了环境实例中,这样就可以在没有 Vite dev 服务器的情况下调用这些方法。
See [Shared plugins during build](/guide/api-environment.md#shared-plugins-during-build).
12
-
>>>>>>> d8c74e66bba83268fb86bc8aef187cf2a9f1be55
13
8
14
9
影响范围:`Vite 插件作者`
15
10
@@ -19,18 +14,11 @@ See [Shared plugins during build](/guide/api-environment.md#shared-plugins-durin
19
14
20
15
## 动机 {#motivation}
21
16
22
-
<<<<<<< HEAD
23
-
// TODO: (保持原文)
24
-
=======
25
-
Align dev and build plugin pipelines.
26
-
>>>>>>> d8c74e66bba83268fb86bc8aef187cf2a9f1be55
17
+
调整开发和构建插件管道。
27
18
28
19
## 迁移指南 {#migration-guide}
29
20
30
-
<<<<<<< HEAD
31
-
// TODO: (保持原文)
32
-
=======
33
-
To be able to share plugins across environments, plugin state must be keyed by the current environment. A plugin of the following form will count the number of transformed modules across all environments.
0 commit comments