1
1
diff --git a/lib/internal/bootstrap/node.js b/lib/internal/bootstrap/node.js
2
- index 885546c5d6..f1287bb191 100644
2
+ index 885546c5d6..f21e7993f1 100644
3
3
--- a/lib/internal/bootstrap/node.js
4
4
+++ b/lib/internal/bootstrap/node.js
5
5
@@ -215,11 +215,16 @@
6
6
// are running from a script and running the REPL - but there are a few
7
7
// others like the debugger or running --eval arguments. Here we decide
8
- // which mode we run in.
8
+ // which mode we run in.
9
9
+
10
10
+ if (NativeModule.exists('_third_party_main')) {
11
11
+ NativeModule.require('_third_party_main');
@@ -21,7 +21,7 @@ index 885546c5d6..f1287bb191 100644
21
21
// one to drop a file lib/_third_party_main.js into the build
22
22
// directory which will be executed instead of Node's normal loading.
23
23
diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js
24
- index fb3770b729..eb65385afe 100644
24
+ index fb3770b729..9e210090e5 100644
25
25
--- a/lib/internal/modules/cjs/loader.js
26
26
+++ b/lib/internal/modules/cjs/loader.js
27
27
@@ -44,6 +44,9 @@ const { getOptionValue } = require('internal/options');
@@ -101,17 +101,19 @@ index fb3770b729..eb65385afe 100644
101
101
try {
102
102
module.exports = JSON.parse(stripBOM(content));
103
103
} catch (err) {
104
- @@ -715,7 +742,14 @@ Module._extensions['.json'] = function(module, filename) {
104
+ @@ -715,7 +742,16 @@ Module._extensions['.json'] = function(module, filename) {
105
105
106
106
// Native extension for .node
107
107
Module._extensions['.node'] = function(module, filename) {
108
108
- return process.dlopen(module, path.toNamespacedPath(filename));
109
109
+ let isInternal = false;
110
110
+ if (nbin.existsSync(filename)) {
111
- + const tmpFile = path.join(os.tmpdir(), `.nbin-${path.basename(filename)}`);
112
- + fs.writeFileSync(tmpFile, nbin.readFileSync(filename));
113
- + filename = tmpFile;
114
- + isInternal = true;
111
+ + const tmpFile = path.join(os.tmpdir(), `.nbin${nbin.version}-${path.basename(filename)}`);
112
+ + if (!fs.existsSync(tmpFile)) {
113
+ + fs.writeFileSync(tmpFile, nbin.readFileSync(filename));
114
+ + }
115
+ + filename = tmpFile;
116
+ + isInternal = true;
115
117
+ }
116
118
+ return process.dlopen(module, isInternal ? filename : path.toNamespacedPath(filename));
117
119
};
0 commit comments