-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Launching main ESM module with search
and hash
#49204
Comments
There's of course the possibility of doing 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: import {env} from 'node:process';
export async function resolve(spec, context, next) {
const result = await next(spec, context);
if (!context.parentURL) {
if ('ENTRY_POINT_SEARCH' in env)
result.url += `?${env.ENTRY_POINT_SEARCH}`;
if ('ENTRY_POINT_HASH' in env)
result.url += `#${env.ENTRY_POINT_HASH}`;
}
return result
} |
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. |
Adapted the Loader Hooks API idea to an executable script that allows to Opened draft PR with an option to load ES module by URL with user-provided |
@nodejs/loaders @nodejs/modules |
I don’t know why this is here, but the MDN documentation for
|
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. 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. For more information on how the project manages feature requests, please consult the feature request management document. |
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? |
There has been no activity on this feature request for 5 months. To help maintain relevant open issues, please add the
never-stale
|
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. |
What is the problem this feature will solve?
We can provide query and hash in ESM imports:
However, AFAICT there is no way to provide them directly to main module:
What is the feature you are proposing to solve the problem?
Command line option(s) to provide
search
andhash
, e.g.What alternatives have you considered?
Right now we can do this with empty script:
Which
import.meta.isMain
process.argv
becauseprocess.argv[1]
will contain first argument instead of path to2.mjs
.
or..
, and to use forward slashes on WindowsThe text was updated successfully, but these errors were encountered: