File tree Expand file tree Collapse file tree 3 files changed +22
-7
lines changed Expand file tree Collapse file tree 3 files changed +22
-7
lines changed Original file line number Diff line number Diff line change 99 ERR_MISSING_DYNAMIC_INSTANTIATE_HOOK ,
1010 ERR_UNKNOWN_MODULE_FORMAT
1111} = require ( 'internal/errors' ) . codes ;
12- const { URL } = require ( 'url' ) ;
12+ const {
13+ URL ,
14+ pathToFileURL
15+ } = require ( 'url' ) ;
1316const { validateString } = require ( 'internal/validators' ) ;
1417const ModuleMap = require ( 'internal/modules/esm/module_map' ) ;
1518const ModuleJob = require ( 'internal/modules/esm/module_job' ) ;
@@ -107,7 +110,10 @@ class Loader {
107110 return { url, format } ;
108111 }
109112
110- async eval ( source , url = `eval:${ ++ this . evalIndex } ` ) {
113+ async eval (
114+ source ,
115+ url = pathToFileURL ( `${ process . cwd ( ) } /[eval${ ++ this . evalIndex } ]` ) . href
116+ ) {
111117 const evalInstance = async ( url ) => {
112118 return {
113119 module : new ModuleWrap ( source , url ) ,
Original file line number Diff line number Diff line change 11Error: test
2- at one (eval:1 :2:9)
3- at two (eval:1 :15:9)
2+ at one (file:*/[eval1] :2:9)
3+ at two (file:*/[eval1] :15:9)
44 at processTicksAndRejections (internal/process/task_queues.js:*:*)
5- at async three (eval:1 :18:3)
6- at async four (eval:1 :22:3)
7- at async main (eval:1 :28:5)
5+ at async three (file:*/[eval1] :18:3)
6+ at async four (file:*/[eval1] :22:3)
7+ at async main (file:*/[eval1] :28:5)
Original file line number Diff line number Diff line change @@ -274,3 +274,12 @@ child.exec(
274274 assert . ifError ( err ) ;
275275 assert . strictEqual ( stdout , 'object\n' ) ;
276276 } ) ) ;
277+
278+ // Assert that packages can be imported cwd-relative with --eval
279+ child . exec (
280+ `${ nodejs } ${ execOptions } ` +
281+ '--eval "import \'./test/fixtures/es-modules/mjs-file.mjs\'"' ,
282+ common . mustCall ( ( err , stdout ) => {
283+ assert . ifError ( err ) ;
284+ assert . strictEqual ( stdout , '.mjs file\n' ) ;
285+ } ) ) ;
You can’t perform that action at this time.
0 commit comments