Skip to content
Prev Previous commit
Next Next commit
Revert "add private property to avoid calling ada twice"
  • Loading branch information
aduh95 committed Apr 25, 2025
commit 077bde31948e491262f6b1ebcf184c128e7a8fc3
1 change: 0 additions & 1 deletion src/env_properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
V(module_circular_visited_private_symbol, "node:module_circular_visited") \
V(module_export_private_symbol, "node:module_export") \
V(module_parent_private_symbol, "node:module_parent") \
V(module_import_meta_path, "node:module_import_meta_path") \
V(napi_type_tag, "node:napi:type_tag") \
V(napi_wrapper, "node:napi:wrapper") \
V(untransferable_object_private_symbol, "node:untransferableObject") \
Expand Down
24 changes: 1 addition & 23 deletions src/node_modules.cc
Original file line number Diff line number Diff line change
Expand Up @@ -629,25 +629,6 @@ static void PathHelpersLazyGetter(Local<v8::Name> name,
CHECK(index != std::string_view::npos); \
ret_view.remove_suffix(ret_view.size() - index)

Local<Value> ret;
if (receiver->HasPrivate(context, env->module_import_meta_path())
.FromMaybe(false)) {
auto maybe_value =
receiver->GetPrivate(context, env->module_import_meta_path());
if (!maybe_value.ToLocal(&ret)) return;

if (plain_name == "dirname") {
node::Utf8Value utf8name(isolate, ret.As<String>());
auto ret_view = utf8name.ToStringView();
dirname(ret_view);
if (!ToV8Value(context, ret_view, isolate).ToLocal(&ret)) {
return;
}
}
info.GetReturnValue().Set(ret);
receiver->DeletePrivate(context, env->module_import_meta_path());
return;
}

node::Utf8Value url(isolate, info.Data());
auto file_url = ada::parse(url.ToStringView());
Expand All @@ -656,13 +637,10 @@ static void PathHelpersLazyGetter(Local<v8::Name> name,
CHECK(file_path.has_value());
std::string_view ret_view = file_path.value();

if (!ToV8Value(context, ret_view, isolate).ToLocal(&ret)) {
return;
}
receiver->SetPrivate(context, env->module_import_meta_path(), ret);
if (plain_name == "dirname") {
dirname(ret_view);
}
Local<Value> ret;
if (!ToV8Value(context, ret_view, isolate).ToLocal(&ret)) {
return;
}
Expand Down