Skip to content

Commit 6e5e15e

Browse files
committed
Merge remote-tracking branch 'upstream/main' into responsiveSponsorAd
2 parents 9e1a1ca + 82f5652 commit 6e5e15e

39 files changed

+3004
-2595
lines changed

.github/CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ See the `package.json` for the full list of `scripts`.
3030

3131
> **Note**
3232
>
33-
> **Node v14.20** or above is required for the build process to run properly.
33+
> **Node v18.12.0** or above is required for the build process to run properly.
3434
3535
## Contributor License Agreement
3636

.github/workflows/testing.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757
- uses: actions/checkout@v4
5858

5959
- name: Vale
60-
uses: errata-ai/vale-action@v2.0.1
60+
uses: errata-ai/vale-action@v2.1.0
6161
with:
6262
files: src/content
6363
env:

package.json

+25-25
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"url": "https://github.com/webpack/webpack.js.org/issues"
2222
},
2323
"engines": {
24-
"node": "^14.20.0 || ^16.15.0 || >=18.0.0"
24+
"node": ">= 18.12.0"
2525
},
2626
"scripts": {
2727
"clean-dist": "rimraf ./dist",
@@ -70,50 +70,50 @@
7070
]
7171
},
7272
"devDependencies": {
73-
"@babel/core": "^7.23.7",
74-
"@babel/eslint-parser": "^7.23.3",
73+
"@babel/core": "^7.24.3",
74+
"@babel/eslint-parser": "^7.24.1",
7575
"@babel/plugin-proposal-class-properties": "^7.17.12",
76-
"@babel/preset-env": "^7.23.8",
77-
"@babel/preset-react": "^7.23.3",
76+
"@babel/preset-env": "^7.24.3",
77+
"@babel/preset-react": "^7.24.1",
7878
"@mdx-js/loader": "^2.0.0-next.9",
79-
"@octokit/auth-action": "^4.0.1",
79+
"@octokit/auth-action": "^5.0.0",
8080
"@octokit/rest": "^20.0.2",
8181
"@pmmmwh/react-refresh-webpack-plugin": "next",
8282
"@svgr/webpack": "^8.1.0",
83-
"autoprefixer": "^10.4.16",
83+
"autoprefixer": "^10.4.19",
8484
"babel-loader": "^9.1.3",
85-
"copy-webpack-plugin": "^11.0.0",
86-
"css-loader": "^6.8.1",
87-
"css-minimizer-webpack-plugin": "^5.0.1",
85+
"copy-webpack-plugin": "^12.0.2",
86+
"css-loader": "^6.10.0",
87+
"css-minimizer-webpack-plugin": "^6.0.0",
8888
"cypress": "^13.6.2",
8989
"directory-tree": "^3.5.1",
9090
"directory-tree-webpack-plugin": "^1.0.3",
9191
"duplexer": "^0.1.1",
92-
"eslint": "^8.56.0",
92+
"eslint": "^8.57.0",
9393
"eslint-config-prettier": "^9.1.0",
9494
"eslint-plugin-cypress": "^2.15.1",
95-
"eslint-plugin-mdx": "^3.0.0",
96-
"eslint-plugin-react": "^7.33.2",
95+
"eslint-plugin-mdx": "^3.1.5",
96+
"eslint-plugin-react": "^7.34.1",
9797
"eslint-plugin-react-hooks": "^4.6.0",
9898
"front-matter": "^4.0.2",
9999
"github-slugger": "^2.0.0",
100100
"html-webpack-plugin": "^5.5.4",
101101
"http-server": "^14.1.1",
102-
"husky": "^8.0.3",
102+
"husky": "^9.0.11",
103103
"hyperlink": "^5.0.4",
104104
"jest": "^29.7.0",
105-
"lightningcss": "^1.22.1",
106-
"lint-staged": "^14.0.1",
105+
"lightningcss": "^1.24.1",
106+
"lint-staged": "^15.2.2",
107107
"lodash": "^4.17.21",
108108
"markdownlint-cli": "^0.38.0",
109109
"mdast-util-to-string": "^4.0.0",
110-
"mini-css-extract-plugin": "^2.7.6",
110+
"mini-css-extract-plugin": "^2.8.1",
111111
"mkdirp": "^3.0.1",
112112
"modularscale-sass": "^3.0.3",
113113
"npm-run-all": "^4.1.1",
114-
"postcss": "^8.4.33",
115-
"postcss-loader": "^7.3.3",
116-
"prettier": "^3.1.1",
114+
"postcss": "^8.4.38",
115+
"postcss-loader": "^8.1.1",
116+
"prettier": "^3.2.5",
117117
"react-refresh": "^0.14.0",
118118
"redirect-webpack-plugin": "^1.0.0",
119119
"remark": "^14.0.3",
@@ -125,19 +125,19 @@
125125
"remark-html": "^15.0.2",
126126
"remark-refractor": "montogeek/remark-refractor",
127127
"rimraf": "^5.0.1",
128-
"sass": "^1.69.7",
129-
"sass-loader": "^13.3.2",
128+
"sass": "^1.71.1",
129+
"sass-loader": "^14.1.1",
130130
"sirv-cli": "^2.0.2",
131131
"sitemap-static": "^0.4.2",
132132
"static-site-generator-webpack-plugin": "^3.4.1",
133-
"style-loader": "^3.3.3",
133+
"style-loader": "^3.3.4",
134134
"tailwindcss": "^3.3.6",
135135
"tap-spot": "^1.1.2",
136136
"unist-util-visit": "^5.0.0",
137-
"webpack": "^5.89.0",
137+
"webpack": "^5.91.0",
138138
"webpack-bundle-analyzer": "^4.10.1",
139139
"webpack-cli": "^5.1.4",
140-
"webpack-dev-server": "^4.15.1",
140+
"webpack-dev-server": "^5.0.4",
141141
"webpack-merge": "^5.10.0",
142142
"workbox-webpack-plugin": "^7.0.0",
143143
"yarn-deduplicate": "^6.0.2"

src/content/api/compilation-hooks.mdx

+97
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ contributors:
1111
- EugeneHlushko
1212
- chenxsan
1313
- jamesgeorge007
14+
- snitin315
1415
---
1516

1617
The `Compilation` module is used by the `Compiler` to create new compilations
@@ -30,6 +31,8 @@ compilation.hooks.someHook.tap(/* ... */);
3031
As with the `compiler`, `tapAsync` and `tapPromise` may also be available
3132
depending on the type of hook.
3233

34+
W> Since webpack 5, `hooks` are no longer extendable. Use a `WeakMap` to add custom hooks.
35+
3336
### buildModule
3437

3538
`SyncHook`
@@ -647,3 +650,97 @@ Executed after setting up a child compiler.
647650
### normalModuleLoader
648651

649652
Since webpack v5 `normalModuleLoader` hook was removed. Now to access the loader use `NormalModule.getCompilationHooks(compilation).loader` instead.
653+
654+
### statsPreset
655+
656+
`HookMap`
657+
658+
This HookMap is like a list of actions that gets triggered when a preset is used. It takes in an options object. When a plugin manages a preset, it should change settings in this object carefully without replacing existing ones.
659+
660+
- Callback Parameters: `options` `context`
661+
662+
Here's an illustrative plugin example:
663+
664+
```js
665+
compilation.hooks.statsPreset.for('my-preset').tap('MyPlugin', (options) => {
666+
if (options.all === undefined) options.all = true;
667+
});
668+
```
669+
670+
This plugin ensures that for the preset `'my-preset'`, if the `all` option is undefined, it defaults to true.
671+
672+
### statsNormalize
673+
674+
`SyncHook`
675+
676+
This hook is used to transform an options object into a consistent format that can be easily used by subsequent hooks. It also ensures that missing options are set to their default values.
677+
678+
- Callback Parameters: `options` `context`
679+
680+
Here's an illustrative plugin example:
681+
682+
```js
683+
compilation.hooks.statsNormalize.tap('MyPlugin', (options) => {
684+
if (options.myOption === undefined) options.myOption = [];
685+
686+
if (!Array.isArray(options.myOption)) options.myOptions = [options.myOptions];
687+
});
688+
```
689+
690+
In this plugin, if the `myOption` is missing, it sets it to an empty array. Additionally, it ensures that `myOption` is always an array even if it was originally defined as a single value.
691+
692+
### statsFactory
693+
694+
This hook provides access to the [`StatsFactory` class](https://github.com/webpack/webpack/blob/main/lib/stats/StatsFactory.js) for specific options.
695+
696+
- Callback Parameters: `statsFactory` `options`
697+
698+
#### StatsFactory.hooks.extract
699+
700+
`HookMap`
701+
702+
- Callback Parameters: `object` `data` `context`
703+
704+
`data` contains the class. object is an object to which properties should be added. `context` provides contextual information, such as classes on the path.
705+
706+
Example:
707+
708+
```js
709+
compilation.hooks.statsFactory.tap('MyPlugin', (statsFactory, options) => {
710+
statsFactory.hooks.extract
711+
.for('compilation')
712+
.tap('MyPlugin', (object, compilation) => {
713+
object.customProperty = MyPlugin.getCustomValue(compilation);
714+
});
715+
});
716+
```
717+
718+
#### StatsFactory.hooks.result
719+
720+
`HookMap`
721+
722+
Called with the result on each level.
723+
724+
- Callback Parameters: `result` `context`
725+
726+
### statsPrinter
727+
728+
This hook provides access to the [`StatsPrinter` class](https://github.com/webpack/webpack/blob/main/lib/stats/StatsPrinter.js) for specific options.
729+
730+
- Callback Parameters: `statsPrinter` `options`
731+
732+
#### StatsPrinter.hooks.print
733+
734+
`HookMap`
735+
736+
This hook is called when a part should be printed.
737+
738+
- Callback Parameters: `object` `context`
739+
740+
#### StatsPrinter.hooks.result
741+
742+
`HookMap`
743+
744+
This hook is called for the resulting string for a part.
745+
746+
- Callback Parameters: `result` `context`

src/content/api/compiler-hooks.mdx

+6-3
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,17 @@ contributors:
1010
- EugeneHlushko
1111
- superburrito
1212
- chenxsan
13+
- snitin315
1314
---
1415

1516
The `Compiler` module is the main engine that creates a compilation instance
1617
with all the options passed through the [CLI](/api/cli) or [Node API](/api/node). It extends the
1718
`Tapable` class in order to register and call plugins. Most user-facing plugins
1819
are first registered on the `Compiler`.
1920

20-
When developing a plugin for webpack, you might want to know where each hook is called. To learn this, search for `hooks.<hook name>.call` across the webpack source
21+
When developing a plugin for webpack, you might want to know where each hook is called. To learn this, search for `hooks.<hook name>.call` across the webpack source.
22+
23+
W> Since webpack 5, `hooks` are no longer extendable. Use a `WeakMap` to add custom hooks.
2124

2225
## Watching
2326

@@ -294,14 +297,14 @@ Called when the compiler is closing.
294297

295298
`SyncBailHook`
296299

297-
Allows to use infrastructure logging when enabled in the configuration via [`infrastructureLogging` option](/configuration/other-options/#infrastructurelogging).
300+
Allows to use infrastructure logging when enabled in the configuration via [`infrastructureLogging` option](/configuration/infrastructureLogging/).
298301

299302
- Callback Parameters: `name`, `type`, `args`
300303

301304
### log
302305

303306
`SyncBailHook`
304307

305-
Allows to log into [stats](/configuration/stats/) when enabled, see [`stats.logging`, `stats.loggingDebug` and `stats.loggingTrace` options](/configuration/stats/#stats-options).
308+
Allows to log into [stats](/configuration/stats/) when enabled, see [`stats.logging`, `stats.loggingDebug` and `stats.loggingTrace` options](/configuration/infrastructureLogging/).
306309

307310
- Callback Parameters: `origin`, `logEntry`

src/content/api/loaders.mdx

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ module.exports = function (content, map, meta) {
5050
};
5151
```
5252

53-
The `this.callback` method is more flexible as it allows multiple arguments to be passed as opposed to only the `content`.
53+
The `this.callback` method is more flexible as you pass multiple arguments instead of using `content` only.
5454

5555
**sync-loader-with-multiple-results.js**
5656

@@ -776,8 +776,8 @@ module.exports = function (source) {
776776
777777
## Logging
778778
779-
Logging API is available since the release of webpack 4.37. When `logging` is enabled in [`stats configuration`](/configuration/stats/#statslogging) and/or when [`infrastructure logging`](/configuration/other-options/#infrastructurelogging) is enabled, loaders may log messages which will be printed out in the respective logger format (stats, infrastructure).
779+
Logging API is available since the release of webpack 4.37. When `logging` is enabled in [`stats configuration`](/configuration/stats/#statslogging) and/or when [`infrastructure logging`](/configuration/infrastructureLogging) is enabled, loaders may log messages which will be printed out in the respective logger format (stats, infrastructure).
780780
781781
- Loaders should prefer to use `this.getLogger()` for logging which is a shortcut to `compilation.getLogger()` with loader path and processed file. This kind of logging is stored to the Stats and formatted accordingly. It can be filtered and exported by the webpack user.
782782
- Loaders may use `this.getLogger('name')` to get an independent logger with a child name. Loader path and processed file is still added.
783-
- Loaders may use special fallback logic for detecting logging support `this.getLogger ? this.getLogger() : console` to provide a fallback when an older webpack version is used which does not support `getLogger` method.
783+
- Loaders may use specific fallback logic for detecting logging support `this.getLogger ? this.getLogger() : console` to provide a fallback when an older webpack version is used which does not support `getLogger` method.

src/content/api/module-methods.mdx

+3-3
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ W> This feature relies on [`Promise`](https://developer.mozilla.org/en-US/docs/W
9696

9797
It is not possible to use a fully dynamic import statement, such as `import(foo)`. Because `foo` could potentially be any path to any file in your system or project.
9898

99-
The `import()` must contain at least some information about where the module is located. Bundling can be limited to a specific directory or set of files so that when you are using a dynamic expression - every module that could potentially be requested on an `import()` call is included. For example, `` import(`./locale/${language}.json`) `` will cause every `.json` file in the `./locale` directory to be bundled into the new chunk. At run time, when the variable `language` has been computed, any file like `english.json` or `german.json` will be available for consumption.
99+
The `import()` must contain at least some information about where the module is located. Bundling can be limited to a specific directory or set of files so that when you are using a dynamic expression - every module that could potentially be requested on an `import()` call is included. For example, ``import(`./locale/${language}.json`)`` will cause every `.json` file in the `./locale` directory to be bundled into the new chunk. At run time, when the variable `language` has been computed, any file like `english.json` or `german.json` will be available for consumption.
100100

101101
```javascript
102102
// imagine we had a method to get language from cookies or other storage
@@ -166,7 +166,7 @@ import(
166166
Since webpack 2.6.0, different modes for resolving dynamic imports can be specified. The following options are supported:
167167

168168
- `'lazy'` (default): Generates a lazy-loadable chunk for each `import()`ed module.
169-
- `'lazy-once'`: Generates a single lazy-loadable chunk that can satisfy all calls to `import()`. The chunk will be fetched on the first call to `import()`, and subsequent calls to `import()` will use the same network response. Note that this only makes sense in the case of a partially dynamic statement, e.g. `` import(`./locales/${language}.json`) ``, where multiple module paths that can potentially be requested.
169+
- `'lazy-once'`: Generates a single lazy-loadable chunk that can satisfy all calls to `import()`. The chunk will be fetched on the first call to `import()`, and subsequent calls to `import()` will use the same network response. Note that this only makes sense in the case of a partially dynamic statement, e.g. ``import(`./locales/${language}.json`)``, where multiple module paths that can potentially be requested.
170170
- `'eager'`: Generates no extra chunk. All modules are included in the current chunk and no additional network requests are made. A `Promise` is still returned but is already resolved. In contrast to a static import, the module isn't executed until the call to `import()` is made.
171171
- `'weak'`: Tries to load the module if the module function has already been loaded in some other way (e.g. another chunk imported it or a script containing the module was loaded). A `Promise` is still returned, but only successfully resolves if the chunks are already on the client. If the module is not available, the `Promise` is rejected. A network request will never be performed. This is useful for universal rendering when required chunks are always manually served in initial requests (embedded within the page), but not in cases where app navigation will trigger an import not initially served.
172172

@@ -398,7 +398,7 @@ require.context(
398398
);
399399
```
400400

401-
Specify a whole group of dependencies using a path to the `directory`, an option to `includeSubdirs`, a `filter` for more fine grained control of the modules included, and a `mode` to define the way how loading will work. Underlying modules can then be easily resolved later on:
401+
Specify a whole group of dependencies using a path to the `directory`, an option to `includeSubdirs`, a `filter` for more fine grained control of the modules included, and a `mode` to define the way how loading will work. Underlying modules can then be resolved later on:
402402

403403
```javascript
404404
var context = require.context('components', true, /\.html$/);

src/content/api/parser.mdx

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ contributors:
88
- misterdev
99
- EugeneHlushko
1010
- chenxsan
11+
- snitin315
1112
---
1213

1314
The `parser` instance, found in the `compiler`, is used to parse each module
@@ -36,6 +37,8 @@ depending on the type of hook.
3637
The following lifecycle hooks are exposed by the `parser` and can be accessed
3738
as such:
3839

40+
W> Since webpack 5, `hooks` are no longer extendable. Use a `WeakMap` to add custom hooks.
41+
3942
### evaluateTypeof
4043

4144
`SyncBailHook`

0 commit comments

Comments
 (0)