mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 18:38:55 +00:00
Fix missing module.prototype._compile
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
|
||||
#include "NodeModuleModule.h"
|
||||
|
||||
#include "CommonJSModuleRecord.h"
|
||||
#include "ErrorCode.h"
|
||||
#include <JavaScriptCore/LazyPropertyInlines.h>
|
||||
#include <JavaScriptCore/VMTrapsInlines.h>
|
||||
@@ -624,10 +625,30 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionInitPaths, (JSGlobalObject * globalObject,
|
||||
return JSC::JSValue::encode(JSC::jsUndefined());
|
||||
}
|
||||
|
||||
JSC_DEFINE_CUSTOM_GETTER(getterModuleConstructor,
|
||||
(JSGlobalObject * lexicalGlobalObject,
|
||||
JSC::EncodedJSValue thisValue,
|
||||
JSC::PropertyName propertyName)) {
|
||||
auto *globalObject = defaultGlobalObject(lexicalGlobalObject);
|
||||
|
||||
return JSValue::encode(
|
||||
globalObject->m_nodeModuleConstructor.getInitializedOnMainThread(
|
||||
globalObject));
|
||||
}
|
||||
|
||||
JSC_DEFINE_CUSTOM_SETTER(setterModuleConstructor,
|
||||
(JSGlobalObject * lexicalGlobalObject,
|
||||
JSC::EncodedJSValue thisValue,
|
||||
JSC::EncodedJSValue value,
|
||||
JSC::PropertyName propertyName)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static JSValue getModulePrototypeObject(VM &vm, JSObject *moduleObject) {
|
||||
auto *globalObject = defaultGlobalObject(moduleObject->globalObject());
|
||||
auto prototype =
|
||||
constructEmptyObject(globalObject, globalObject->objectPrototype(), 2);
|
||||
constructEmptyObject(globalObject, globalObject->objectPrototype(), 3);
|
||||
prototype->structure()->setMayBePrototype(true);
|
||||
|
||||
prototype->putDirectCustomAccessor(
|
||||
vm, WebCore::clientData(vm)->builtinNames().requirePublicName(),
|
||||
@@ -635,6 +656,18 @@ static JSValue getModulePrototypeObject(VM &vm, JSObject *moduleObject) {
|
||||
setterRequireFunction),
|
||||
0);
|
||||
|
||||
prototype->putDirectCustomAccessor(
|
||||
vm, vm.propertyNames->constructor,
|
||||
JSC::CustomGetterSetter::create(vm, getterModuleConstructor,
|
||||
setterModuleConstructor),
|
||||
PropertyAttribute::DontEnum | PropertyAttribute::ReadOnly);
|
||||
|
||||
prototype->putDirectNativeFunction(
|
||||
vm, globalObject, Identifier::fromString(vm, "_compile"_s), 1,
|
||||
jsFunctionCommonJSModuleRecord_compile,
|
||||
JSC::ImplementationVisibility::Public, NoIntrinsic,
|
||||
JSC::PropertyAttribute::DontEnum | 0);
|
||||
|
||||
return prototype;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user