@@ -2407,27 +2407,30 @@ static void Binding(const FunctionCallbackInfo<Value>& args) {
24072407static void LinkedBinding (const FunctionCallbackInfo<Value>& args) {
24082408 Environment* env = Environment::GetCurrent (args.GetIsolate ());
24092409
2410- Local<String> module = args[0 ]->ToString (env->isolate ());
2410+ Local<String> module_name = args[0 ]->ToString (env->isolate ());
24112411
24122412 Local<Object> cache = env->binding_cache_object ();
2413- Local<Value> exports_v = cache->Get (module );
2413+ Local<Value> exports_v = cache->Get (module_name );
24142414
24152415 if (exports_v->IsObject ())
24162416 return args.GetReturnValue ().Set (exports_v.As <Object>());
24172417
2418- node::Utf8Value module_v (env->isolate (), module );
2419- node_module* mod = get_linked_module (*module_v );
2418+ node::Utf8Value module_name_v (env->isolate (), module_name );
2419+ node_module* mod = get_linked_module (*module_name_v );
24202420
24212421 if (mod == nullptr ) {
24222422 char errmsg[1024 ];
24232423 snprintf (errmsg,
24242424 sizeof (errmsg),
24252425 " No such module was linked: %s" ,
2426- *module_v );
2426+ *module_name_v );
24272427 return env->ThrowError (errmsg);
24282428 }
24292429
2430+ Local<Object> module = Object::New (env->isolate ());
24302431 Local<Object> exports = Object::New (env->isolate ());
2432+ Local<String> exports_prop = String::NewFromUtf8 (env->isolate (), " exports" );
2433+ module ->Set (exports_prop, exports);
24312434
24322435 if (mod->nm_context_register_func != nullptr ) {
24332436 mod->nm_context_register_func (exports,
@@ -2440,7 +2443,7 @@ static void LinkedBinding(const FunctionCallbackInfo<Value>& args) {
24402443 return env->ThrowError (" Linked module has no declared entry point." );
24412444 }
24422445
2443- cache->Set (module , exports );
2446+ cache->Set (module_name, module -> Get (exports_prop) );
24442447
24452448 args.GetReturnValue ().Set (exports);
24462449}
0 commit comments