@@ -575,7 +575,7 @@ class IsolateModuleRegistry final {
575575 // like the CommonJS require. Returns the instantiated/evaluated module namespace.
576576 // If an empty v8::MaybeLocal is returned and the default option is given, then an
577577 // exception has been scheduled.
578- v8::MaybeLocal<v8::Object > require (
578+ v8::MaybeLocal<v8::Value > require (
579579 Lock& js, const ResolveContext& context, RequireOption option = RequireOption::DEFAULT) {
580580 // Returns either the module namespace or, when UNWRAP_DEFAULT is set and
581581 // the module is not ESM, the default export from the namespace. This matches
@@ -708,7 +708,7 @@ class IsolateModuleRegistry final {
708708 KJ_UNREACHABLE;
709709 };
710710
711- return js.tryCatch ([&]() -> v8::MaybeLocal<v8::Object > {
711+ return js.tryCatch ([&]() -> v8::MaybeLocal<v8::Value > {
712712 KJ_IF_SOME (processUrl, maybeRedirectNodeProcess (js, context.normalizedSpecifier .getHref ())) {
713713 ResolveContext newContext{
714714 .type = ResolveContext::Type::BUILTIN_ONLY,
@@ -1161,12 +1161,13 @@ v8::MaybeLocal<std::conditional_t<IsSourcePhase, v8::Object, v8::Module>> resolv
11611161 // with the compiled record, so that we can just directly read `sourceObject_` off of
11621162 // entry.module instead.
11631163 if (entry.module .isWasm ()) {
1164- v8::Local<v8::Object > moduleNamespace;
1164+ v8::Local<v8::Value > moduleNamespace;
11651165 if (registry
11661166 .require (js, resolveContext, IsolateModuleRegistry::RequireOption::RETURN_EMPTY)
11671167 .ToLocal (&moduleNamespace)) {
11681168 v8::Local<v8::Value> defaultExport;
1169- if (moduleNamespace->Get (js.v8Context (), js.strIntern (" default" _kj))
1169+ if (moduleNamespace.As <v8::Object>()
1170+ ->Get (js.v8Context (), js.strIntern (" default" _kj))
11701171 .ToLocal (&defaultExport)) {
11711172 if (defaultExport->IsWasmModuleObject ()) {
11721173 return defaultExport.As <v8::Object>();
@@ -1801,7 +1802,7 @@ kj::Maybe<const Module&> ModuleRegistry::lookup(const ResolveContext& context) c
18011802 return kj::none;
18021803}
18031804
1804- kj::Maybe<JsObject > ModuleRegistry::tryResolveModuleNamespace (Lock& js,
1805+ kj::Maybe<JsValue > ModuleRegistry::tryResolveModuleNamespace (Lock& js,
18051806 kj::StringPtr specifier,
18061807 ResolveContext::Type type,
18071808 ResolveContext::Source source,
@@ -1839,7 +1840,7 @@ kj::Maybe<JsObject> ModuleRegistry::tryResolveModuleNamespace(Lock& js,
18391840 throw JsExceptionThrown ();
18401841 }
18411842 if (ns.IsEmpty ()) return kj::none;
1842- return JsObject (check (ns));
1843+ return JsValue (check (ns));
18431844}
18441845
18451846JsValue ModuleRegistry::resolve (Lock& js,
@@ -1848,7 +1849,8 @@ JsValue ModuleRegistry::resolve(Lock& js,
18481849 ResolveContext::Type type,
18491850 ResolveContext::Source source,
18501851 kj::Maybe<const Url&> maybeReferrer) {
1851- KJ_IF_SOME (ns, tryResolveModuleNamespace (js, specifier, type, source, maybeReferrer)) {
1852+ KJ_IF_SOME (val, tryResolveModuleNamespace (js, specifier, type, source, maybeReferrer)) {
1853+ auto ns = KJ_ASSERT_NONNULL (val.tryCast <JsObject>());
18521854 return ns.get (js, exportName);
18531855 }
18541856 JSG_FAIL_REQUIRE (Error, kj::str (" Module not found: " , specifier));
0 commit comments