From 4dc6bf1b099a2a7425a5ff313cff9a9c828f6cd3 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Tue, 14 Feb 2023 21:56:49 -0800 Subject: Add workaround for `tls` and `worker_threads` --- src/bun.js/bindings/ZigGlobalObject.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/bun.js/bindings/ZigGlobalObject.cpp') diff --git a/src/bun.js/bindings/ZigGlobalObject.cpp b/src/bun.js/bindings/ZigGlobalObject.cpp index bcb462d42..0f4fe92e2 100644 --- a/src/bun.js/bindings/ZigGlobalObject.cpp +++ b/src/bun.js/bindings/ZigGlobalObject.cpp @@ -1137,6 +1137,15 @@ enum ReadableStreamTag : int32_t { Bytes = 4, }; +JSC_DEFINE_HOST_FUNCTION(functionCallNotImplemented, + (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame)) +{ + auto& vm = globalObject->vm(); + auto scope = DECLARE_THROW_SCOPE(vm); + throwTypeError(globalObject, scope, "Not implemented yet in Bun :("_s); + return JSC::JSValue::encode(JSC::JSValue {}); +} + // we're trying out a new way to do this lazy loading static JSC_DEFINE_HOST_FUNCTION(functionLazyLoad, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame)) @@ -1156,6 +1165,7 @@ JSC: static NeverDestroyed bunStreamString(MAKE_STATIC_STRING_IMPL("bun:stream")); static NeverDestroyed noopString(MAKE_STATIC_STRING_IMPL("noop")); static NeverDestroyed createImportMeta(MAKE_STATIC_STRING_IMPL("createImportMeta")); + static NeverDestroyed masqueradesAsUndefined(MAKE_STATIC_STRING_IMPL("masqueradesAsUndefined")); JSC::JSValue moduleName = callFrame->argument(0); if (moduleName.isNumber()) { @@ -1235,6 +1245,10 @@ JSC: return JSValue::encode(obj); } + if (string == masqueradesAsUndefined) { + return JSValue::encode(InternalFunction::createFunctionThatMasqueradesAsUndefined(vm, globalObject, 0, String(), functionCallNotImplemented)); + } + if (UNLIKELY(string == noopString)) { auto* obj = constructEmptyObject(globalObject); obj->putDirectCustomAccessor(vm, JSC::PropertyName(JSC::Identifier::fromString(vm, "getterSetter"_s)), JSC::CustomGetterSetter::create(vm, noop_getter, noop_setter), 0); -- cgit v1.2.3