Skip to content

Commit

Permalink
add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Jun 18, 2021
1 parent da6fe93 commit 2b210f9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
6 changes: 5 additions & 1 deletion test/ConfigTestCases.template.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,11 @@ const describeCases = config => {
module in testConfig.modules
) {
return testConfig.modules[module];
} else return require(module);
} else {
return require(module.startsWith("node:")
? module.slice(5)
: module);
}
};

results.push(
Expand Down
8 changes: 8 additions & 0 deletions test/configCases/node/node-prefix/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import vm1 from "vm";
import vm2 from "node:vm";

it("should allow importing node builtin modules with the node: prefix", () => {
expect(require("node:fs")).toBe(require("fs"));
expect(require("node:path")).toBe(require("path"));
expect(vm2).toBe(vm1);
});
4 changes: 4 additions & 0 deletions test/configCases/node/node-prefix/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/** @type {import("../../../../").Configuration} */
module.exports = {
target: "node"
};

0 comments on commit 2b210f9

Please sign in to comment.