mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
49fb529139
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: https://github.com/nodejs/node/issues/19570 PR-URL: https://github.com/nodejs/node/pull/30609 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ben Coe <bencoe@gmail.com>
25 lines
747 B
JavaScript
25 lines
747 B
JavaScript
'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();
|