From 21f9fc828f9b115f2d0db5da025394e4aee9530e Mon Sep 17 00:00:00 2001 From: dave caruso Date: Sun, 12 Mar 2023 06:43:32 -0400 Subject: fix `require.resolve` with an empty options object #2370 (#2371) * fix #2370 and import-meta test * edit test to not allow transpiler optimization --- src/bun.js/bindings/ImportMetaObject.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/bun.js/bindings/ImportMetaObject.cpp') diff --git a/src/bun.js/bindings/ImportMetaObject.cpp b/src/bun.js/bindings/ImportMetaObject.cpp index 89d59b541..f8b6d0f9b 100644 --- a/src/bun.js/bindings/ImportMetaObject.cpp +++ b/src/bun.js/bindings/ImportMetaObject.cpp @@ -84,9 +84,11 @@ static EncodedJSValue functionRequireResolve(JSC::JSGlobalObject* globalObject, // require.resolve also supports a paths array // we only support a single path if (!fromValue.isUndefinedOrNull() && fromValue.isObject()) { - if (JSC::JSArray* array = JSC::jsDynamicCast(fromValue.getObject()->getIfPropertyExists(globalObject, JSC::Identifier::fromString(vm, "paths"_s)))) { - if (array->length() > 0) { - fromValue = array->getIndex(globalObject, 0); + if (JSValue pathsValue = fromValue.getObject()->getIfPropertyExists(globalObject, JSC::Identifier::fromString(vm, "paths"_s))) { + if (JSC::JSArray* array = JSC::jsDynamicCast(pathsValue)) { + if (array->length() > 0) { + fromValue = array->getIndex(globalObject, 0); + } } } } -- cgit v1.2.3