Create a new Specifier type for JavaScript module specifiers#3818
Create a new Specifier type for JavaScript module specifiers#3818hansl wants to merge 1 commit intoboa-dev:mainfrom
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. 🚀 New features to boost your workflow:
|
|
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.RevoledSpecifieror 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:
NodeModuleResolverthat doesn't have to also be a loader would be good.ModuleLoader::get_module, and that this method be implemented correctly.