Skip to content

Commit 1220d79

Browse files
authored
Merge pull request #1656 from docschina/sync-73993d98
docs(en): merge webpack.js.org/master into webpack.js.org/cn @ 73993d9
2 parents be42a96 + 9598776 commit 1220d79

File tree

13 files changed

+1489
-1617
lines changed

13 files changed

+1489
-1617
lines changed

.github/workflows/deploy.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,8 @@ jobs:
4141
- run: yarn lint:links
4242

4343
- name: Deploy
44-
uses: JamesIves/github-pages-deploy-action@v4.2.5
44+
uses: JamesIves/github-pages-deploy-action@v4.4.0
4545
with:
4646
token: ${{ secrets.GITHUB_TOKEN }}
47-
branch: gh-pages
4847
folder: dist
4948
clean: true

package.json

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@
5959
"cypress:open": "cypress open",
6060
"cypress:run": "cypress run",
6161
"prettier": "prettier --write '**/*.{js,json,jsx,css,scss,md,mdx}'",
62-
"prepare": "husky install",
63-
"postinstall": "rimraf ./node_modules/.cache/webpack"
62+
"prepare": "husky install && rimraf ./node_modules/.cache/webpack && yarn-deduplicate --strategy fewer"
6463
},
6564
"lint-staged": {
6665
"*.{js,jsx,md,mdx}": [
@@ -74,31 +73,31 @@
7473
]
7574
},
7675
"devDependencies": {
77-
"@babel/core": "^7.18.9",
76+
"@babel/core": "^7.18.13",
7877
"@babel/eslint-parser": "^7.18.9",
7978
"@babel/plugin-proposal-class-properties": "^7.17.12",
80-
"@babel/preset-env": "^7.18.9",
79+
"@babel/preset-env": "^7.18.10",
8180
"@babel/preset-react": "^7.18.6",
8281
"@mdx-js/loader": "^2.0.0-next.9",
83-
"@octokit/auth-action": "^2.0.0",
84-
"@octokit/rest": "^19.0.3",
85-
"@parcel/css": "^1.12.0",
82+
"@octokit/auth-action": "^2.0.1",
83+
"@octokit/rest": "^19.0.4",
84+
"@parcel/css": "^1.13.0",
8685
"@pmmmwh/react-refresh-webpack-plugin": "next",
8786
"@svgr/webpack": "^6.3.1",
88-
"autoprefixer": "^10.4.7",
87+
"autoprefixer": "^10.4.8",
8988
"babel-loader": "^8.2.5",
9089
"copy-webpack-plugin": "^11.0.0",
9190
"css-loader": "^6.7.1",
9291
"css-minimizer-webpack-plugin": "^4.0.0",
93-
"cypress": "^10.3.1",
92+
"cypress": "^10.6.0",
9493
"directory-tree": "^3.3.0",
9594
"directory-tree-webpack-plugin": "^1.0.3",
9695
"duplexer": "^0.1.1",
97-
"eslint": "^8.20.0",
96+
"eslint": "^8.23.0",
9897
"eslint-config-prettier": "^8.5.0",
9998
"eslint-plugin-cypress": "^2.12.1",
100-
"eslint-plugin-mdx": "^2.0.1",
101-
"eslint-plugin-react": "^7.30.1",
99+
"eslint-plugin-mdx": "^2.0.2",
100+
"eslint-plugin-react": "^7.31.1",
102101
"eslint-plugin-react-hooks": "^4.6.0",
103102
"front-matter": "^4.0.2",
104103
"github-slugger": "^1.4.0",
@@ -107,18 +106,18 @@
107106
"http-server": "^14.1.1",
108107
"husky": "^8.0.1",
109108
"hyperlink": "^5.0.4",
110-
"jest": "^28.1.3",
109+
"jest": "^29.0.1",
111110
"lint-staged": "^13.0.3",
112111
"lodash": "^4.17.21",
113-
"markdownlint": "^0.26.0",
114-
"markdownlint-cli": "^0.32.0",
112+
"markdownlint": "^0.26.2",
113+
"markdownlint-cli": "^0.32.2",
115114
"mdast-util-to-string": "^3.1.0",
116115
"mini-css-extract-plugin": "^2.6.1",
117116
"mkdirp": "^1.0.4",
118117
"modularscale-sass": "^3.0.3",
119-
"node-fetch": "^3.2.9",
118+
"node-fetch": "^3.2.10",
120119
"npm-run-all": "^4.1.1",
121-
"postcss": "^8.4.14",
120+
"postcss": "^8.4.16",
122121
"postcss-loader": "^7.0.1",
123122
"prettier": "^2.7.1",
124123
"react-refresh": "^0.14.0",
@@ -132,23 +131,24 @@
132131
"remark-html": "^15.0.1",
133132
"remark-refractor": "montogeek/remark-refractor",
134133
"rimraf": "^3.0.2",
135-
"sass": "^1.53.0",
134+
"sass": "^1.54.5",
136135
"sass-loader": "^13.0.2",
137136
"sirv-cli": "^2.0.2",
138137
"sitemap-static": "^0.4.2",
139138
"static-site-generator-webpack-plugin": "^3.4.1",
140139
"style-loader": "^3.3.1",
141-
"tailwindcss": "^3.1.6",
140+
"tailwindcss": "^3.1.8",
142141
"tap-spot": "^1.1.2",
143142
"textlint": "^11.8.2",
144143
"textlint-rule-heading": "^1.0.10",
145-
"unist-util-visit": "^4.1.0",
146-
"webpack": "^5.73.0",
147-
"webpack-bundle-analyzer": "^4.5.0",
144+
"unist-util-visit": "^4.1.1",
145+
"webpack": "^5.74.0",
146+
"webpack-bundle-analyzer": "^4.6.1",
148147
"webpack-cli": "^4.10.0",
149-
"webpack-dev-server": "^4.9.3",
148+
"webpack-dev-server": "^4.10.1",
150149
"webpack-merge": "^5.8.0",
151-
"workbox-webpack-plugin": "^6.5.3"
150+
"workbox-webpack-plugin": "^6.5.4",
151+
"yarn-deduplicate": "^6.0.0"
152152
},
153153
"dependencies": {
154154
"@docsearch/react": "^3.0.0-alpha.50",
@@ -158,13 +158,13 @@
158158
"react-dom": "^17.0.2",
159159
"react-helmet-async": "^1.3.0",
160160
"react-router-dom": "^6.3.0",
161-
"react-spring": "^9.5.1",
161+
"react-spring": "^9.5.2",
162162
"react-tiny-popover": "5",
163163
"react-use": "^17.4.0",
164164
"react-visibility-sensor": "^5.0.2",
165165
"webpack-pwa-manifest": "^4.3.0",
166166
"webpack.vote": "https://github.com/webpack/voting-app.git",
167-
"workbox-window": "^6.5.3"
167+
"workbox-window": "^6.5.4"
168168
},
169169
"resolutions": {
170170
"sitemap-static/minimist": "1.2.5",

src/components/Configuration/Configuration.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
overflow: visible;
33
border-radius: 4px;
44
box-shadow: -1px 1px 10px 0 rgba(255, 255, 255, 0.44);
5+
6+
pre.inline {
7+
padding: 0;
8+
display: block;
9+
}
510
}
611

