-
Notifications
You must be signed in to change notification settings - Fork 204
qjsc: find module based on path instead of script name #1194
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
base: master
Are you sure you want to change the base?
Conversation
Store the original file path in module_loader_opaque, let normalize function read from that and store a normalized filepath in context opaque, and make module loader read from the filepath from that. Make it possible to preserve the custom script name while resolving from another path.
It's not immediately obvious to me what this accomplishes. Or perhaps I should say: it's sort of obvious what it does, but not why (or when) that's useful. |
Useful if you want to strip the file path from compiled bytecode / make module resolution independent to script name & cwd Originally |
Okay, that makes sense on the face of it. The code in this PR is really fragile-looking though. Maybe there's a way to improve the module loader API to make that easier. What information do you need when? |
It's possible to remove the Set/GetRuntimeOpaque by making normalize return a struct. |
A while ago we added versions of JS_Eval and JS_EvalThis that take an extensible Having said that, I can't really gauge how broadly useful this feature is. I don't want to end up with something that only has a single user. In what real world scenario do you envision using it? |
I initially wrote this for the meson codegen PR, since |
@saghul is a feature like this useful for txiki.js? |
Store the original file path in module_loader_opaque, let normalize
function read from that and store a normalized filepath in context
opaque, and make module loader read from the filepath from that.
Make it possible to preserve the custom script name while resolving
from another path.
Split from #1187