Skip to content

docs(cn): translate src/content/plugins/dll-plugin.md #795

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jul 8, 2020

Conversation

weiyuan0609
Copy link

describe your changes...

  • Read and sign the CLA. PRs that haven't signed it won't be accepted.
  • Make sure your PR complies with the writer's guide.
  • Review the diff carefully as sometimes this can reveal issues.
  • Do not abandon your Pull Request: Stale Pull Requests.
  • Remove these instructions from your PR as they are for your eyes only.

@netlify
Copy link

netlify bot commented Jun 29, 2020

Deploy preview for cn-webpack ready!

Built with commit b24f560

https://deploy-preview-795--cn-webpack.netlify.app

@netlify
Copy link

netlify bot commented Jun 29, 2020

Deploy preview for cn-webpack ready!

Built with commit 38e37da

https://deploy-preview-795--cn-webpack.netlify.app

- `path`: __absolute path__ to the manifest json file (output)
- `entryOnly` (boolean = true): if `true`, only entry points will be exposed
- `type`: type of the dll bundle
- `context` (可选的): manifest 文件中请求的上下文(context)(默认值为 webpack 的上下文(context))
Copy link
Member

@QC-L QC-L Jul 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `context` (可选的): manifest 文件中请求的上下文(context)(默认值为 webpack 的上下文(context))
- `context`(可选):manifest 文件中请求的 context默认值为 webpack context

- `entryOnly` (boolean = true): if `true`, only entry points will be exposed
- `type`: type of the dll bundle
- `context` (可选的): manifest 文件中请求的上下文(context)(默认值为 webpack 的上下文(context))
- `format` (boolean = false): 如果为 `true`,则 manifest json 文件 (输出文件) 将被格式化。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `format` (boolean = false): 如果为 `true`,则 manifest json 文件 (输出文件) 将被格式化。
- `format` (boolean = false)如果为 `true`,则 manifest.json 文件 (输出文件) 将被格式化。

