-
Notifications
You must be signed in to change notification settings - Fork 44
Discussion about an implicit (or explicit) "node" scheme #169
Comments
Absolutely, which is more ambiguously than
Certainly, those are merely conceptual schemes for design purposes (and possibly internal resolution algorithms). The only time you would need to explicitly refer to |
strong -1 on |
@devsnek that |
node
scheme
I don't think it's likely that |
@ljharb so I've thought about this for a while and wanted to push this discussion further but with more clarity. Assume for a moment that I not proposing that So this whole direction of the discussion about supporting or not protocols in node files has nothing to do with my intent. Let's try extra hard to not let hot topics overshadow seemingly related issues which can be very critical. Can you clarify if you are just against the node resolving part (which is not the intent) and if not, are you against specifiers being URLs in general? I am just trying to relay my own thinking to steer the conversation in a more productive path. |
Although anyone will be able to use loaders and transpilers to use any specifier they want - I’m against node having specifiers work by default. Every path in node is file:// and so does not need an explicit protocol, http/https URLs would be dangerous imo (altho these might end up being acceptable), and i don’t see the benefit of adding additional protocols. A protocol talks about how you access the format - but not what the format is. What access method needs disambiguation here? (In addition, I’m firmly against encoding the module format anywhere but in the module itself - either in its contents (altho this won’t work for JS scripts vs modules), in its filename (ie, it’s extension), or in “closest package.json” metadata that overrides one of those two options) |
Again, that is all besides the points I am trying to raise. And as far as node is concerned, I don't think I disagree with your logic.
This imho is where I might be able to articulate my thinking better. My version of this is more like "while every path in node is file:// and so does not need an explicit protocol" not every specifier is a path.
For instance, bare specifiers are not a path nor a URL until they are resolved by node's ESM subsystem to a file in some package. More importantly though, bare specifiers that resolve to a dynamic module instance, including at the very least every single builtin module, not to mention all non-esm if you consider the --experimental-modules implementation, those are not paths, but they are resources, just like blobs are resources, and they too have a scheme. But here is where this all matters from my point of view, and @demurgos's example is spot on, we should not just be focusing on specifiers from the resolution aspect (not touching this one), we should also consider how they interoperate at the very least inside the parent runtime, which happens to be v8/chrome+webkit, possible chakra... and so on. This is just conceptual, not implementational. |
I could certainly see the internal - not user-visible - use of an implicit node:// protocol on bare specifiers, just like resolved file paths might have file:// and source text modules might have another protocol. However, i wouldn’t want users to be able by default to have two ways to represent a specifier to the same module (noting that |
absolutely, my own thinking too, the source text specifier An instantiated module "node:process" in an electron app for instance, is only accessible by an ES module when the source text is requiring or importing "process". It cannot be accessed from a |
@devsnek I know, I blame you for all this discussion. If I did not see this, I think I would have remained relatively ignorant of the notion of the ModuleWrap's My concerns are with all other non-path ModuleWraps (dynamic modules like cjs) and how a simple spinoff on "node:builtins" which do not factor into node's ESM resolution at all, could potentially prevent conflicting coercions or assumptions in other realms of node's own ecosystem (for instance Electron & NW.js) |
@SMotaal the implementation has a lot of freedom about what it does for specifiers. the only we have is that our specifiers must be valid javascript strings. we currently use urls because they're nice generic interface for saying where something came from, but we can change it to be anything we want. |
That's true, and we usually aim for what is best for everyone involved in the ecosystem. Which is why I think node should be a little more clear (at least in concept) about why specifiers (aside from relative paths to specific files) make sense, which can happen if we align them to the theoretical of a scheme, now we tell someone who has no trouble understanding URLs and for all intents and purposes has associated specifiers with relative or absolute URLs, that a specifier resolved by node is a little different from If I see URLs, and everyone tells me URLs, the browser says URLs, node tells me special characters (or windows path aspects) are not valid (ie expects proper file:// syntax), and I am quite the expert in my own domain, I even lookup the specs, but not necessarily in node's own story with modules… This guy really wants your help, and making sure that our implementation (which does not resolve |
I will somewhat proactively reiterate that this is simply conceptual, it will affect how look at things and on the very rare occasion may influence some design choices, but in no way am I associating this with the idea that node will resolve |
I am hoping we can discuss this in our next meeting regarding:
|
The next meeting overlaps with TC39, so a number of us will be unable to attend. It may need to wait until the following meeting. |
In that case, we would have a casual discussion and hold the more formal one next meeting. |
So are we meeting this week? If not, can that be announced somewhere? I potentially have big plans for Wednesday at noon Pacific! 😋 |
One reason I have been playing with a |
It seems like it puts the necessity of knowing the module format in the hands of the consumer, which a number of us find unacceptable. |
Not necessarily, depending on where it appears and how it's used. It can be used 100% internally for developer tooling niceness. |
@jkrems we might need to give it a more generic term, for things like WASM you can see existing implementations that load modules that are compiled to source text module records. The problem of modules being facades is not limited to CJS. |
Yeah, there's various overlapping concerns ("bridge module", "reflection util module", "not actually a file but compiled into node as a built-in"). For WASM my current assumption/hope is that it would end up as a "true" module in V8 because it would actually run as a module and should support linking etc.. But that's pending additional work that we don't (directly) control. EDIT: Added the example of node built-in as a protocol reason. |
Can this be removed from the agenda? |
I think it needs to be addressed down the road... So I'll remove the label, but keep it open please. |
Can this be closed? |
I don't know @MylesBorins… If The concepts of But I really think this discussion is best punted for the time being. Do we close and reopen? |
Namespace discussions are still quite premature / early. closing for now. |
This compliments #168 with a more open discussion about the notion of assuming an implicit (or explicit)
node
scheme which builds on the existing internal/implicit use ofnode:
in experimental-modules.This thread opens the discussion about the notion that a theoretical (or experimental) Node.js ESM loader can be considered the one and only implementation for a
node+file:
scheme.Other schemes which are not supported by such a loader (like
node+https:
) can still be valid schemes that live in the realm of other platforms like Electron, or handled by third-party handlers that may or may not interface with node's own loader.The text was updated successfully, but these errors were encountered: