Skip to content

Commit 3166f52

Browse files
committed
docs(cn): resolve conflicts
1 parent 49cb2a8 commit 3166f52

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

docs/plugin-development/index.md

+7-17
Original file line numberDiff line numberDiff line change
@@ -1084,19 +1084,13 @@ interface ImportedExternalChunk {
10841084
}
10851085
```
10861086

1087-
<<<<<<< HEAD
1088-
此钩子通过提供导入表达式参数左侧(`import(`)和右侧(`)`)的代码替换,提供了对动态导入如何呈现的细粒度控制。返回`null`将推迟到此类型的其他钩子,最终呈现特定于格式的默认值。
1087+
请参阅 [`chunkFileNames`](../configuration-options/index.md#output-chunkfilenames) 选项,以了解 `PreRenderedChunk` 类型的相关信息。
10891088

1090-
`format` 是呈现的输出格式, `moduleId` 是执行动态导入的模块的 ID。如果导入可以解析为内部或外部 ID,则 `targetModuleId` 将设置为此 ID,否则将为 `null`。如果动态导入包含由 [`resolveDynamicImport`](#resolvedynamicimport) 钩子解析为替换字符串的非字符串表达式,则 `customResolution` 将包含该字符串。
1091-
=======
1092-
See the [`chunkFileNames`](../configuration-options/index.md#output-chunkfilenames) option for the `PreRenderedChunk` type.
1089+
这个钩子函数提供了对动态导入渲染的精细控制,它通过替换导入表达式参数左侧(`import(`)和右(`)`)侧的代码实现这一功能。如果返回 `null`,则会降级到其他同类型的钩子函数,最终渲染出特定格式的默认值。
10931090

1094-
This hook provides fine-grained control over how dynamic imports are rendered by providing replacements for the code to the left (`import(`) and right (`)`) of the argument of the import expression. Returning `null` defers to other hooks of this type and ultimately renders a format-specific default.
1091+
`format` 是渲染的输出格式,`moduleId` 是进行动态导入的模块的 id。如果导入可以被解析为内部或外部 id,那么 `targetModuleId` 将被设置为这个 id,否则它将是 `null`。如果动态导入包含了一个非字符串表达式,这个表达式被 [`resolveDynamicImport`](#resolvedynamicimport) 钩子函数解析为一个替换字符串,那么 `customResolution` 将包含那个字符串。`chunk``targetChunk` 分别提供了执行导入的块和被导入的块(目标块)的额外信息。`getTargetChunkImports` 返回一个数组,包含了被目标块导入的块。如果目标块未解析或是外部的,`targetChunk` 将为 null`getTargetChunkImports` 也将返回 null。
10951092

1096-
`format` is the rendered output format, `moduleId` the id of the module performing the dynamic import. If the import could be resolved to an internal or external id, then `targetModuleId` will be set to this id, otherwise it will be `null`. If the dynamic import contained a non-string expression that was resolved by a [`resolveDynamicImport`](#resolvedynamicimport) hook to a replacement string, then `customResolution` will contain that string. `chunk` and `targetChunk` provide additional information about the chunk performing the import and the chunk being imported (the target chunk), respectively. `getTargetChunkImports` returns an array containing chunks which are imported by the target chunk. If the target chunk is unresolved or external, `targetChunk` will be null and `getTargetChunkImports` will return null.
1097-
1098-
The `PreRenderedChunkWithFileName` type is identical to the `PreRenderedChunk` type except for the addition of the `fileName` field, which contains the path and file name of the chunk. `fileName` may contain a placeholder if the chunk file name format contains a hash.
1099-
>>>>>>> ab7bfa8fe9c25e41cc62058fa2dcde6b321fd51d
1093+
`PreRenderedChunkWithFileName` 类型与 `PreRenderedChunk` 类型相同,只是多了一个 `fileName` 字段,这个字段包含了块的路径和文件名。如果块文件名格式包含了哈希,`fileName` 可能会包含一个占位符。
11001094

11011095
以下代码将使用自定义处理程序替换所有动态导入,添加 `import.meta.url` 作为第二个参数,以允许处理程序正确解析相对导入:
11021096

@@ -1148,12 +1142,9 @@ function retainImportExpressionPlugin() {
11481142
}
11491143
```
11501144
1151-
<<<<<<< HEAD
1152-
请注意,当此钩子在非 ES 格式中重写动态导入时,不会生成任何交互代码以确保例如默认导出可用作`.default`。插件有责任确保重写的动态导入返回一个 Promise,该 Promise 解析为适当的命名空间对象。
1153-
=======
1154-
When a dynamic import occurs, the browser will fetch the requested module and parse it. If the target module is discovered to have imports and they have not already been fetched, the browser must perform more network requests before it can execute the module. This will incur the latency of an additional network round trip. For static modules, Rollup will hoist transitive dependencies ([`hoistTransitiveDependencies`](../configuration-options/index.md#output-hoisttransitiveimports)) to prevent this from occuring. However, dependency hoisting is currently not automatically performed for dynamic imports.
1145+
当进行动态导入时,浏览器会获取并解析请求的模块。如果目标模块被发现有导入,并且这些导入还未被获取,浏览器需要进行更多的网络请求才能执行该模块。这将导致额外一轮网络往返的延迟。对于静态模块,Rollup 会提升转移依赖([`hoistTransitiveDependencies`](../configuration-options/index.md#output-hoisttransitiveimports)),以防止这种情况发生。然而,目前还没有自动为动态导入执行依赖提升的操作。
11551146
1156-
The following plugin can achieve similar preloading behavior for dynamic imports:
1147+
以下的插件可以实现类似于动态导入预加载的功能:
11571148
11581149
```js twoslash
11591150
// ---cut-start---
@@ -1196,8 +1187,7 @@ import('./lib.js');
11961187
```
11971188
<!-- prettier-ignore-end -->
11981189
1199-
Note that when this hook rewrites dynamic imports in non-ES formats, no interop code to make sure that e.g. the default export is available as `.default` is generated. It is the responsibility of the plugin to make sure the rewritten dynamic import returns a Promise that resolves to a proper namespace object.
1200-
>>>>>>> ab7bfa8fe9c25e41cc62058fa2dcde6b321fd51d
1190+
请注意,当此钩子在非 ES 格式中重写动态导入时,不会生成任何交互代码以确保例如默认导出可用作 `.default`。插件有责任确保重写的动态导入返回一个 Promise,该 Promise 解析为适当的命名空间对象。
12011191
12021192
### renderError
12031193

0 commit comments

Comments
 (0)