Skip to content

Commit 9d102a3

Browse files
perf: migrate on new API, big perf improvement, you need to have at least webpack 5.52.0 (recommended latest stable)
1 parent 26feefe commit 9d102a3

File tree

28 files changed

+2382
-5911
lines changed

28 files changed

+2382
-5911
lines changed

.github/workflows/nodejs.yml

+3-5
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,14 @@ jobs:
9090

9191
- name: Run tests for webpack version ${{ matrix.webpack-version }}
9292
run: npm run test:coverage -- --ci
93-
env:
94-
EXPERIMENTAL_USE_IMPORT_MODULE: "false"
9593

9694
- name: Submit coverage data to codecov
9795
uses: codecov/codecov-action@v1
9896
with:
9997
token: ${{ secrets.CODECOV_TOKEN }}
10098

101-
test-new-api:
102-
name: Test - ${{ matrix.os }} - Node v${{ matrix.node-version }}, Webpack latest, experimentalUseImportModule
99+
test-old-api:
100+
name: Test - ${{ matrix.os }} - Node v${{ matrix.node-version }}, Webpack latest, old API
103101

104102
strategy:
105103
matrix:
@@ -138,7 +136,7 @@ jobs:
138136
- name: Run tests for webpack version latest with experimentalUseImportModule
139137
run: npm run test:coverage -- --ci
140138
env:
141-
EXPERIMENTAL_USE_IMPORT_MODULE: "true"
139+
OLD_API: "true"
142140

143141
- name: Submit coverage data to codecov
144142
uses: codecov/codecov-action@v2

README.md

+11-5
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ module.exports = {
8888
| **[`attributes`](#attributes)** | `{Object}` | `{}` | Adds custom attributes to the `link` tag for [non-initial (async)](https://webpack.js.org/concepts/under-the-hood/#chunks) CSS chunks |
8989
| **[`linkType`](#linkType)** | `{String\|Boolean}` | `text/css` | Allows loading asynchronous chunks with a custom link type |
9090
| **[`runtime`](#runtime)** | `{Boolean}` | `true` | Allows to enable/disable the runtime generation |
91-
| **[`experimentalUseImportModule`](#experimentalUseImportModule)** | `{Boolean}` | `false` | Use an experimental webpack API to execute modules instead of child compilers |
91+
| **[`experimentalUseImportModule`](#experimentalUseImportModule)** | `{Boolean}` | `undefined` | Use an experimental webpack API to execute modules instead of child compilers |
9292

9393
#### `filename`
9494

@@ -301,13 +301,16 @@ module.exports = {
301301

302302
#### `experimentalUseImportModule`
303303

304-
Use an experimental webpack API to execute modules instead of child compilers.
304+
Type: `Boolean`
305+
Default: `undefined`
305306

306-
This improves performance and memory usage a lot, but isn't as stable as the normal approach.
307+
Enabled by default if not explicitly enabled (i.e. `true` and `false` allow you to explicitly control this option) and new API is available (at least webpack `5.52.0` is required).
308+
Boolean values are available since version `5.33.2`, but you need to enable `experiments.executeModule` (not required from webpack `5.52.0`).
307309

308-
When combined with `experiments.layers`, this adds a `layer` option to the loader options to specify the layer of the css execution.
310+
Use a new webpack API to execute modules instead of child compilers.
311+
This improves performance and memory usage a lot.
309312

310-
You need to have at least webpack 5.33.2.
313+
When combined with `experiments.layers`, this adds a `layer` option to the loader options to specify the layer of the css execution.
311314

312315
**webpack.config.js**
313316

@@ -317,6 +320,9 @@ const MiniCssExtractPlugin = require("mini-css-extract-plugin");
317320
module.exports = {
318321
plugins: [
319322
new MiniCssExtractPlugin({
323+
// You don't need this for `>= 5.52.0` due to the fact that this is enabled by default
324+
// Required only for `>= 5.33.2 & <= 5.52.0`
325+
// Not avaliable/unsafe for `<= 5.33.2`
320326
experimentalUseImportModule: true,
321327
}),
322328
],

0 commit comments

Comments
 (0)