Skip to content

Commit 7892e23

Browse files
cola119targos
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 3a02d50 commit 7892e23

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/internal/main/repl.js

Lines changed: 1 addition & 1 deletion
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');
@@ -37,6 +36,7 @@ if (process.env.NODE_REPL_EXTERNAL_MODULE) {
3736
process.exit(kGenericUserError);
3837
}
3938

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

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

Lines changed: 16 additions & 0 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy