@@ -2407,27 +2407,30 @@ static void Binding(const FunctionCallbackInfo<Value>& args) {
2407
2407
static void LinkedBinding (const FunctionCallbackInfo<Value>& args) {
2408
2408
Environment* env = Environment::GetCurrent (args.GetIsolate ());
2409
2409
2410
- Local<String> module = args[0 ]->ToString (env->isolate ());
2410
+ Local<String> module_name = args[0 ]->ToString (env->isolate ());
2411
2411
2412
2412
Local<Object> cache = env->binding_cache_object ();
2413
- Local<Value> exports_v = cache->Get (module );
2413
+ Local<Value> exports_v = cache->Get (module_name );
2414
2414
2415
2415
if (exports_v->IsObject ())
2416
2416
return args.GetReturnValue ().Set (exports_v.As <Object>());
2417
2417
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 );
2420
2420
2421
2421
if (mod == nullptr ) {
2422
2422
char errmsg[1024 ];
2423
2423
snprintf (errmsg,
2424
2424
sizeof (errmsg),
2425
2425
" No such module was linked: %s" ,
2426
- *module_v );
2426
+ *module_name_v );
2427
2427
return env->ThrowError (errmsg);
2428
2428
}
2429
2429
2430
+ Local<Object> module = Object::New (env->isolate ());
2430
2431
Local<Object> exports = Object::New (env->isolate ());
2432
+ Local<String> exports_prop = String::NewFromUtf8 (env->isolate (), " exports" );
2433
+ module->Set (exports_prop, exports);
2431
2434
2432
2435
if (mod->nm_context_register_func != nullptr ) {
2433
2436
mod->nm_context_register_func (exports,
@@ -2440,7 +2443,7 @@ static void LinkedBinding(const FunctionCallbackInfo<Value>& args) {
2440
2443
return env->ThrowError (" Linked module has no declared entry point." );
2441
2444
}
2442
2445
2443
- cache->Set (module, exports );
2446
+ cache->Set (module_name, module-> Get (exports_prop) );
2444
2447
2445
2448
args.GetReturnValue ().Set (exports);
2446
2449
}
0 commit comments