712
.shadow > .markdown {

src/content/api/loaders.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ console.log('yep');
719719
**extract-style-loader/index.js**
720720
721721
```javascript
722-
const getStylesLoader = require.resolve('./getStyle');
722+
const getStylesLoader = require.resolve('./getStyles');
723723

724724
module.exports = function (source) {
725725
if (STYLES_REGEXP.test(source)) {
@@ -736,7 +736,7 @@ module.exports = function (source) {
736736
737737
```javascript
738738
module.exports = function (source) {
739-
const match = STYLES_REGEXP.match(source);
739+
const match = source.match(STYLES_REGEXP);
740740
return match[0];
741741
};
742742
```

src/content/api/plugins.mdx

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ contributors:
99
- byzyk
1010
- EugeneHlushko
1111
- wizardofhogwarts
12+
- snitin315
1213
translators:
1314
- chenzesam
1415
- QC-L
@@ -90,18 +91,52 @@ compiler.hooks.run.tapPromise(
9091

9192
## 自定义钩子 $#custom-hooks$
9293

93-
为了便于其他插件的编译过程中可以 `tap` 到,则需要创建一个新的 hook,
94-
我们只需要简单的从 `tapable``require` 所需的 hook 类,并创建
94+
为了便于其他插件的编译过程中可以 `tap` 到,
95+
你可以这样做
9596

96-
```js
97-
const SyncHook = require('tapable').SyncHook;
97+
1. Create a module-scope `WeakMap` for compilation hooks:
9898

99-
if (compiler.hooks.myCustomHook) throw new Error('已存在该钩子');
100-
compiler.hooks.myCustomHook = new SyncHook(['a', 'b', 'c']);
99+
```ts
100+
const compilationHooks = new WeakMap<Compilation, MyHooks>();
101101

102-
// 在你想要触发钩子的位置/时机下调用……
103-
compiler.hooks.myCustomHook.call(a, b, c);
104-
```
102+
interface MyHooks {
103+
custom: SyncHook<[number, string]>;
104+
}
105+
```
106+
107+
2. 在插件中创建一个静态方法:
108+
109+
```ts
110+
static getCompilationHooks(compilation: Compilation) : MyHooks {
111+
let hooks = compilationHooks.get(compilation);
112+
if(hooks === undefined) {
113+
compilationHooks.set(compilation, hooks = {
114+
custom: new SyncHook()
115+
});
116+
}
117+
return hooks;
118+
}
119+
```
120+
121+
3. 像下面这样在你的插件中调用钩子函数:
122+
123+
```ts
124+
const hooks = MyPlugin.getCompilationHooks(compilation);
125+
126+
hooks.custom.call(1, 'hello');
127+
```
128+
129+
4. 其他插件也可以访问你的自定义钩子函数:
130+
131+
```ts
132+
import MyPlugin from 'my-plugin';
133+
134+
const hooks = MyPlugin.getCompilationHooks(compilation);
135+
136+
hooks.custom.tap('OtherPlugin', (n, s) => {
137+
// magic
138+
});
139+
```
105140

106141
再次声明,
107142
查看 `tapable` [文档](https://github.com/webpack/tapable) 来了解更多不同的钩子类(hook class),以及它们是如何工作的。

src/content/blog/2020-10-10-webpack-5-release.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ export function test() {
365365

366366
当设置`"sideEffects": false`时,可以省略更多的模块。在这个例子中,当 `test` 导出未被使用时,`./something` 将被省略。
367367

368-
要获得未使用的导出信息,需要使用 `optimization.unusedExports`。要删除无副作用的模块,需要使用`optimization.sideEffects`
368+
要获得未使用的导出信息,需要使用 `optimization.usedExports`。要删除无副作用的模块,需要使用`optimization.sideEffects`
369369

370370
可以分析以下标记。
371371

src/content/configuration/dev-server.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ W> 请注意,当[导出多个配置对象](/configuration/configuration-types/
7575

7676
T> 如果你碰到了问题,请将路由导航至 `/webpack-dev-server` 将会为你展示服务文件的位置。例如: `http://localhost:9000/webpack-dev-server`
7777

78-
T> 如果你需要要手动重新编译 `bundle`,将路由导航至 `/invalidate` 使当前编译的 `bundle` [无效](/api/node/#invalidate-watching),并通过 [webpack-dev-middleware](https://github.com/webpack/webpack-dev-middleware#invalidate) 为你重新编译。根据你的配置,URL 可能看起来像 `http://localhost:9000/invalidate`
78+
T> 如果你需要要手动重新编译 `bundle`,将路由导航至 `/webpack-dev-server/invalidate` 使当前编译的 `bundle` [无效](/api/node/#invalidate-watching),并通过 [webpack-dev-middleware](https://github.com/webpack/webpack-dev-middleware#invalidate) 为你重新编译。根据你的配置,URL 可能看起来像 `http://localhost:9000/webpack-dev-server/invalidate`
7979

8080
T> 当启动本地服务的时候 HTML 模板是必须提供的,通常是 `index.html`。确保将脚本引用添加到 HTML 中,webpack-dev-server 不会自动注入它们。
8181

@@ -1584,7 +1584,7 @@ module.exports = {
15841584
// 如果你想在所有其他中间件之前运行一个中间件或者当你从 `onBeforeSetupMiddleware` 配置项迁移时,
15851585
// 可以使用 `unshift` 方法
15861586
middlewares.unshift({
1587-
name: 'fist-in-array',
1587+
name: 'first-in-array',
15881588
// `path` 是可选的
15891589
path: '/foo/path',
15901590
middleware: (req, res) => {

0 commit comments

Comments
 (0)