-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
repl: fix referrer for dynamic import
The ESM loader does not accept a directory as the referrer, it requires a path within the directory. Add `/repl` to ensure relative dynamic imports can succeed. Fixes: #19570 PR-URL: #30609 Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ben Coe <[email protected]>
- Loading branch information
1 parent
6257408
commit b91d22c
Showing
2 changed files
with
29 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const cp = require('child_process'); | ||
const fixtures = require('../common/fixtures'); | ||
|
||
const args = ['--interactive', '--experimental-repl-await']; | ||
const opts = { cwd: fixtures.path('es-modules') }; | ||
const child = cp.spawn(process.execPath, args, opts); | ||
|
||
let output = ''; | ||
child.stdout.setEncoding('utf8'); | ||
child.stdout.on('data', (data) => { | ||
output += data; | ||
}); | ||
|
||
child.on('exit', common.mustCall(() => { | ||
const results = output.replace(/^> /mg, '').split('\n').slice(2); | ||
assert.deepStrictEqual(results, ['[Module] { message: \'A message\' }', '']); | ||
})); | ||
|
||
child.stdin.write('await import(\'./message.mjs\');\n'); | ||
child.stdin.write('.exit'); | ||
child.stdin.end(); |