Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/internal/util/embedding.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,18 @@ function embedderRunCjs(contents) {
customDirname);
}

let embedderRequireInternal;

function embedderRequire(path) {
if (!Module.isBuiltin(path)) {
throw new ERR_UNKNOWN_BUILTIN_MODULE(path);
}

return require(path);
if (!embedderRequireInternal) {
Comment thread
RaisinTen marked this conversation as resolved.
Outdated
embedderRequireInternal = Module.createRequire(process.execPath);
}

return embedderRequireInternal(path);
}

module.exports = { embedderRequire, embedderRunCjs };
2 changes: 1 addition & 1 deletion test/fixtures/sea.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ expectWarning('ExperimentalWarning',
'might change at any time');

const { deepStrictEqual, strictEqual, throws } = require('assert');
const { dirname } = require('path');
const { dirname } = require('node:path');

deepStrictEqual(process.argv, [process.execPath, process.execPath, '-a', '--b=c', 'd']);

Expand Down