node-eval
node-eval copied to clipboard
Replace "require-like" by createRequire?
require-like
uses Module._load
, an API that is not supported by Bun (atm): https://github.com/oven-sh/bun/issues/5925
This led to bugs in Docusaurus Bun support: https://github.com/oven-sh/bun/issues/3426#issuecomment-1929173528
This can be prevented by using this Node API instead of the very old require-like
code:
const module = require("module");
const sandbox = {
require: module.createRequire(_filename);
}
This seems to be the "modern" way to achieve the same behavior, using a built-in API, and would get rid of a useless dependency. (and this would permit to use this lib in Bun, until they support the older Module apis)