This commit is contained in:
Jarred Sumner
2025-03-28 20:23:49 -07:00
committed by GitHub
parent f0dfa109bb
commit f38d35f7c9
56 changed files with 191 additions and 1011 deletions

View File

@@ -12,7 +12,6 @@
#include <JavaScriptCore/JSInternalPromise.h>
#include "JavaScriptCore/Completion.h"
#include "JavaScriptCore/JSNativeStdFunction.h"
#include "JSCommonJSExtensions.h"
#include "PathInlines.h"
#include "ZigGlobalObject.h"
@@ -563,12 +562,6 @@ static JSValue getModuleCacheObject(VM& vm, JSObject* moduleObject)
->lazyRequireCacheObject();
}
static JSValue getModuleExtensionsObject(VM& vm, JSObject* moduleObject)
{
return jsCast<Zig::GlobalObject*>(moduleObject->globalObject())
->lazyRequireExtensionsObject();
}
static JSValue getModuleDebugObject(VM& vm, JSObject* moduleObject)
{
return JSC::constructEmptyObject(moduleObject->globalObject());
@@ -581,6 +574,13 @@ static JSValue getPathCacheObject(VM& vm, JSObject* moduleObject)
vm, globalObject->nullPrototypeObjectStructure());
}
static JSValue getModuleExtensionsObject(VM& vm, JSObject* moduleObject)
{
auto* globalObject = defaultGlobalObject(moduleObject->globalObject());
return globalObject->requireFunctionUnbound()->getIfPropertyExists(
globalObject, Identifier::fromString(vm, "extensions"_s));
}
static JSValue getSourceMapFunction(VM& vm, JSObject* moduleObject)
{
auto* globalObject = defaultGlobalObject(moduleObject->globalObject());
@@ -951,27 +951,6 @@ void addNodeModuleConstructorProperties(JSC::VM& vm,
JSC::NoIntrinsic, jsFunctionResolveFileName);
init.set(resolveFilenameFunction);
});
globalObject->m_lazyRequireCacheObject.initLater(
[](const Zig::GlobalObject::Initializer<JSObject>& init) {
JSC::VM& vm = init.vm;
JSC::JSGlobalObject* globalObject = init.owner;
auto* function = JSFunction::create(vm, globalObject, static_cast<JSC::FunctionExecutable*>(commonJSCreateRequireCacheCodeGenerator(vm)), globalObject);
NakedPtr<JSC::Exception> returnedException = nullptr;
auto result = JSC::profiledCall(globalObject, ProfilingReason::API, function, JSC::getCallData(function), globalObject, ArgList(), returnedException);
ASSERT(!returnedException);
init.set(result.toObject(globalObject));
});
globalObject->m_lazyRequireExtensionsObject.initLater(
[](const Zig::GlobalObject::Initializer<Bun::JSCommonJSExtensions>& init) {
JSC::VM& vm = init.vm;
JSC::JSGlobalObject* globalObject = init.owner;
init.set(JSCommonJSExtensions::create(vm, globalObject, JSCommonJSExtensions::createStructure(vm, globalObject, globalObject->nullPrototype())));
});
}
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsModuleResolveFilenameSlowPathEnabled,