-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Override module.createRequire
#9426
Comments
Hi @SimenB . Can I work on this? |
Yeah, go for it! |
I tested a bit in the repl now, and EDIT: One complication is |
Fixed by #9469 |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
People can do
today, which will break out of the sandbox. We need to intercept this function when
module
is imported and provide our own implementation. This will be especially important when we start supporting ES Modules.Relevant places in the code:
https://github.com/facebook/jest/blob/2ece4f979deaa2504038e8cca1f6b97925c3eb26/packages/jest-runtime/src/index.ts#L860-L866
Need to check for
moduleName === 'module'
and callhttps://github.com/facebook/jest/blob/2ece4f979deaa2504038e8cca1f6b97925c3eb26/packages/jest-runtime/src/index.ts#L970-L973
where we already have a function to create a
require
from a path.I'm not sure if each
createRequire
call returns its own cache or not.Docs: https://nodejs.org/api/modules.html#modules_module_createrequire_filename
We should probably inspect the real
module
export and see ifcreateRequire
is there and only add ours if it is. We should also check ifcreateRequireFromPath
exist and support that as well. The latter only support a full path, while the former supportsURL
s.We should probably just no-op
syncBuiltinESMExports
at the same timeThe text was updated successfully, but these errors were encountered: