Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanwhit committed Oct 30, 2024
1 parent e20cfec commit 3281108
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 0 deletions.
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"
}
}
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"
}
]
}
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");
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dependencies": {
"@denotest/cjs-multiple-exports": "1.0.0"
}
}

0 comments on commit 3281108

Please sign in to comment.