summaryrefslogtreecommitdiff
path: root/tests/specs/node/require_export_from_parent_with_no_filename/main.cjs
blob: 3335ae1bf981e7fe6132fa479903afd786184742 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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");