-
Notifications
You must be signed in to change notification settings - Fork 1.1k
docs(cn): translate src/content/api/hot-module-replace… #756
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
Conversation
Deploy preview for cn-webpack ready! Built with commit b7d9256 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
建议翻译完读一遍,不少地方语句翻译的有些生硬和不准确,中英文排版也需要检查一遍
@@ -15,99 +15,100 @@ related: | |||
url: /guides/hot-module-replacement | |||
--- | |||
|
|||
If [Hot Module Replacement](/concepts/hot-module-replacement) has been enabled via the [`HotModuleReplacementPlugin`](/plugins/hot-module-replacement-plugin), its interface will be exposed under the [`module.hot` property](/api/module-variables/#modulehot-webpack-specific). Typically, users will check to see if the interface is accessible, then begin working with it. As an example, here's how you might `accept` an updated module: | |||
如果已经通过 [Hot Module Replacement](/concepts/hot-module-replacement) 启用了 [`HotModuleReplacementPlugin`](/plugins/hot-module-replacement-plugin), 则它的接口将被暴露在 [`module.hot` 属性](/api/module-variables/#modulehot-webpack-specific)下面。 通常,用户先要检查这个接口是否可访问, 然后再开始使用它。举个例子,你可以这样 `accept` 一个更新的模块: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
「通过...启用...」反了;表述不用那么繁琐,比如「用户先要检查这个接口是否可访问, 然后再开始使用它」->「用户先要检查这个接口是否可访问, 再使用它」或者「用户在开始使用它之前需要先检查这个接口是否可访问」;「你可以这样 accept
一个更新的模块」->「你可以这样使用 accept
操作一个更新的模块」
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry,有的内容直接拷贝了 webpack4 ,以为是正确的。。
所有错误地方已更改,请审阅。
|
||
``` js | ||
if (module.hot) { | ||
module.hot.accept('./library.js', function() { | ||
// Do something with the updated library module... | ||
// 使用更新过的 library 模块执行某些操作... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
对更新过的 library 模块做些事情...
|
||
### `accept` | ||
|
||
Accept updates for the given `dependencies` and fire a `callback` to react to those updates. | ||
接受(accept)给定`依赖模块(dependencies)`的更新,并触发一个 `回调函数` 来对这些更新做出响应。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
中英文间隔
|
||
### `accept` | ||
|
||
Accept updates for the given `dependencies` and fire a `callback` to react to those updates. | ||
接受(accept)给定`依赖模块(dependencies)`的更新,并触发一个 `回调函数` 来对这些更新做出响应。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
「来响应更新」
); | ||
``` | ||
|
||
When using ESM `import` all imported symbols from `dependencies` are automatically updated. Note: The dependency string must match exactly with the `from` string in the `import`. In some cases `callback` can even be omitted. Using `require()` in the `callback` doesn't make sense here. | ||
当使用 ESM `import` 时,所有引用`依赖模块(dependencies)`的导入符号都会被自动更新。注意:依赖模块字符串必须和 `import` 中的 `from` 字符串相匹配。在一些情况中 `callback` 可以省略。在 `callback` 中使用的 `require()` 在这里没有任何意义。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
语言重新组织下吧,这块有点不通顺;文中没有模块一词,翻译中加了这个?
|
||
``` js | ||
module.hot.removeDisposeHandler(callback); | ||
``` | ||
|
||
## Management API | ||
## 管理 API |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
API 管理
|
||
W> Do not get caught in an `invalidate` loop, by calling `invalidate` again and again. This will result in stack overflow and HMR entering the `fail` state. | ||
W> 不要陷入 `invalidate` 循环,一次次的调用 `invalidate`, 将导致栈溢出并且 HMR 进入 `fail` 状态。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
「不要陷入 invalidate
循环,一次次的调用 invalidate
」语序反一下
); | ||
``` | ||
|
||
When this module or dependencies are updated, this module can be disposed and re-evaluated without informing parents. This makes sense if this module has no exports (or exports are updated in another way). | ||
在此模块或依赖模块更新时,在不通知父母的情况下,可以对此模块处理和重新取值。 如果此模块没有导出(或以其他方式更新的导出),这是有意义的。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
父母?
|
||
The `errorHandler` is fired when the evaluation of this module (or dependencies) has thrown an exception. | ||
当对此模块(或依赖模块)进行取值而引发异常时,会触发 `errorHandler`。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
取值 -> 执行
|
||
The `errorHandler` is fired when the evaluation of this module (or dependencies) has thrown an exception. | ||
当对此模块(或依赖模块)进行取值而引发异常时,会触发 `errorHandler`。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
当执行此模块(或依赖)抛出异常时,会...
|
||
When using CommonJS you need to update dependencies manually by using `require()` in the `callback`. Omitting the `callback` doesn't make sense here. | ||
在使用 CommonJS 时,你应该通过 `callback` 中的 `require()` 手动更新依赖模块。这时省略 `callback` 在这里没有任何意义。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在使用 CommonJS 时,你应该通过 `callback` 中的 `require()` 手动更新依赖模块。这时省略 `callback` 在这里没有任何意义。 | |
在使用 CommonJS 时,你应该通过 `callback` 中的 `require()` 手动更新依赖模块。省略 `callback` 在这里没有任何意义。 |
@Geekhyt 没改完全... |
已检查并更改过,请审阅。 |
}); | ||
``` | ||
|
||
The optional `options` object can include the following properties: | ||
可选的 `options` 对象可以包含以下属性: | ||
|
||
- `ignoreUnaccepted` (boolean): Ignore changes made to unaccepted modules. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
每个选项后面的说明没翻译~
@@ -232,7 +233,7 @@ The optional `options` object can include the following properties: | |||
- `onDisposed` (function(info)): Notifier for disposed modules | |||
- `onErrored` (function(info)): Notifier for errors | |||
|
|||
The `info` parameter will be an object containing some of the following values: | |||
`info` 参数将是一个包含以下某些值的对象: | |||
|
|||
<!-- eslint-skip --> | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
下面的注释没翻译
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
把剩余的改掉,就可以合并了~辛苦
已更新,请审阅。 |
这么晚还不睡.... |
加班。。。 |
。。。辛苦了 |
@QC-L