-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
1 parent
e20cfec
commit 3281108
Showing
4 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
tests/registry/npm/@denotest/cjs-multiple-exports/1.0.0/package.json
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,8 @@ | ||
{ | ||
"name": "@denotest/cjs-multiple-exports", | ||
"version": "1.0.0", | ||
"exports": { | ||
".": "./src/index.js", | ||
"./add": "./src/add.js" | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
tests/specs/node/require_export_from_parent_with_no_filename/__test__.jsonc
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,13 @@ | ||
{ | ||
"tempDir": true, | ||
"steps": [ | ||
{ | ||
"args": "install", | ||
"output": "[WILDCARD]" | ||
}, | ||
{ | ||
"args": "run -A main.cjs", | ||
"output": "3\n" | ||
} | ||
] | ||
} |
16 changes: 16 additions & 0 deletions
16
tests/specs/node/require_export_from_parent_with_no_filename/main.cjs
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,16 @@ | ||
const path = require("node:path"); | ||
const Module = require("node:module"); | ||
function requireFromString(code, filename) { | ||
const paths = Module._nodeModulePaths((0, path.dirname)(filename)); | ||
const m = new Module(filename, module.parent); | ||
m.paths = paths; | ||
m._compile(code, filename); | ||
return m.exports; | ||
} | ||
|
||
const code = ` | ||
const add = require("@denotest/cjs-multiple-exports/add"); | ||
console.log(add(1, 2)); | ||
`; | ||
requireFromString(code, "fake.js"); |
5 changes: 5 additions & 0 deletions
5
tests/specs/node/require_export_from_parent_with_no_filename/package.json
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,5 @@ | ||
{ | ||
"dependencies": { | ||
"@denotest/cjs-multiple-exports": "1.0.0" | ||
} | ||
} |