Skip to content

Commit b999983

Browse files
cola119danielleadams
authored andcommitted
repl: do not define wasi on global with no flag
PR-URL: #45595 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent ebc89f1 commit b999983

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/internal/main/repl.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ const {
88
markBootstrapComplete
99
} = require('internal/process/pre_execution');
1010

11-
const esmLoader = require('internal/process/esm_loader');
1211
const {
1312
evalScript
1413
} = require('internal/process/execution');
@@ -34,6 +33,7 @@ if (process.env.NODE_REPL_EXTERNAL_MODULE) {
3433
process.exit(1);
3534
}
3635

36+
const esmLoader = require('internal/process/esm_loader');
3737
esmLoader.loadESM(() => {
3838
console.log(`Welcome to Node.js ${process.version}.\n` +
3939
'Type ".help" for more information.');

test/parallel/test-repl-built-in-modules.js

+16
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,19 @@ assert.doesNotMatch(
3030
stdout,
3131
/Uncaught Error: Cannot find module 'wasi'[\w\W]+- <repl>\n/);
3232
assert.match(stdout, /{ WASI: \[class WASI\] }/);
33+
34+
{
35+
const res = cp.execFileSync(process.execPath, ['-i'], {
36+
input: "'wasi' in global",
37+
encoding: 'utf8',
38+
});
39+
// `wasi` shouldn't be defined on global when the flag is not set
40+
assert.match(res, /false\n/);
41+
}
42+
{
43+
const res = cp.execFileSync(process.execPath, ['-i', '--experimental-wasi-unstable-preview1'], {
44+
input: "'wasi' in global",
45+
encoding: 'utf8',
46+
});
47+
assert.match(res, /true\n/);
48+
}

0 commit comments

Comments
 (0)