Skip to content
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.

Replace "require-like" by createRequire? #33

Open
slorber opened this issue Feb 6, 2024 · 0 comments
Open

Replace "require-like" by createRequire? #33

slorber opened this issue Feb 6, 2024 · 0 comments

Comments

@slorber
Copy link

slorber commented Feb 6, 2024

require-like uses Module._load, an API that is not supported by Bun (atm): oven-sh/bun#5925

This led to bugs in Docusaurus Bun support:
oven-sh/bun#3426 (comment)

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)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant