-
-
Notifications
You must be signed in to change notification settings - Fork 400
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
Create a new Specifier type for JavaScript module specifiers #3818
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3818 +/- ##
==========================================
+ Coverage 47.24% 50.41% +3.16%
==========================================
Files 476 460 -16
Lines 46892 45179 -1713
==========================================
+ Hits 22154 22776 +622
+ Misses 24738 22403 -2335 ☔ View full report in Codecov by Sentry. |
I'm trying to think about the implications of always having absolute paths for modules and scripts. Right now, I can think of:
Committing to absolute paths would be very bad for both use cases. Maybe we can just change specifiers to store a |
Absolute to the root of the (very much virtual) namespace, not their filesystems.
This would be done using the Basically what I'm saying is:
This is a very powerful statement, and would allow optimizations that are host independent, such as having a module cache outside of module loader, for example. And to avoid further confusion, what I mean by "absolute |
What would be the overall changes to |
|
Could be in |
This discussion is getting a bit too long for a PR, and I wanted to ask some more questions about the API. I'll open a thread in Matrix. |
This PR does not change any of the current API. I wanted to see if people preferred doing it as part of this PR (thus larger in scope), or doing a review of this new type, then as a follow up update the related APIs.
My thoughts after playing with modules;
import './path'
resolving to/some/path.js
(see below), should show up in traces as/some/path.js
. This would be part of the follow up PR.RevoledSpecifier
or something which is guaranteed at creation to be absolute and resolved. It canDeref<Specifier>
orDeref<OwnedSpecifier>
. That way the type system will make sure you cannot create a module with a relative path (relative to what?!?). When creating a module, you need to pass a referrer or a resolved specifier.Some extra curricular suggestions:
NodeModuleResolver
that doesn't have to also be a loader would be good.ModuleLoader::get_module
, and that this method be implemented correctly.