- `context` (可选的): manifest 文件中请求的上下文(context)(默认值为 webpack 的上下文(context))
- `format` (boolean = false): 如果为 `true`,则 manifest json 文件 (输出文件) 将被格式化。
- `name`: 暴露出的 DLL 的函数名 ([TemplatePaths](https://github.com/webpack/webpack/blob/master/lib/TemplatedPathPlugin.js): `[hash]` & `[name]` )
- `path`: manifest json 文件的 __绝对路径__ (输出文件)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `path`: manifest json 文件的 __绝对路径__ (输出文件)
- `path`manifest.json 文件的__绝对路径__输出文件

- `type`: type of the dll bundle
- `context` (可选的): manifest 文件中请求的上下文(context)(默认值为 webpack 的上下文(context))
- `format` (boolean = false): 如果为 `true`,则 manifest json 文件 (输出文件) 将被格式化。
- `name`: 暴露出的 DLL 的函数名 ([TemplatePaths](https://github.com/webpack/webpack/blob/master/lib/TemplatedPathPlugin.js): `[hash]` & `[name]` )
Copy link
Member

@QC-L QC-L Jul 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `name`: 暴露出的 DLL 的函数名 ([TemplatePaths](https://github.com/webpack/webpack/blob/master/lib/TemplatedPathPlugin.js): `[hash]` & `[name]` )
- `name`暴露出的 DLL 的函数名[TemplatePaths](https://github.com/webpack/webpack/blob/master/lib/TemplatedPathPlugin.js)`[hash]` & `[name]`

- `format` (boolean = false): 如果为 `true`,则 manifest json 文件 (输出文件) 将被格式化。
- `name`: 暴露出的 DLL 的函数名 ([TemplatePaths](https://github.com/webpack/webpack/blob/master/lib/TemplatedPathPlugin.js): `[hash]` & `[name]` )
- `path`: manifest json 文件的 __绝对路径__ (输出文件)
- `entryOnly` (boolean = true): 如果为 `true`,则仅暴露入口点
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `entryOnly` (boolean = true): 如果为 `true`则仅暴露入口点
- `entryOnly` (boolean = true)如果为 `true`则仅暴露入口


```javascript
new webpack.DllPlugin(options);
```

W> We recommend using DllPlugin only with `entryOnly: true`, otherwise tree shaking in the DLL won't work as all the exports might be used.
W> 我们建议仅将 DllPlugin `entryOnly: true` 一起使用,否则 DLL 中的 tree shaking 将无法工作,因为可能会使用所有导出。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
W> 我们建议仅将 DllPlugin `entryOnly: true` 一起使用,否则 DLL 中的 tree shaking 将无法工作,因为可能会使用所有导出
W> 我们建议 DllPlugin 只在 `entryOnly: true` 时使用,否则 DLL 中的 tree shaking 将无法工作,因为所有 exports 均可使用


Creates a `manifest.json` which is written to the given `path`. It contains mappings from require and import requests to module ids. It is used by the `DllReferencePlugin`.
在给定的 `path` 路径下创建一个名为 `manifest.json` 的文件。 这个文件包含了从 require import 的 request 到模块 id 的映射。 `DllReferencePlugin` 也会用到这个文件。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
在给定的 `path` 路径下创建一个名为 `manifest.json` 的文件。 这个文件包含了从 require 和 import request 到模块 id 的映射。 `DllReferencePlugin` 也会用到这个文件。
在给定的 `path` 路径下创建一个 `manifest.json` 文件。这个文件包含了从 require 和 import request 到模块 id 的映射。`DllReferencePlugin` 也会用到这个文件。


Combine this plugin with [`output.library`](/configuration/output/#outputlibrary) option to expose (aka, put into the global scope) the dll function.
这个插件与 [`output.library`](/configuration/output/#outputlibrary) 的选项相结合可以暴露出 (也称为放入全局作用域) dll 函数。
Copy link
Member

@QC-L QC-L Jul 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
这个插件与 [`output.library`](/configuration/output/#outputlibrary) 的选项相结合可以暴露出 (也称为放入全局作用域) dll 函数。
此插件与 [`output.library`](/configuration/output/#outputlibrary) 的选项相结合可以暴露出也称为放入全局作用域dll 函数。



## `DllReferencePlugin`

This plugin is used in the primary webpack config, it references the dll-only-bundle(s) to require pre-built dependencies.
这个插件是在 webpack 主配置文件中设置的, 这个插件把只有 dll 的 bundle(们)(dll-only-bundle(s))引用到需要的预编译的依赖。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
这个插件是在 webpack 主配置文件中设置的, 这个插件把只有 dll 的 bundle(们)(dll-only-bundle(s))引用到需要的预编译的依赖
此插件配置在 webpack 的主配置文件中,此插件会把 dll-only-bundles 引用到需要的预编译的依赖中


_Two separate example folders. Demonstrates scope and context._
_两个单独的用例,用来分别演示作用域(scope)和上下文(context)。_
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
_两个单独的用例,用来分别演示作用域(scope)和上下文(context)_
_两个单独的用例,用来分别演示作用域scope和上下文context_



## References
## 引用参考(References)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## 引用参考(References)
## 参考

@@ -105,16 +105,16 @@ new webpack.DllReferencePlugin({
```


## Examples
## 示例(Examples)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## 示例(Examples)
## 示例


W> `DllReferencePlugin` and `DllPlugin` are used in _separate_ webpack configs.
W> `DllReferencePlugin` `DllPlugin` 都是在 _单独的_ webpack 设置中使用的。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
W> `DllReferencePlugin``DllPlugin` 都是在 _单独的_ webpack 设置中使用的
W> `DllReferencePlugin``DllPlugin` 都是在_单独的_ webpack 配置中使用的


Because this happens after resolving every file in the dll bundle, the same paths must be available for the consumer of the dll bundle. i.e. if the dll contains `lodash` and the file `abc`, `require('lodash')` and `require('./abc')` will be used from the dll, rather than building them into the main bundle.
由于这是在解析了 dll 中每个文件之后才发生的,相同的路径必须能够确保这个 dll bundle 的使用者(不一定是人,可指某些代码)有权限访问。 举例来说, 假如一个 dll bundle 中含有 `loadash`库以及文件 `abc`, 那么 `require("lodash")` `require("./abc")` 都不会被编译进主要的 bundle 文件,而是会被 dll 所使用。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
由于这是在解析了 dll 中每个文件之后才发生的,相同的路径必须能够确保这个 dll bundle 的使用者(不一定是人,可指某些代码)有权限访问。 举例来说, 假如一个 dll bundle 中含有 `loadash`库以及文件 `abc` 那么 `require("lodash")``require("./abc")` 都不会被编译进主要的 bundle 文件,而是会被 dll 所使用。
由于这是在解析了 dll 中每个文件之后才触发的,因此相同的路径必须能够确保这个 dll bundle 的使用者不一定是人,可指某些代码有权限访问。举例来说,假如一个 dll bundle 中含有 `loadash` 库以及文件 `abc`,那么 `require("lodash")``require("./abc")` 都不会被编译进主 bundle 文件中,而是会被 dll 所使用。


#### Mapped Mode

The content of the dll is mapped to the current directory. If a required file matches a file in the dll (after resolving), then the file from the dll is used instead.
dll 中的内容被映射到了当前目录下。如果一个被 `require` 的文件符合 dll 中的某个文件(解析之后),那么这个dll中的这个文件就会被使用。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
dll 中的内容被映射到了当前目录下。如果一个被 `require` 的文件符合 dll 中的某个文件(解析之后),那么这个dll中的这个文件就会被使用
dll 中的内容会被映射到当前目录下。如果被 `require` 的文件与 dll 中的某个文件匹配(解析之后),那么这个 dll 中的文件就会被使用


#### Scoped Mode

The content of the dll is accessible under a module prefix. i.e. with `scope = 'xyz'` a file `abc` in the dll can be access via `require('xyz/abc')`.
dll 中的内容可以在模块前缀下被引用,举例来说,令 `scope = 'xyz'` 的话,这个 dll 中的名为 `abc` 的文件可以通过 `require('xyz/abc')` 来获取。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
dll 中的内容可以在模块前缀下被引用,举例来说, `scope = 'xyz'` 的话,这个 dll 中的名为 `abc` 的文件可以通过 `require('xyz/abc')` 来获取。
dll 中的内容可以使用模块前缀的方式引用,举例来说,设置 `scope = 'xyz'`,这个 dll 中的名为 `abc` 的文件可以通过 `require('xyz/abc')` 来获取。


This plugin can be used in two different modes, _scoped_ and _mapped_.
这个插件支持两种模式,分别是作用域(_scoped_)和映射(_mapped_)。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
这个插件支持两种模式,分别是作用域(_scoped_)和映射(_mapped_)
这个插件支持两种模式,分别是作用域_scoped_和映射_mapped_


W> Keep the `name` consistent with [`output.library`](/configuration/output/#outputlibrary).
W> [`output.library`](/configuration/output/#outputlibrary) 保持 `name` 的一致性。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
W> 与 [`output.library`](/configuration/output/#outputlibrary) 保持 `name` 的一致性
W> 保持 `name` [`output.library`](/configuration/output/#outputlibrary) 一致


```javascript
new webpack.DllReferencePlugin(options);
```

References a dll manifest file to map dependency names to module ids, then requires them as needed using the internal `__webpack_require__` function.
通过引用 dll manifest 文件来把依赖的名称映射到模块的 id 上,之后再在需要的时候通过内置的 `__webpack_require__` 函数来 `require` 他们
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
通过引用 dll 的 manifest 文件来把依赖的名称映射到模块的 id 上,之后再在需要的时候通过内置的 `__webpack_require__` 函数来 `require` 他们
通过引用 dll 的 manifest 文件来把依赖的名称映射到模块的 id 上,之后再在需要的时候通过内置的 `__webpack_require__` 函数来 `require` 对应的模块

- `name` (optional): an identifier where the dll is exposed (defaults to `manifest.name`) (see also [`externals`](/configuration/externals/))
- `scope` (optional): prefix which is used for accessing the content of the dll
- `sourceType` (optional): how the dll is exposed ([libraryTarget](/configuration/output/#outputlibrarytarget))
- `context`: (__绝对路径__) manifest (或者是内容属性)中请求的上下文
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `context`: (__绝对路径__) manifest (或者是内容属性)中请求的上下文
- `context`:(__绝对路径__manifest (或者是内容属性)中的请求上下文

- `scope` (optional): prefix which is used for accessing the content of the dll
- `sourceType` (optional): how the dll is exposed ([libraryTarget](/configuration/output/#outputlibrarytarget))
- `context`: (__绝对路径__) manifest (或者是内容属性)中请求的上下文
- `extensions`: 用于解析 dll bundle 中模块的扩展名 (仅在使用 'scope' 时使用)。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `extensions`: 用于解析 dll bundle 中模块的扩展名 (仅在使用 'scope' 时使用)。
- `extensions`用于解析 dll bundle 中模块的扩展名 (仅在使用 'scope' 时使用)。

- `sourceType` (optional): how the dll is exposed ([libraryTarget](/configuration/output/#outputlibrarytarget))
- `context`: (__绝对路径__) manifest (或者是内容属性)中请求的上下文
- `extensions`: 用于解析 dll bundle 中模块的扩展名 (仅在使用 'scope' 时使用)。
- `manifest` : 包含 `content` 和 `name` 的对象,或者在编译时(compilation)的一个用于加载的 JSON manifest 绝对路径
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `manifest` : 包含 `content``name` 的对象,或者在编译时(compilation)的一个用于加载的 JSON manifest 绝对路径
- `manifest`包含 `content``name` 的对象,或者是一个字符串 —— 编译时用于加载 JSON manifest 的绝对路径

- `context`: (__绝对路径__) manifest (或者是内容属性)中请求的上下文
- `extensions`: 用于解析 dll bundle 中模块的扩展名 (仅在使用 'scope' 时使用)。
- `manifest` : 包含 `content` 和 `name` 的对象,或者在编译时(compilation)的一个用于加载的 JSON manifest 绝对路径
- `content` (可选的): 请求到模块 id 的映射 (默认值为 `manifest.content`)
Copy link
Member

@QC-L QC-L Jul 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `content` (可选的): 请求到模块 id 的映射 (默认值为 `manifest.content`)
- `content`(可选):请求到模块 id 的映射默认值为 `manifest.content`

- `extensions`: 用于解析 dll bundle 中模块的扩展名 (仅在使用 'scope' 时使用)。
- `manifest` : 包含 `content` 和 `name` 的对象,或者在编译时(compilation)的一个用于加载的 JSON manifest 绝对路径
- `content` (可选的): 请求到模块 id 的映射 (默认值为 `manifest.content`)
- `name` (可选的): dll 暴露的地方的名称 (默认值为 `manifest.name`) (可参考[`externals`](/configuration/externals/))
Copy link
Member

@QC-L QC-L Jul 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `name` (可选的): dll 暴露的地方的名称 (默认值为 `manifest.name`) (可参考[`externals`](/configuration/externals/))
- `name`(可选):dll 暴露地方的名称(默认值为 `manifest.name`)(可参考[`externals`](/configuration/externals/)

- `manifest` : 包含 `content` 和 `name` 的对象,或者在编译时(compilation)的一个用于加载的 JSON manifest 绝对路径
- `content` (可选的): 请求到模块 id 的映射 (默认值为 `manifest.content`)
- `name` (可选的): dll 暴露的地方的名称 (默认值为 `manifest.name`) (可参考[`externals`](/configuration/externals/))
- `scope` (可选的): dll 中内容的前缀
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `scope` (可选的): dll 中内容的前缀
- `scope` (可选):dll 中内容的前缀

- `content` (可选的): 请求到模块 id 的映射 (默认值为 `manifest.content`)
- `name` (可选的): dll 暴露的地方的名称 (默认值为 `manifest.name`) (可参考[`externals`](/configuration/externals/))
- `scope` (可选的): dll 中内容的前缀
- `sourceType` (可选的): dll 是如何暴露的 ([libraryTarget](/configuration/output/#outputlibrarytarget))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `sourceType` (可选的): dll 是如何暴露的 ([libraryTarget](/configuration/output/#outputlibrarytarget))
- `sourceType`(可选):dll 是如何暴露的 ([libraryTarget](/configuration/output/#outputlibrarytarget))

Copy link
Member

@QC-L QC-L left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

问题蛮多的,修改下吧

@QC-L
Copy link
Member

QC-L commented Jul 7, 2020

读着并不顺畅

@weiyuan0609
Copy link
Author

按照建议,做了调整 @QC-L

1 similar comment
@weiyuan0609
Copy link
Author

按照建议,做了调整 @QC-L

@QC-L QC-L merged commit f48e04b into docschina:cn Jul 8, 2020
@QC-L QC-L mentioned this pull request Jul 8, 2020
73 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants