GeezerVison is showing github.com — repl: do not define `wasi` on global with no flag · nodejs/node@b999983
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: lib/internal/main/repl.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
|
8 | 8 | markBootstrapComplete |
9 | 9 | } = require('internal/process/pre_execution'); |
10 | 10 |
|
11 | | -const esmLoader = require('internal/process/esm_loader'); |
12 | 11 | const { |
13 | 12 | evalScript |
14 | 13 | } = require('internal/process/execution'); |
@@ -34,6 +33,7 @@ if (process.env.NODE_REPL_EXTERNAL_MODULE) { |
34 | 33 | process.exit(1); |
35 | 34 | } |
36 | 35 |
|
| 36 | + const esmLoader = require('internal/process/esm_loader'); |
37 | 37 | esmLoader.loadESM(() => { |
38 | 38 | console.log(`Welcome to Node.js ${process.version}.\n` + |
39 | 39 | 'Type ".help" for more information.'); |
|
Collapse file
Copy file name to clipboardExpand all lines: test/parallel/test-repl-built-in-modules.js +16Lines changed: 16 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -30,3 +30,19 @@ assert.doesNotMatch( |
30 | 30 | stdout, |
31 | 31 | /Uncaught Error: Cannot find module 'wasi'[\w\W]+- <repl>\n/); |
32 | 32 | 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 | +} |