Skip to content

Commit ce179d7

Browse files
fix: increase parallelism when using importModule on the execution stage
2 parents 90ea8b8 + 3316bf7 commit ce179d7

File tree

12 files changed

+62
-6
lines changed

12 files changed

+62
-6
lines changed

lib/dependencies/LoaderPlugin.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ class LoaderPlugin {
197197
if (!referencedModule) {
198198
return callback(new Error("Cannot load the module"));
199199
}
200+
compilation.buildQueue.increaseParallelism();
200201
compilation.executeModule(
201202
referencedModule,
202203
{
@@ -206,6 +207,7 @@ class LoaderPlugin {
206207
}
207208
},
208209
(err, result) => {
210+
compilation.buildQueue.decreaseParallelism();
209211
if (err) return callback(err);
210212
const {
211213
fileDependencies,

test/configCases/performance/many-async-imports/test.filter.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

test/configCases/performance/many-exports/test.filter.js

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import * as styles from './style.module.css';
2+
import * as styles1 from './module.js';
3+
4+
it("should not deadlock when using importModule", () => {
5+
expect(styles.someBottom).toBe("8px");
6+
expect(styles1.someBottom).toBe("8px");
7+
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@value someBottom from "./vars.module.css";
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/** @type {import("../../../../").LoaderDefinition} */
2+
module.exports.pitch = function (request) {
3+
const callback = this.async();
4+
let finished = false;
5+
6+
this.importModule(
7+
`${this.resourcePath}.webpack[javascript/auto]!=!!!${request}`,
8+
{},
9+
(err, result) => {
10+
if (err) return callback(err);
11+
if (finished) return;
12+
finished = true;
13+
callback(null, `module.exports = ${JSON.stringify(result)};`);
14+
}
15+
);
16+
setTimeout(() => {
17+
if (finished) return;
18+
finished = true;
19+
callback(new Error("importModule is hanging"));
20+
}, 2000);
21+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './style1.module.css'
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@value someBottom from "./inner.module.css";
2+
3+
.cold {
4+
bottom: someBottom;
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@value someBottom from "./inner.module.css";
2+
3+
.cold {
4+
bottom: someBottom;
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = function (config) {
2+
const [major] = process.versions.node.split(".").map(Number);
3+
4+
return major >= 18;
5+
};

0 commit comments

Comments
 (0)