mirror of
https://github.com/zebrajr/node.git
synced 2025-12-06 12:20:27 +01:00
PR-URL: https://github.com/nodejs/node/pull/59805 Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Richard Lau <richard.lau@ibm.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
25 lines
854 B
JavaScript
25 lines
854 B
JavaScript
/**
|
|
* This file is supposed to be loaded by `test-import.js` and `test-require.js`
|
|
* to verify that `import('*.node')` is working properly either been loaded with
|
|
* the ESM loader or the CJS loader.
|
|
*/
|
|
|
|
import { buildType } from '../../common/index.mjs';
|
|
import assert from 'node:assert';
|
|
import { createRequire } from 'node:module';
|
|
import { pathToFileURL } from 'node:url';
|
|
|
|
const require = createRequire(import.meta.url);
|
|
|
|
export async function run() {
|
|
// binding-export-primitive.node
|
|
{
|
|
const bindingPath = require.resolve(`./build/${buildType}/binding-export-primitive.node`);
|
|
const ns = await import(pathToFileURL(bindingPath));
|
|
|
|
// As same as ESM-import-CJS, the default export is the value of `module.exports`.
|
|
assert.strictEqual(ns.default, ns['module.exports']);
|
|
assert.strictEqual(ns.default, 'hello world');
|
|
}
|
|
}
|