fix: increase parallelism when using `importModule` on the execution stage

This commit is contained in:
Alexander Akait 2024-09-26 17:45:27 +03:00 committed by GitHub
commit ce179d77c5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 62 additions and 6 deletions

View File

@ -197,6 +197,7 @@ class LoaderPlugin {
if (!referencedModule) {
return callback(new Error("Cannot load the module"));
}
compilation.buildQueue.increaseParallelism();
compilation.executeModule(
referencedModule,
{
@ -206,6 +207,7 @@ class LoaderPlugin {
}
},
(err, result) => {
compilation.buildQueue.decreaseParallelism();
if (err) return callback(err);
const {
fileDependencies,

View File

@ -1,3 +0,0 @@
module.exports = function (config) {
return !/^v(4|6)/.test(process.version);
};

View File

@ -1,3 +0,0 @@
module.exports = function (config) {
return !/^v(4|6)/.test(process.version);
};

View File

@ -0,0 +1,7 @@
import * as styles from './style.module.css';
import * as styles1 from './module.js';
it("should not deadlock when using importModule", () => {
expect(styles.someBottom).toBe("8px");
expect(styles1.someBottom).toBe("8px");
});

View File

@ -0,0 +1 @@
@value someBottom from "./vars.module.css";

View File

@ -0,0 +1,21 @@
/** @type {import("../../../../").LoaderDefinition} */
module.exports.pitch = function (request) {
const callback = this.async();
let finished = false;
this.importModule(
`${this.resourcePath}.webpack[javascript/auto]!=!!!${request}`,
{},
(err, result) => {
if (err) return callback(err);
if (finished) return;
finished = true;
callback(null, `module.exports = ${JSON.stringify(result)};`);
}
);
setTimeout(() => {
if (finished) return;
finished = true;
callback(new Error("importModule is hanging"));
}, 2000);
};

View File

@ -0,0 +1 @@
export * from './style1.module.css'

View File

@ -0,0 +1,5 @@
@value someBottom from "./inner.module.css";
.cold {
bottom: someBottom;
}

View File

@ -0,0 +1,5 @@
@value someBottom from "./inner.module.css";
.cold {
bottom: someBottom;
}

View File

@ -0,0 +1,5 @@
module.exports = function (config) {
const [major] = process.versions.node.split(".").map(Number);
return major >= 18;
};

View File

@ -0,0 +1,2 @@
@value someBottom: 8px;
@value someBottom1: 8px;

View File

@ -0,0 +1,13 @@
/** @type {import("../../../../").Configuration} */
module.exports = {
parallelism: 1,
mode: "development",
module: {
rules: [
{
test: /\.css$/i,
use: [require.resolve("./loader"), "css-loader"]
}
]
}
};