-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
feat: Allow resolving "ext:" modules from "ext:" or "node:" modules #369
feat: Allow resolving "ext:" modules from "ext:" or "node:" modules #369
Conversation
if specifier.starts_with("ext:") | ||
&& !referrer.starts_with("ext:") | ||
&& !referrer.starts_with("node:") | ||
&& referrer != "." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When would referrer
be .
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Referrer is "." when we are resolving top level specifier - in such case the specifier needs to be already resolved. It's a bit of code smell, but that code hasn't been touched in a couple years.
@@ -541,11 +569,14 @@ impl ModuleMap { | |||
referrer: &str, | |||
import_assertions: HashMap<String, String>, | |||
) -> Option<v8::Local<'s, v8::Module>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Follow-up for the future. Not for this PR, but it would be nice if this function was more rust-y and returned Result<Module, Error>
and we had an extra small shim function that would throw the error and return None.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, one question. Should be easy enough to slot in a custom callback.
A new "ModuleMap::resolve" function was added that is now used in
favor of directly calling "loader.resolve". This method performs additional
checks that prohibit resolution of "ext:" modules from modules that are not
"ext:" or "node:" modules.
This will allow us to sunset "RuntimeOptions::preserve_snapshotted_modules"
and will greatly help with #263 and denoland/deno#21422.
A bit different approach than suggested in the issue, but closes #363.