@@ -2428,23 +2428,26 @@ void DLOpen(const FunctionCallbackInfo<Value>& args) {
2428
2428
return ;
2429
2429
}
2430
2430
2431
- #ifdef ENABLE_NAPI
2432
- bool isNapiModule = (!no_napi_modules && mp->nm_version == -1 );
2433
-
2434
- if (mp->nm_version != NODE_MODULE_VERSION && !isNapiModule) {
2435
- #else /* !defined ENABLE_NAPI */
2436
2431
if (mp->nm_version != NODE_MODULE_VERSION) {
2437
- #endif /* def ENABLE_NAPI */
2438
2432
char errmsg[1024 ];
2439
- snprintf (errmsg,
2440
- sizeof (errmsg),
2441
- " The module '%s'"
2442
- " \n was compiled against a different Node.js version using"
2443
- " \n NODE_MODULE_VERSION %d. This version of Node.js requires"
2444
- " \n NODE_MODULE_VERSION %d. Please try re-compiling or "
2445
- " re-installing\n the module (for instance, using `npm rebuild` or "
2446
- " `npm install`)." ,
2447
- *filename, mp->nm_version , NODE_MODULE_VERSION);
2433
+ if (mp->nm_version == -1 ) {
2434
+ snprintf (errmsg,
2435
+ sizeof (errmsg),
2436
+ " The module '%s'"
2437
+ " \n was compiled against the Node.js API. This feature is "
2438
+ " \n experimental and must be enabled on the command-line." ,
2439
+ *filename);
2440
+ } else {
2441
+ snprintf (errmsg,
2442
+ sizeof (errmsg),
2443
+ " The module '%s'"
2444
+ " \n was compiled against a different Node.js version using"
2445
+ " \n NODE_MODULE_VERSION %d. This version of Node.js requires"
2446
+ " \n NODE_MODULE_VERSION %d. Please try re-compiling or "
2447
+ " re-installing\n the module (for instance, using `npm rebuild` or "
2448
+ " `npm install`)." ,
2449
+ *filename, mp->nm_version , NODE_MODULE_VERSION);
2450
+ }
2448
2451
2449
2452
// NOTE: `mp` is allocated inside of the shared library's memory, calling
2450
2453
// `uv_dlclose` will deallocate it
@@ -2465,21 +2468,6 @@ void DLOpen(const FunctionCallbackInfo<Value>& args) {
2465
2468
Local<String> exports_string = env->exports_string ();
2466
2469
Local<Object> exports = module ->Get (exports_string)->ToObject (env->isolate ());
2467
2470
2468
- #ifdef ENABLE_NAPI
2469
- if (isNapiModule) {
2470
- if (mp->nm_register_func != nullptr ) {
2471
- reinterpret_cast <node::addon_abi_register_func>(mp->nm_register_func )(
2472
- v8impl::JsEnvFromV8Isolate (v8::Isolate::GetCurrent ()),
2473
- v8impl::JsValueFromV8LocalValue (exports),
2474
- v8impl::JsValueFromV8LocalValue (module ),
2475
- mp->nm_priv );
2476
- } else {
2477
- uv_dlclose (&lib);
2478
- env->ThrowError (" Module has no declared entry point." );
2479
- }
2480
- return ;
2481
- }
2482
- #endif /* def ENABLE_NAPI */
2483
2471
if (mp->nm_context_register_func != nullptr ) {
2484
2472
mp->nm_context_register_func (exports, module , env->context (), mp->nm_priv );
2485
2473
} else if (mp->nm_register_func != nullptr ) {
@@ -2714,19 +2702,7 @@ static void LinkedBinding(const FunctionCallbackInfo<Value>& args) {
2714
2702
env->context (),
2715
2703
mod->nm_priv );
2716
2704
} else if (mod->nm_register_func != nullptr ) {
2717
- #ifdef ENABLE_NAPI
2718
- if (mod->nm_version != -1 ) {
2719
- mod->nm_register_func (exports, module , mod->nm_priv );
2720
- } else {
2721
- reinterpret_cast <node::addon_abi_register_func>(mod->nm_register_func )(
2722
- v8impl::JsEnvFromV8Isolate (v8::Isolate::GetCurrent ()),
2723
- v8impl::JsValueFromV8LocalValue (exports),
2724
- v8impl::JsValueFromV8LocalValue (module ),
2725
- mod->nm_priv );
2726
- }
2727
- #else /* !defined ENABLE_NAPI */
2728
2705
mod->nm_register_func (exports, module , mod->nm_priv );
2729
- #endif /* def ENABLE_NAPI */
2730
2706
} else {
2731
2707
return env->ThrowError (" Linked module has no declared entry point." );
2732
2708
}
0 commit comments