@@ -3083,6 +3083,8 @@ void BindingData::LegacyMainResolve(const FunctionCallbackInfo<Value>& args) {
3083
3083
return ;
3084
3084
}
3085
3085
3086
+ std::string package_initial_file = " " ;
3087
+
3086
3088
ada::result<ada::url_aggregator> file_path_url;
3087
3089
std::optional<std::string> initial_file_path;
3088
3090
std::string file_path;
@@ -3105,6 +3107,8 @@ void BindingData::LegacyMainResolve(const FunctionCallbackInfo<Value>& args) {
3105
3107
3106
3108
FromNamespacedPath (&initial_file_path.value ());
3107
3109
3110
+ package_initial_file = *initial_file_path;
3111
+
3108
3112
for (int i = 0 ; i < legacy_main_extensions_with_main_end; i++) {
3109
3113
file_path = *initial_file_path + std::string (legacy_main_extensions[i]);
3110
3114
@@ -3160,13 +3164,10 @@ void BindingData::LegacyMainResolve(const FunctionCallbackInfo<Value>& args) {
3160
3164
}
3161
3165
}
3162
3166
3163
- std::optional<std::string> module_path =
3164
- node::url::FileURLToPath (env, *package_json_url);
3165
- std::optional<std::string> module_base;
3167
+ if (package_initial_file == " " )
3168
+ package_initial_file = *initial_file_path + " .js" ;
3166
3169
3167
- if (!module_path.has_value ()) {
3168
- return ;
3169
- }
3170
+ std::optional<std::string> module_base;
3170
3171
3171
3172
if (args.Length () >= 3 && args[2 ]->IsString ()) {
3172
3173
Utf8Value utf8_base_path (isolate, args[2 ]);
@@ -3191,7 +3192,7 @@ void BindingData::LegacyMainResolve(const FunctionCallbackInfo<Value>& args) {
3191
3192
3192
3193
THROW_ERR_MODULE_NOT_FOUND (isolate,
3193
3194
" Cannot find package '%s' imported from %s" ,
3194
- *module_path ,
3195
+ package_initial_file ,
3195
3196
*module_base);
3196
3197
}
3197
3198
0 commit comments