Skip to content

Commit c8374ba

Browse files
committed
Merge branch 'master' into awesome-webpack
2 parents 4372387 + beacb51 commit c8374ba

File tree

4 files changed

+214
-128
lines changed

4 files changed

+214
-128
lines changed

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"lint:markdown": "npm run lint-markdown *.md ./src/content/**/*.md",
4747
"lint-markdown": "markdownlint --config ./.markdownlint.json --ignore './src/content/**/_*.md' --ignore '.vale/**/*.md' --ignore '.github/**/*.md'",
4848
"lint:prose": "vale --config='.vale.ini' src/content",
49-
"lint:links": "hyperlink -c 8 --root dist -r dist/index.html --canonicalroot https://webpack.js.org/ --internal --skip /plugins/extract-text-webpack-plugin/ --skip /printable --skip https:// --skip http:// --skip sw.js > internal-links.tap; cat internal-links.tap | tap-spot",
49+
"lint:links": "hyperlink -c 8 --root dist -r dist/index.html --canonicalroot https://webpack.js.org/ --skip /plugins/extract-text-webpack-plugin/ --skip /printable --skip https:// --skip http:// --skip sw.js > internal-links.tap; cat internal-links.tap | tap-spot",
5050
"sitemap": "cd dist && sitemap-static --ignore-file=../sitemap-ignore.json --pretty --prefix=https://webpack.js.org/ > sitemap.xml",
5151
"serve": "npm run build && sirv start ./dist --port 4000",
5252
"preprintable": "npm run clean-printable",
@@ -103,7 +103,7 @@
103103
"husky": "^7.0.1",
104104
"hyperlink": "^4.6.1",
105105
"jest": "^27.0.6",
106-
"lint-staged": "^11.1.1",
106+
"lint-staged": "^11.1.2",
107107
"lodash": "^4.17.21",
108108
"markdownlint": "^0.23.1",
109109
"markdownlint-cli": "^0.28.1",
@@ -143,7 +143,7 @@
143143
"webpack-cli": "^4.7.2",
144144
"webpack-dev-server": "^4.0.0-rc.0",
145145
"webpack-merge": "^5.8.0",
146-
"workbox-webpack-plugin": "^6.2.0"
146+
"workbox-webpack-plugin": "^6.2.2"
147147
},
148148
"dependencies": {
149149
"@docsearch/react": "^3.0.0-alpha.39",
@@ -161,7 +161,7 @@
161161
"unist-util-visit": "^2.0.3",
162162
"webpack-pwa-manifest": "^4.3.0",
163163
"webpack.vote": "https://github.com/webpack/voting-app.git",
164-
"workbox-window": "^6.2.0"
164+
"workbox-window": "^6.2.2"
165165
},
166166
"resolutions": {
167167
"sitemap-static/minimist": "1.2.5",

src/content/configuration/experiments.mdx

Lines changed: 89 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ contributors:
88
- anshumanv
99
---
1010

11-
## `experiments`
11+
## experiments
1212

1313
`boolean: false`
1414

@@ -19,6 +19,7 @@ W> Because experimental features have relaxed semantic versioning and might cont
1919
Available options:
2020

2121
- `asyncWebAssembly`: Support the new WebAssembly according to the [updated specification](https://github.com/WebAssembly/esm-integration), it makes a WebAssembly module an async module.
22+
- [`buildHttp`](#experimentsbuildhttp)
2223
- [`executeModule`](#experimentsexecutemodule)
2324
- `layers`: Enable module and chunk layers.
2425
- [`lazyCompilation`](#experimentslazycompilation)
@@ -32,17 +33,101 @@ Available options:
3233
module.exports = {
3334
//...
3435
experiments: {
36+
asyncWebAssembly: true,
37+
buildHttp: true,
3538
executeModule: true,
39+
layers: true,
40+
lazyCompilation: true,
3641
outputModule: true,
3742
syncWebAssembly: true,
3843
topLevelAwait: true,
39-
asyncWebAssembly: true,
40-
layers: true,
41-
lazyCompilation: true,
4244
},
4345
};
4446
```
4547

48+
### experiments.buildHttp
49+
50+
When enabled, webpack can build remote resources that begin with the `http(s):` protocol.
51+
52+
- Type:
53+
54+
One of the following:
55+
56+
- `boolean`
57+
- `HttpUriOptions`
58+
```ts
59+
{
60+
cacheLocation?: false | string,
61+
frozen?: boolean,
62+
lockfileLocation?: string,
63+
upgrade?: boolean
64+
}
65+
```
66+
67+
- Available: 5.49.0+
68+
- Example
69+
70+
```javascript
71+
// webpack.config.js
72+
module.exports = {
73+
//...
74+
experiments: {
75+
buildHttp: true,
76+
},
77+
};
78+
```
79+
80+
```js
81+
// src/index.js
82+
import pMap1 from 'https://cdn.skypack.dev/p-map';
83+
// with `buildHttp` enabled, webpack will build pMap1 just like a regular local module
84+
console.log(pMap1);
85+
```
86+
87+
#### experiments.buildHttp.cacheLocation
88+
89+
Define the location for caching remote resources.
90+
91+
- Type
92+
- `string`
93+
- `false`
94+
- Example
95+
```javascript
96+
// webpack.config.js
97+
module.exports = {
98+
//...
99+
experiments: {
100+
buildHttp: {
101+
cacheLocation: false,
102+
},
103+
},
104+
};
105+
```
106+
107+
By default webpack would use `<compiler-name.>webpack.lock.data/` for caching, but you can disable it by setting its value to `false`.
108+
109+
Note that you should commit files under `experiments.buildHttp.cacheLocation` into a version control system as no network requests will be made during the `production` build.
110+
111+
#### experiments.buildHttp.frozen
112+
113+
Freeze the remote resources and lockfile. Any modification to the lockfile or resource contents will result in an error.
114+
115+
- Type: `boolean`
116+
117+
#### experiments.buildHttp.lockfileLocation
118+
119+
Define the location to store the lockfile.
120+
121+
- Type: `string`
122+
123+
By default webpack would generate a `<compiler-name.>webpack.lock` file>. Make sure to commit it into a version control system. During the `production` build, webpack will build those modules beginning with `http(s):` protocol from the lockfile and caches under [`experiments.buildHttp.cacheLocation`](#experimentsbuildhttpcachelocation).
124+
125+
#### experiments.buildHttp.upgrade
126+
127+
Detect changes to remote resources and upgrade them automatically.
128+
129+
- Type: `boolean`
130+
46131
### experiments.executeModule
47132

48133
Enable execution of modules from the module graph for plugins and loaders at build time to generate code or other assets.

src/content/configuration/index.mdx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,17 @@ contributors:
2222

2323
Out of the box, webpack won't require you to use a configuration file. However, it will assume the entry point of your project is `src/index.js` and will output the result in `dist/main.js` minified and optimized for production.
2424

25+
T> [createapp.dev](https://createapp.dev/webpack) is an online tool for creating custom webpack configuration. It allows you to select various features that will be combined and added to resulting configuration file. Also, it generates an example project based on provided webpack configuration that you can review in your browser and download.
26+
2527
Usually your projects will need to extend this functionality, for this you can create a `webpack.config.js` file in the root folder and webpack will automatically use it.
2628

2729
All the available configuration options are specified below.
2830

2931
T> New to webpack? Check out our guide to some of webpack's [core concepts](/concepts) to get started!
3032

31-
## Use different configuration file
33+
## Use a different configuration file
3234

33-
If for some reason you want to use different configuration file depending on certain situations you can change this via command line by using the `--config` flag.
35+
If for some reason you want to use different configuration file depending on certain situations, you can change this via command line by using the `--config` flag.
3436

3537
**package.json**
3638

@@ -1170,4 +1172,4 @@ found 0 vulnerabilities
11701172
Congratulations! Your new webpack configuration file has been created!
11711173
```
11721174

1173-
[createapp.dev - create a webpack configuration in your browser](https://createapp.dev/webpack) is an online tool for creating custom webpack configuration. It allows you to select various features that will be combined and added to resulting configuration file. Also, it generates an example project based on provided webpack configuration that you can review in your browser and download.
1175+

0 commit comments

Comments
 (0)