-
-
Notifications
You must be signed in to change notification settings - Fork 32.6k
Description
Is your feature request related to a problem? Please describe.
I am interested in having my scripts respond to arguments supplied by the calling file, rather than for the application as a whole (i.e., checking the likes of new URL(import.meta.url).searchParams.get('someParam')
rather than process.argv
).
This works well when a file imports another. In polyglot files too, it works to get the query string and hash in the browser (Chrome or Firefox at least) no matter whether the import originates in HTML or in JavaScript.
But I get a MODULE_NOT_FOUND
error when trying the likes of:
node --experimental-modules index.mjs?someParam=1
...apparently as it is looking for a file here rather than a (portion of) a URL.
Describe the solution you'd like
Allow the supplied file to be treated as a URL at least as far as the query string and any hash.
Describe alternatives you've considered
It duplicates effort to add special process.argv
handling (and it could interfere if the same file is used in an application which has a different root file yet checks process.argv
as well as import.meta.url
).
Thanks!