Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
395 additions
and
73 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = 2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = 3; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { createRequire as _createRequire } from "module"; | ||
import { createRequire as __createRequire, builtinModules } from "module"; | ||
|
||
it("should evaluate require/createRequire", () => { | ||
expect( | ||
(function() { return typeof _createRequire; }).toString() | ||
).toBe('function() { return "function"; }'); | ||
expect( | ||
(function() { if (typeof _createRequire); }).toString() | ||
).toBe('function() { if (true); }'); | ||
const require = __createRequire(import.meta.url); | ||
expect( | ||
(function() { return typeof require; }).toString() | ||
).toBe('function() { return "function"; }'); | ||
expect( | ||
(function() { if (typeof require); }).toString() | ||
).toBe('function() { if (true); }'); | ||
}); | ||
|
||
it("should create require", () => { | ||
const require = _createRequire(import.meta.url); | ||
expect(require("./a")).toBe(1); | ||
expect(_createRequire(import.meta.url)("./c")).toBe(3); | ||
}); | ||
|
||
it("should resolve using created require", () => { | ||
const require = _createRequire(import.meta.url); | ||
expect(require.resolve("./b")).toBe("./b.js"); | ||
expect(_createRequire(import.meta.url).resolve("./b")).toBe("./b.js"); | ||
}); | ||
|
||
it("should provide require.cache", () => { | ||
const _require = _createRequire(import.meta.url); | ||
expect(require.cache).toBe(_require.cache); | ||
expect(require.cache).toBe(_createRequire(import.meta.url).cache); | ||
}); | ||
|
||
it("should import Node.js module", () => { | ||
expect(Array.isArray(builtinModules)).toBe(true); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/** @type {import("../../../../").Configuration} */ | ||
module.exports = { | ||
target: "node", | ||
optimization: { | ||
moduleIds: "named" | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters