fix: package import existence verification (#46022)

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
trop[bot] 2025-03-14 09:58:01 +01:00 committed by GitHub
parent 11fad1b737
commit 02783dd1e0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 3 deletions

View file

@ -53,7 +53,7 @@ index 2879e5cf541fb4d226cfd7cc0fe367ca448fb926..03082f0ec4f91382933eec48e77331cd
const maybeMain = resolvedOption <= legacyMainResolveExtensionsIndexes.kResolvedByMainIndexNode ?
packageConfig.main || './' : '';
diff --git a/src/node_file.cc b/src/node_file.cc
index 1d22e19f16d5ad82466b0724971b2e4a685682f7..9619d10710ffbbdc73fa7d59d1b797c8d0b3a956 100644
index 1d22e19f16d5ad82466b0724971b2e4a685682f7..3d7e303741a73134e140152bed637fe5ae8bc1db 100644
--- a/src/node_file.cc
+++ b/src/node_file.cc
@@ -3220,13 +3220,25 @@ static void CpSyncCheckPaths(const FunctionCallbackInfo<Value>& args) {
@ -73,7 +73,7 @@ index 1d22e19f16d5ad82466b0724971b2e4a685682f7..9619d10710ffbbdc73fa7d59d1b797c8
+ env->isolate(), file_path.c_str(), v8::NewStringType::kNormal)
+ .ToLocalChecked()};
+ MaybeLocal<Value> maybe_is_file = is_file_function->Call(env->context(), v8::Undefined(env->isolate()), 1, argv);
+ if (maybe_is_file.IsEmpty()) {
+ if (!maybe_is_file.IsEmpty()) {
+ bool is_file = maybe_is_file.ToLocalChecked()->BooleanValue(env->isolate());
+ return is_file ? BindingData::FilePathIsFileReturnType::kIsFile
+ : BindingData::FilePathIsFileReturnType::kIsNotFile;

View file

@ -40,7 +40,7 @@ index 0f0cde7be431dcb80c5314b1a9da49886c436d1c..f6d2bd439cad8b9f91c9d9a6cdb302e6
}
HistogramBase* histogram;
diff --git a/src/node_file.cc b/src/node_file.cc
index 9619d10710ffbbdc73fa7d59d1b797c8d0b3a956..f2a5c0939b60c582dbbecc07add1e903a9183b95 100644
index 3d7e303741a73134e140152bed637fe5ae8bc1db..5e744bc34b9dc364e8f20adfd37ee41d76451170 100644
--- a/src/node_file.cc
+++ b/src/node_file.cc
@@ -1061,13 +1061,8 @@ static int32_t FastInternalModuleStat(