| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,7 +9,10 @@ const { | |||
| 9 | 9 | ERR_MISSING_DYNAMIC_INSTANTIATE_HOOK, | |
| 10 | 10 | ERR_UNKNOWN_MODULE_FORMAT | |
| 11 | 11 | } = require('internal/errors').codes; | |
| 12 | - const { URL } = require('url'); | ||
| 12 | + const { | ||
| 13 | + URL, | ||
| 14 | + pathToFileURL | ||
| 15 | + } = require('url'); | ||
| 13 | 16 | const { validateString } = require('internal/validators'); | |
| 14 | 17 | const ModuleMap = require('internal/modules/esm/module_map'); | |
| 15 | 18 | const ModuleJob = require('internal/modules/esm/module_job'); | |
@@ -107,7 +110,10 @@ class Loader { | |||
| 107 | 110 | return { url, format }; | |
| 108 | 111 | } | |
| 109 | 112 | ||
| 110 | - async eval(source, url = `eval:${++this.evalIndex}`) { | ||
| 113 | + async eval( | ||
| 114 | + source, | ||
| 115 | + url = pathToFileURL(`${process.cwd()}/[eval${++this.evalIndex}]`).href | ||
| 116 | + ) { | ||
| 111 | 117 | const evalInstance = async (url) => { | |
| 112 | 118 | return { | |
| 113 | 119 | module: new ModuleWrap(source, url), | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,7 +1,7 @@ | |||
| 1 | 1 | Error: 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) | ||
| 4 | 4 | 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( | |||
| 274 | 274 | assert.ifError(err); | |
| 275 | 275 | assert.strictEqual(stdout, 'object\n'); | |
| 276 | 276 | })); | |
| 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 | + })); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments