@@ -11,24 +11,24 @@ We can fix this by allowing the C++ implementation of legacyMainResolve to use
1111a fileExists function that does take Asar into account.
1212
1313diff --git a/lib/internal/modules/esm/resolve.js b/lib/internal/modules/esm/resolve.js
14- index 185793fa305edbeab299f743e0018f34b2aaa655..b44eab420fe1bbec7ce34bde2ca4974b9d24a6dd 100644
14+ index beb3452ea134e4b408f8a3335a6cc65e97c8055a..a1c743cde5063a6ca504e8d2c32e9f2e13802cd9 100644
1515--- a/lib/internal/modules/esm/resolve.js
1616+++ b/lib/internal/modules/esm/resolve.js
1717@@ -28,11 +28,10 @@ const { BuiltinModule } = require('internal/bootstrap/realm');
1818 const fs = require('fs');
1919 const { getOptionValue } = require('internal/options');
2020 // Do not eagerly grab .manifest, it may be in TDZ
21- - const { sep, posix: { relative: relativePosixPath }, resolve } = require('path');
21+ - const { sep, posix: { relative: relativePosixPath }, resolve, join } = require('path');
2222- const { URL, pathToFileURL, fileURLToPath, isURL, URLParse } = require('internal/url');
23- + const { sep, posix: { relative: relativePosixPath }, toNamespacedPath, resolve } = require('path');
23+ + const { sep, posix: { relative: relativePosixPath }, toNamespacedPath, resolve, join } = require('path');
2424+ const { URL, pathToFileURL, fileURLToPath, isURL, URLParse, toPathIfFileURL } = require('internal/url');
2525 const { getCWDURL, setOwnProperty } = require('internal/util');
2626 const { canParse: URLCanParse } = internalBinding('url');
2727- const { legacyMainResolve: FSLegacyMainResolve } = internalBinding('fs');
2828 const {
2929 ERR_INPUT_TYPE_NOT_ALLOWED,
3030 ERR_INVALID_ARG_TYPE,
31- @@ -180 ,6 +179 ,11 @@ const legacyMainResolveExtensionsIndexes = {
31+ @@ -181 ,6 +180 ,11 @@ const legacyMainResolveExtensionsIndexes = {
3232 kResolvedByPackageAndNode: 9,
3333 };
3434
@@ -40,7 +40,7 @@ index 185793fa305edbeab299f743e0018f34b2aaa655..b44eab420fe1bbec7ce34bde2ca4974b
4040 /**
4141 * Legacy CommonJS main resolution:
4242 * 1. let M = pkg_url + (json main field)
43- @@ -198 ,7 +202 ,7 @@ function legacyMainResolve(packageJSONUrl, packageConfig, base) {
43+ @@ -199 ,7 +203 ,7 @@ function legacyMainResolve(packageJSONUrl, packageConfig, base) {
4444
4545 const baseStringified = isURL(base) ? base.href : base;
4646
@@ -50,10 +50,10 @@ index 185793fa305edbeab299f743e0018f34b2aaa655..b44eab420fe1bbec7ce34bde2ca4974b
5050 const maybeMain = resolvedOption <= legacyMainResolveExtensionsIndexes.kResolvedByMainIndexNode ?
5151 packageConfig.main || './' : '';
5252diff --git a/src/node_file.cc b/src/node_file.cc
53- index c46adc83d8542ae28c84b41821204b4608b1f34f..d828e7e78f9b41e053c306b01a71ad3ad847aaf6 100644
53+ index 126913185e0cd3e0e78cb2fb92177c9a8d9de044..5be1b553e29dbcc78c4bee1b778587ede6bc60f8 100644
5454--- a/src/node_file.cc
5555+++ b/src/node_file.cc
56- @@ -3648 ,13 +3648 ,25 @@ static void CpSyncCopyDir(const FunctionCallbackInfo<Value>& args) {
56+ @@ -3877 ,13 +3877 ,25 @@ static void CpSyncCopyDir(const FunctionCallbackInfo<Value>& args) {
5757 }
5858
5959 BindingData::FilePathIsFileReturnType BindingData::FilePathIsFile(
@@ -80,7 +80,7 @@ index c46adc83d8542ae28c84b41821204b4608b1f34f..d828e7e78f9b41e053c306b01a71ad3a
8080 uv_fs_t req;
8181
8282 int rc = uv_fs_stat(env->event_loop(), &req, file_path.c_str(), nullptr);
83- @@ -3712 ,6 +3724 ,11 @@ void BindingData::LegacyMainResolve(const FunctionCallbackInfo<Value>& args) {
83+ @@ -3941 ,6 +3953 ,11 @@ void BindingData::LegacyMainResolve(const FunctionCallbackInfo<Value>& args) {
8484 std::optional<std::string> initial_file_path;
8585 std::string file_path;
8686
@@ -92,7 +92,7 @@ index c46adc83d8542ae28c84b41821204b4608b1f34f..d828e7e78f9b41e053c306b01a71ad3a
9292 if (args.Length() >= 2 && args[1]->IsString()) {
9393 auto package_config_main = Utf8Value(isolate, args[1]).ToString();
9494
95- @@ -3732 ,7 +3749 ,7 @@ void BindingData::LegacyMainResolve(const FunctionCallbackInfo<Value>& args) {
95+ @@ -3961 ,7 +3978 ,7 @@ void BindingData::LegacyMainResolve(const FunctionCallbackInfo<Value>& args) {
9696 BufferValue buff_file_path(isolate, local_file_path);
9797 ToNamespacedPath(env, &buff_file_path);
9898
@@ -101,7 +101,7 @@ index c46adc83d8542ae28c84b41821204b4608b1f34f..d828e7e78f9b41e053c306b01a71ad3a
101101 case BindingData::FilePathIsFileReturnType::kIsFile:
102102 return args.GetReturnValue().Set(i);
103103 case BindingData::FilePathIsFileReturnType::kIsNotFile:
104- @@ -3769 ,7 +3786 ,7 @@ void BindingData::LegacyMainResolve(const FunctionCallbackInfo<Value>& args) {
104+ @@ -3998 ,7 +4015 ,7 @@ void BindingData::LegacyMainResolve(const FunctionCallbackInfo<Value>& args) {
105105 BufferValue buff_file_path(isolate, local_file_path);
106106 ToNamespacedPath(env, &buff_file_path);
107107
@@ -111,10 +111,10 @@ index c46adc83d8542ae28c84b41821204b4608b1f34f..d828e7e78f9b41e053c306b01a71ad3a
111111 return args.GetReturnValue().Set(i);
112112 case BindingData::FilePathIsFileReturnType::kIsNotFile:
113113diff --git a/src/node_file.h b/src/node_file.h
114- index c276a873f8516a5c7c6efcf8a400e07f78f92620..fe314d2a2c0fa9e2b71e12ae83b915c4314986a0 100644
114+ index 17f3b4203c8eddc8d050243d9cc26ba2ee61ff86..f2ae912dbe28f6165befb07f34c1dbf2430afce6 100644
115115--- a/src/node_file.h
116116+++ b/src/node_file.h
117- @@ -102 ,7 +102 ,8 @@ class BindingData : public SnapshotableObject {
117+ @@ -101 ,7 +101 ,8 @@ class BindingData : public SnapshotableObject {
118118 InternalFieldInfo* internal_field_info_ = nullptr;
119119
120120 static FilePathIsFileReturnType FilePathIsFile(Environment* env,
0 commit comments