You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Launching main ESM module with search and hash #49204
There's of course the possibility of doing node --input-type=module -e 'import "./2.mjs?key=value#hash"', although it would also not help with import.meta.main and the other things you listed.
I think that's something Loader Hooks API can already provide, and for that reason, I don't think we should add flags for this. Here's an example of a loader that would do what you want using env variable:
It'd be great to have a feature like this. Ideally users shouldn't have to meddle with hooks to get the full flexibility of ESM.
There's similar questions of what Node can do on it's own (batteries-included) versus what a loader api might be able to do (do it yourself) in #34049. I keep hoping Node will just make ESM stuff directly supported.
The ES module implementation in Node.js supports resolving module specifiers containing query parameters (or the hash), as in the latter example. However, you cannot use queries or hashes when the module is specified through the CLI command (like node index.mjs?someURLInfo=5), because the CLI entrypoint uses a more CommonJS-like resolution mode, treating the path as a file path rather than a URL. To pass parameters to the entrypoint module, use CLI arguments and read them through process.argv instead (like node index.mjs --someURLInfo=5).
I don't see anything wrong with this note on MDN page: it correctly describes this limitation and suggests workaround for those who want to implement something similar in Node.js-specific way. import.meta page is correct place to have it, because import.meta.url is the mechanism to retrieve these parameters.
If this issue gets fixed, the MDN page should be updated accordingly.
There has been no activity on this feature request for 5 months and it is unlikely to be implemented. It will be closed 6 months after the last non-automated comment.
There has been no activity on this feature request for 5 months. To help maintain relevant open issues, please add the
never-staleIssues and PRs exempt from automated stale handling.
label or close this issue if it should be closed. If not, the issue will be automatically closed 6 months after the last non-automated comment.
For more information on how the project manages feature requests, please consult the feature request management document.
There has been no activity on this feature request and it is being closed. If you feel closing this issue is not the right thing to do, please leave a comment.
Activity
aduh95 commentedon Aug 17, 2023
There's of course the possibility of doing
node --input-type=module -e 'import "./2.mjs?key=value#hash"', although it would also not help withimport.meta.mainand the other things you listed.I think that's something Loader Hooks API can already provide, and for that reason, I don't think we should add flags for this. Here's an example of a loader that would do what you want using env variable:
pinko-fowle commentedon Aug 22, 2023
It'd be great to have a feature like this. Ideally users shouldn't have to meddle with hooks to get the full flexibility of ESM.
There's similar questions of what Node can do on it's own (batteries-included) versus what a loader api might be able to do (do it yourself) in #34049. I keep hoping Node will just make ESM stuff directly supported.
LiviaMedeiros commentedon Aug 23, 2023
Adapted the Loader Hooks API idea to an executable script that allows to
$ launchByURL file.mjs?qwe=rty#uiodirectly: https://gist.github.com/LiviaMedeiros/76a553a86db90878121e58be65834eb3Opened draft PR with an option to load ES module by URL with user-provided
searchandhashas$ node --module file.mjs?qwe=rty#uio: #49295GeoffreyBooth commentedon Aug 23, 2023
@nodejs/loaders @nodejs/modules
GeoffreyBooth commentedon Aug 23, 2023
I don’t know why this is here, but the MDN documentation for
import.metadiscusses this:LiviaMedeiros commentedon Aug 24, 2023
I don't see anything wrong with this note on MDN page: it correctly describes this limitation and suggests workaround for those who want to implement something similar in Node.js-specific way.
import.metapage is correct place to have it, becauseimport.meta.urlis the mechanism to retrieve these parameters.If this issue gets fixed, the MDN page should be updated accordingly.
github-actions commentedon Feb 21, 2024
There has been no activity on this feature request for 5 months and it is unlikely to be implemented. It will be closed 6 months after the last non-automated comment.
For more information on how the project manages feature requests, please consult the feature request management document.
pinko-fowle commentedon Feb 21, 2024
I'd love to see this.
Someone ought to bring this up with WinterCG. They're more server-focused than script-focused, but perhaps they'll bite?
github-actions commentedon Aug 20, 2024
There has been no activity on this feature request for 5 months. To help maintain relevant open issues, please add the never-staleIssues and PRs exempt from automated stale handling.
label or close this issue if it should be closed. If not, the issue will be automatically closed 6 months after the last non-automated comment.
For more information on how the project manages feature requests, please consult the feature request management document.
github-actions commentedon Sep 19, 2024
There has been no activity on this feature request and it is being closed. If you feel closing this issue is not the right thing to do, please leave a comment.
For more information on how the project manages feature requests, please consult the feature request management document.