aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/bindings/BunPlugin.cpp
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-09-05 23:05:22 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-09-05 23:05:22 -0700
commit11aa17a57cc679d34e8e6f6f7aa665f565cb7305 (patch)
treeccb9a605cb4bcc42c6b2665ddbf8d04af72d94c7 /src/bun.js/bindings/BunPlugin.cpp
parentd2397b60e79e4386c6a7b7a9783a6f8e379a5ae0 (diff)
downloadbun-11aa17a57cc679d34e8e6f6f7aa665f565cb7305.tar.gz
bun-11aa17a57cc679d34e8e6f6f7aa665f565cb7305.tar.zst
bun-11aa17a57cc679d34e8e6f6f7aa665f565cb7305.zip
Support async `onLoad` callbacks in `Bun.plugin`
Diffstat (limited to 'src/bun.js/bindings/BunPlugin.cpp')
-rw-r--r--src/bun.js/bindings/BunPlugin.cpp6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/bun.js/bindings/BunPlugin.cpp b/src/bun.js/bindings/BunPlugin.cpp
index 0941d2722..ba1d40a0b 100644
--- a/src/bun.js/bindings/BunPlugin.cpp
+++ b/src/bun.js/bindings/BunPlugin.cpp
@@ -303,8 +303,7 @@ extern "C" EncodedJSValue jsFunctionBunPlugin(JSC::JSGlobalObject* globalObject,
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
if (auto* promise = JSC::jsDynamicCast<JSC::JSPromise*>(result)) {
- JSC::throwTypeError(globalObject, throwScope, "setup() does not support promises yet"_s);
- return JSValue::encode(jsUndefined());
+ RELEASE_AND_RETURN(throwScope, JSValue::encode(promise));
}
RELEASE_AND_RETURN(throwScope, JSValue::encode(jsUndefined()));
@@ -384,8 +383,7 @@ EncodedJSValue BunPlugin::OnLoad::run(JSC::JSGlobalObject* globalObject, ZigStri
if (auto* promise = JSC::jsDynamicCast<JSPromise*>(result)) {
switch (promise->status(vm)) {
case JSPromise::Status::Pending: {
- JSC::throwTypeError(globalObject, throwScope, "onLoad() doesn't support pending promises yet"_s);
- return JSValue::encode({});
+ return JSValue::encode(promise);
}
case JSPromise::Status::Rejected: {
promise->internalField(JSC::JSPromise::Field::Flags).set(vm, promise, jsNumber(static_cast<unsigned>(JSC::JSPromise::Status::Fulfilled)));