@@ -25,18 +25,15 @@ diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loade
2525index 92554a374d189b3b284546b0e122940e9a175de8..e478c57af873da717c00db73d6719f806280efe1 100644
2626--- a/lib/internal/modules/cjs/loader.js
2727+++ b/lib/internal/modules/cjs/loader.js
28- @@ -55,10 +55,7 @@ const assert = require('internal/assert');
28+ @@ -55,7 +55,7 @@ const assert = require('internal/assert');
2929 const fs = require('fs');
3030 const internalFS = require('internal/fs/utils');
3131 const path = require('path');
32- - const {
33- - internalModuleReadJSON,
34- - internalModuleStat
35- - } = internalBinding('fs');
32+ - const { internalModuleStat } = internalBinding('fs');
3633+ const internalFsBinding = internalBinding('fs');
34+ const packageJsonReader = require('internal/modules/package_json_reader');
3735 const { safeGetenv } = internalBinding('credentials');
3836 const {
39- makeRequireFunction,
4037@@ -144,14 +141,12 @@ function enrichCJSError(err) {
4138 }
4239
@@ -53,12 +50,26 @@ index 92554a374d189b3b284546b0e122940e9a175de8..e478c57af873da717c00db73d6719f80
5350 if (statCache !== null) statCache.set(filename, result);
5451 return result;
5552 }
56- @@ -257,7 +252,7 @@ function readPackage(requestPath) {
57- const existing = packageJsonCache.get(jsonPath);
58- if (existing !== undefined) return existing;
53+ diff --git a/lib/internal/modules/package_json_reader.js b/lib/internal/modules/package_json_reader.js
54+ index 066047b55eb9d82bc1eea66dc54aa68abd116b6b..4fcc65e235692d7d5fe2643571f006c593c4e173 100644
55+ --- a/lib/internal/modules/package_json_reader.js
56+ +++ b/lib/internal/modules/package_json_reader.js
57+ @@ -1,7 +1,7 @@
58+ 'use strict';
5959
60- - const json = internalModuleReadJSON(path.toNamespacedPath(jsonPath));
61- + const json = internalFsBinding.internalModuleReadJSON(path.toNamespacedPath(jsonPath));
62- if (json === undefined) {
63- packageJsonCache.set(jsonPath, false);
64- return false;
60+ const { SafeMap } = primordials;
61+ - const { internalModuleReadJSON } = internalBinding('fs');
62+ + const internalFsBinding = internalBinding('fs');
63+
64+ const cache = new SafeMap();
65+
66+ @@ -14,7 +14,7 @@ function read(path) {
67+ return cache.get(path);
68+ }
69+
70+ - const [string, containsKeys] = internalModuleReadJSON(path);
71+ + const [string, containsKeys] = internalFsBinding.internalModuleReadJSON(path);
72+ const result = { string, containsKeys };
73+ cache.set(path, result);
74+ return result;
75+
0 commit comments