node/test/fixtures/pkgexports.mjs
Guy Bedford d24c7313f7 module: support 'module.exports' interop export in require(esm)
PR-URL: https://github.com/nodejs/node/pull/54563
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2024-10-01 21:13:03 -07:00

17 lines
402 B
JavaScript

import { fileURLToPath } from 'url';
import { createRequire } from 'module';
const rawRequire = createRequire(fileURLToPath(import.meta.url));
export function directRequireFixture(specifier) {
return rawRequire(specifier);
}
export async function requireFixture(specifier) {
return { default: rawRequire(specifier ) };
}
export function importFixture(specifier) {
return import(specifier);
}