From addef1aafb55a36bfc03c3404624f7e7072f8c16 Mon Sep 17 00:00:00 2001 From: chenxsan Date: Fri, 6 Aug 2021 20:17:11 +0800 Subject: [PATCH 1/5] docs(configuration): sort options --- src/content/configuration/experiments.mdx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/content/configuration/experiments.mdx b/src/content/configuration/experiments.mdx index e9137d169e01..76e1ec7c65d2 100644 --- a/src/content/configuration/experiments.mdx +++ b/src/content/configuration/experiments.mdx @@ -32,13 +32,13 @@ Available options: module.exports = { //... experiments: { + asyncWebAssembly: true, executeModule: true, + layers: true, + lazyCompilation: true, outputModule: true, syncWebAssembly: true, topLevelAwait: true, - asyncWebAssembly: true, - layers: true, - lazyCompilation: true, }, }; ``` From 9499b7b38cd9662725b796c8bfab007ee661eca6 Mon Sep 17 00:00:00 2001 From: chenxsan Date: Fri, 6 Aug 2021 20:24:02 +0800 Subject: [PATCH 2/5] add buildHttp --- src/content/configuration/experiments.mdx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/content/configuration/experiments.mdx b/src/content/configuration/experiments.mdx index 76e1ec7c65d2..5fbbd6cca629 100644 --- a/src/content/configuration/experiments.mdx +++ b/src/content/configuration/experiments.mdx @@ -19,6 +19,7 @@ W> Because experimental features have relaxed semantic versioning and might cont Available options: - `asyncWebAssembly`: Support the new WebAssembly according to the [updated specification](https://github.com/WebAssembly/esm-integration), it makes a WebAssembly module an async module. +- [`buildHttp`](#experimentsbuildhttp) - [`executeModule`](#experimentsexecutemodule) - `layers`: Enable module and chunk layers. - [`lazyCompilation`](#experimentslazycompilation) @@ -33,6 +34,7 @@ module.exports = { //... experiments: { asyncWebAssembly: true, + buildHttp: true, executeModule: true, layers: true, lazyCompilation: true, @@ -43,6 +45,10 @@ module.exports = { }; ``` +### experiments.buildHttp + +Build remote resources from the `http(s):` protocol. + ### experiments.executeModule Enable execution of modules from the module graph for plugins and loaders at build time to generate code or other assets. From a8080a5a6ee4d33ab8fce533db3910b0b16ecb66 Mon Sep 17 00:00:00 2001 From: chenxsan Date: Sat, 7 Aug 2021 10:42:54 +0800 Subject: [PATCH 3/5] docs(configuration): document buildHttp --- src/content/configuration/experiments.mdx | 56 ++++++++++++++++++++++- 1 file changed, 54 insertions(+), 2 deletions(-) diff --git a/src/content/configuration/experiments.mdx b/src/content/configuration/experiments.mdx index 5fbbd6cca629..0009c7a69f3a 100644 --- a/src/content/configuration/experiments.mdx +++ b/src/content/configuration/experiments.mdx @@ -8,7 +8,7 @@ contributors: - anshumanv --- -## `experiments` +## experiments `boolean: false` @@ -47,7 +47,59 @@ module.exports = { ### experiments.buildHttp -Build remote resources from the `http(s):` protocol. +When eanbled, webpack can build remote resources with the `http(s):` protocol. + +- Type: one of the following: + - `boolean` + - `HttpUriOptions` + ```ts + { + cacheLocation?: false | string, + frozen?: boolean, + lockfileLocation?: string, + upgrade?: boolean + } + ``` +- Example + + ```javascript + // webpack.config.js + module.exports = { + //... + experiments: { + buildHttp: true, + }, + }; + ``` + + ```js + // src/index.js + import pMap1 from 'https://cdn.skypack.dev/p-map'; + // note that webpack will build pMap1 just like a regular local module + console.log(pMap1); + ``` + +#### experiments.buildHttp.cacheLocation + +Define where to persist remote resources. + +By default webpack would use `webpack.lock.data/`, but you can disable it by setting it to `false`. + +Note that you should commit files under `cacheLocation` into a version control system as no network requests will be made during the `production` mode. + +#### experiments.buildHttp.frozen + +Freeze the remote resources and lockfile. Any modification to the lockfile or resource contents will result in an error. + +#### experiments.buildHttp.lockfileLocation + +Define the location to store the lockfile. + +By default webpack would generate a `webpack.lock` file, you're expected to commit it into a version control system. During the `production` mode, webpack will build those modules with `http(s):` protocol from the lockfile and cached remote resources under [`experiments.buildHttp.cacheLocation`](#experimentsbuildhttpcachelocation). + +#### experiments.buildHttp.upgrade + +Detect changes to remote resources and upgrade them automatically. It's possible to opt-out this feature by setting `upgrade` to `false`. ### experiments.executeModule From 4035798eaa183c1a56a327e1e8726c385d45053f Mon Sep 17 00:00:00 2001 From: chenxsan Date: Sat, 7 Aug 2021 10:50:14 +0800 Subject: [PATCH 4/5] optimize --- src/content/configuration/experiments.mdx | 33 +++++++++++++++++++---- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/src/content/configuration/experiments.mdx b/src/content/configuration/experiments.mdx index 0009c7a69f3a..878b74d90809 100644 --- a/src/content/configuration/experiments.mdx +++ b/src/content/configuration/experiments.mdx @@ -47,7 +47,7 @@ module.exports = { ### experiments.buildHttp -When eanbled, webpack can build remote resources with the `http(s):` protocol. +When enabled, webpack can build remote resources with the `http(s):` protocol. - Type: one of the following: - `boolean` @@ -60,6 +60,7 @@ When eanbled, webpack can build remote resources with the `http(s):` protocol. upgrade?: boolean } ``` +- Available: 5.49.0+ - Example ```javascript @@ -81,25 +82,47 @@ When eanbled, webpack can build remote resources with the `http(s):` protocol. #### experiments.buildHttp.cacheLocation -Define where to persist remote resources. +Define the location to cache remote resources. + +- Type + - `string` + - `false` +- Example + ```javascript + // webpack.config.js + module.exports = { + //... + experiments: { + buildHttp: { + cacheLocation: false, + }, + }, + }; + ``` By default webpack would use `webpack.lock.data/`, but you can disable it by setting it to `false`. -Note that you should commit files under `cacheLocation` into a version control system as no network requests will be made during the `production` mode. +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` mode. #### experiments.buildHttp.frozen Freeze the remote resources and lockfile. Any modification to the lockfile or resource contents will result in an error. +- Type: `boolean` + #### experiments.buildHttp.lockfileLocation Define the location to store the lockfile. -By default webpack would generate a `webpack.lock` file, you're expected to commit it into a version control system. During the `production` mode, webpack will build those modules with `http(s):` protocol from the lockfile and cached remote resources under [`experiments.buildHttp.cacheLocation`](#experimentsbuildhttpcachelocation). +- Type: `string` + +By default webpack would generate a `webpack.lock` file, and make sure to commit it into a version control system. During the `production` mode, webpack will build those modules with `http(s):` protocol from the lockfile and cached remote resources under [`experiments.buildHttp.cacheLocation`](#experimentsbuildhttpcachelocation). #### experiments.buildHttp.upgrade -Detect changes to remote resources and upgrade them automatically. It's possible to opt-out this feature by setting `upgrade` to `false`. +Detect changes to remote resources and upgrade them automatically. + +- Type: `boolean` ### experiments.executeModule From 822f4f8d7a3ce8c799fab30b28bd7a5ea298f19a Mon Sep 17 00:00:00 2001 From: chenxsan Date: Sat, 7 Aug 2021 12:03:47 +0800 Subject: [PATCH 5/5] docs(configuration): optimize --- src/content/configuration/experiments.mdx | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/content/configuration/experiments.mdx b/src/content/configuration/experiments.mdx index 878b74d90809..0015ee2fcfed 100644 --- a/src/content/configuration/experiments.mdx +++ b/src/content/configuration/experiments.mdx @@ -47,9 +47,12 @@ module.exports = { ### experiments.buildHttp -When enabled, webpack can build remote resources with the `http(s):` protocol. +When enabled, webpack can build remote resources that begin with the `http(s):` protocol. + +- Type: + + One of the following: -- Type: one of the following: - `boolean` - `HttpUriOptions` ```ts @@ -60,6 +63,7 @@ When enabled, webpack can build remote resources with the `http(s):` protocol. upgrade?: boolean } ``` + - Available: 5.49.0+ - Example @@ -76,13 +80,13 @@ When enabled, webpack can build remote resources with the `http(s):` protocol. ```js // src/index.js import pMap1 from 'https://cdn.skypack.dev/p-map'; - // note that webpack will build pMap1 just like a regular local module + // with `buildHttp` enabled, webpack will build pMap1 just like a regular local module console.log(pMap1); ``` #### experiments.buildHttp.cacheLocation -Define the location to cache remote resources. +Define the location for caching remote resources. - Type - `string` @@ -100,9 +104,9 @@ Define the location to cache remote resources. }; ``` -By default webpack would use `webpack.lock.data/`, but you can disable it by setting it to `false`. +By default webpack would use `webpack.lock.data/` for caching, but you can disable it by setting its value to `false`. -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` mode. +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. #### experiments.buildHttp.frozen @@ -116,7 +120,7 @@ Define the location to store the lockfile. - Type: `string` -By default webpack would generate a `webpack.lock` file, and make sure to commit it into a version control system. During the `production` mode, webpack will build those modules with `http(s):` protocol from the lockfile and cached remote resources under [`experiments.buildHttp.cacheLocation`](#experimentsbuildhttpcachelocation). +By default webpack would generate a `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). #### experiments.buildHttp.upgrade