Skip to content

Commit 11449f0

Browse files
test: async loaders
1 parent 491d7e0 commit 11449f0

8 files changed

Lines changed: 46 additions & 0 deletions

File tree

test/configCases/loaders/async-loader/a.js

Whitespace-only changes.

test/configCases/loaders/async-loader/b.js

Whitespace-only changes.

test/configCases/loaders/async-loader/c.js

Whitespace-only changes.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
it("should work when loader is async", function() {
2+
expect(require("./a")).toBe("a");
3+
});
4+
5+
it("should work when loader is async #2", function() {
6+
expect(require("./b")).toBe("b");
7+
});
8+
9+
it("should work when loader is async #3", function() {
10+
expect(require("./c")).toBe("c");
11+
});
12+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/** @type {import("../../../../").LoaderDefinition} */
2+
module.exports = async function () {
3+
return `module.exports = 'a';`;
4+
};
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/** @type {import("../../../../").LoaderDefinition} */
2+
module.exports = function () {
3+
return Promise.resolve(`module.exports = 'b';`);
4+
};
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/** @type {import("../../../../").LoaderDefinition} */
2+
module.exports = function () {
3+
const callback = this.async();
4+
5+
callback(null, `module.exports = 'c';`);
6+
};
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/** @type {import("../../../../").Configuration} */
2+
module.exports = {
3+
mode: "development",
4+
module: {
5+
rules: [
6+
{
7+
test: /a\.js$/,
8+
use: "./loader-1"
9+
},
10+
{
11+
test: /b\.js$/,
12+
use: "./loader-2"
13+
},
14+
{
15+
test: /c\.js$/,
16+
use: "./loader-3"
17+
}
18+
]
19+
}
20+
};

0 commit comments

Comments
 (0)