Skip to content

Commit 16f880a

Browse files
authored
Only include nodePath when needed (#24369)
This was generated by looking at the eslint warning for our generated JS code. See #24368
1 parent 6d0e4a8 commit 16f880a

File tree

91 files changed

+95
-95
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+95
-95
lines changed

src/lib/libnodepath.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
// operations. Hence, using `nodePath` should be safe here.
1313

1414
addToLibrary({
15+
$nodePath: "require('path')",
16+
$PATH__deps: ['$nodePath'],
1517
$PATH: `{
1618
isAbs: nodePath.isAbsolute,
1719
normalize: nodePath.normalize,
@@ -22,7 +24,7 @@ addToLibrary({
2224
}`,
2325
// The FS-using parts are split out into a separate object, so simple path
2426
// usage does not require the FS.
25-
$PATH_FS__deps: ['$FS'],
27+
$PATH_FS__deps: ['$FS', '$nodePath'],
2628
$PATH_FS__docs: '/** @type{{resolve: function(...*)}} */',
2729
$PATH_FS: {
2830
resolve: (...paths) => {

src/shell.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ if (ENVIRONMENT_IS_PTHREAD) {
110110
#endif
111111
#endif
112112

113-
#if ENVIRONMENT_MAY_BE_NODE
113+
#if ENVIRONMENT_MAY_BE_NODE && (EXPORT_ES6 || PTHREADS || WASM_WORKERS)
114114
if (ENVIRONMENT_IS_NODE) {
115115
#if EXPORT_ES6
116116
// When building an ES module `require` is not normally available.
@@ -201,7 +201,6 @@ if (ENVIRONMENT_IS_NODE) {
201201
var nodeVersion = process.versions.node;
202202
var numericVersion = nodeVersion.split('.').slice(0, 3);
203203
numericVersion = (numericVersion[0] * 10000) + (numericVersion[1] * 100) + (numericVersion[2].split('-')[0] * 1);
204-
var minVersion = {{{ MIN_NODE_VERSION }}};
205204
if (numericVersion < {{{ MIN_NODE_VERSION }}}) {
206205
throw new Error('This emscripten-generated code requires node {{{ formattedMinNodeVersion() }}} (detected v' + nodeVersion + ')');
207206
}
@@ -210,11 +209,10 @@ if (ENVIRONMENT_IS_NODE) {
210209
// These modules will usually be used on Node.js. Load them eagerly to avoid
211210
// the complexity of lazy-loading.
212211
var fs = require('fs');
213-
var nodePath = require('path');
214212

215213
#if EXPORT_ES6
216214
if (_scriptName.startsWith('file:')) {
217-
scriptDirectory = nodePath.dirname(require('url').fileURLToPath(_scriptName)) + '/';
215+
scriptDirectory = require('path').dirname(require('url').fileURLToPath(_scriptName)) + '/';
218216
}
219217
#else
220218
scriptDirectory = __dirname + '/';
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8184
1+
8179
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
19848
1+
19832
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8173
1+
8169
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
19826
1+
19810
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
9181
1+
9175
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
23585
1+
23569
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8133
1+
8128
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
19741
1+
19725

0 commit comments

Comments
 (0)