aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/bindings/CommonJSModuleRecord.cpp
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2023-07-09 16:33:49 -0700
committerGravatar GitHub <noreply@github.com> 2023-07-09 16:33:49 -0700
commitca42c820d29400d8bd93f493064db029f6d4420d (patch)
tree7d05580229fbab45a9fa54bec19d320d16a76ce2 /src/bun.js/bindings/CommonJSModuleRecord.cpp
parent565d1689e9f2c1f6b657f14b07fa9b95e50a5a56 (diff)
downloadbun-ca42c820d29400d8bd93f493064db029f6d4420d.tar.gz
bun-ca42c820d29400d8bd93f493064db029f6d4420d.tar.zst
bun-ca42c820d29400d8bd93f493064db029f6d4420d.zip
Implement nearly all of `process` object methods and properties (#3581)
* Add special case * Make process object load faster * Fix openStdin --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Diffstat (limited to 'src/bun.js/bindings/CommonJSModuleRecord.cpp')
-rw-r--r--src/bun.js/bindings/CommonJSModuleRecord.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/bun.js/bindings/CommonJSModuleRecord.cpp b/src/bun.js/bindings/CommonJSModuleRecord.cpp
index c7dac89c2..8adba197c 100644
--- a/src/bun.js/bindings/CommonJSModuleRecord.cpp
+++ b/src/bun.js/bindings/CommonJSModuleRecord.cpp
@@ -817,6 +817,12 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionRequireCommonJS, (JSGlobalObject * lexicalGlo
WTF::String specifier = specifierValue.toWTFString(globalObject);
RETURN_IF_EXCEPTION(throwScope, {});
+ // Special-case for "process" to just return the process object directly.
+ if (UNLIKELY(specifier == "process"_s || specifier == "node:process"_s)) {
+ jsDynamicCast<JSCommonJSModule*>(callframe->argument(1))->putDirect(vm, builtinNames(vm).exportsPublicName(), globalObject->processObject(), 0);
+ return JSValue::encode(globalObject->processObject());
+ }
+
WTF::String referrer = thisObject->id().toWTFString(globalObject);
RETURN_IF_EXCEPTION(throwScope, {});