-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
esm: Make custom loaders specific #21415
Comments
Hiya @viktor-ku , The Modules WG is currently reviewing things and Loader are subject a potentially large refactor to how they work. I'm going to try and make a meeting explicitly on loaders nodejs/modules#135 and would love if you have any input you can offer. CC: @nodejs/modules I will state that in #18914 I designed it not around a separate |
@viktor-ku you can just do export async function resolve(specifier, parentModule, defaultResolve) {
if (!specifier.startsWith('https:')) {
return defaultResolve(specifier, parentModule);
}
// handle your own stuff here
} |
I think that adding a separate A possible benefit for having the test defined outside of In short, a |
@demurgos Yeah. I guess my idea is not great so I am closing this issue. Thanks everyone ❤️ |
Hello, folks!
The whole story with ESM HTTPS Modules got me to a point where I am about to write custom loader for node. And I have one little issue with it (but maybe I am wrong?). I need to write a loader that will handle the whole import process of all types (builting, external .js, etc.)?
Why can't I write one specific loader that will extend node.js import policy rather than replace it?
If I could I'd like to write my specific loader like this:
node-https-loader.js
:In addition to
resolve
function we havetest
also. With the latter we can test thespecifier
to see if it can be resolved with the given loader.To optimize loading time any custom loaders could be tested after builtin modules, relative files, absolute files, checks.
This approach could give developers flexibility to use multiple custom loaders (e.g.
yml
andhttps
at the same time)I know that it breaks existing loaders idea but maybe we can do something about it?
If you like this idea I can invest my time to create PR
Thanks,
Viktor Ku
The text was updated successfully, but these errors were encountered: