-
Notifications
You must be signed in to change notification settings - Fork 5.6k
std/node: add CommonJS require #3380
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
Conversation
@@ -0,0 +1,1189 @@ | |||
// Copyright Joyent, Inc. and other Node contributors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello old friend
|
||
test(function requireCycle() { | ||
const resultA = require_("./node/tests/cjs/cjs_cycle_a"); | ||
const resultB = require_("./node/tests/cjs/cjs_cycle_b"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - very nice
Basically from https://github.com/nodejs/node/blob/master/lib/internal/modules/cjs/loader.js
Seems to also work with
node_modules
.NOTICE this requires
Deno.core.evalContext
This would likely be a great starting point for compat, since this requires only the entry point to explicitly create
require
frommakeRequire
. Also we could possibly inject otherstd/node
polyfills in therequire
resolution steps as builtin modules, such that polyfills would work seamlessly.ref #2644