-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
fix(hmr): dedupe virtual modules in module graph #10144
Conversation
So good that you did the refactoring, that will simplify discussions. What I'm worried about doing the unwrapping at
This was in the context of the same problem but for |
Interesting, I thought the term "url" and "id" meant "browser URL" and "rollup URL" respectively. In that path specifiers in browsers is called "url", while in Rollup it's called "id". Since in the module graph, we have
I also thought that we want I'm not so sure about having Back to this PR and I also pushed a commit to fix this logic since I was incorrectly unwrapping the resolved URL where it shouldn't. |
What we have is:
It is named
It is the other way around. You can see here in the TransformMiddleware. As soon as we get the request, we unwrap it (going back to having a Current use of
See here:
|
Ah I see your point now, it's... confusing but I think we know that now 😄 I guess another thing to note for the module graph So back to
I still think Instead I think we should try to find where Rollup-space URLs are passed and prevent that further forward as this distinction wasn't clear in the past. Re |
And I think we're still not there... maybe we should get in a call on Monday 😅
I think that
But this isn't the case,
This is a big change, as we are using Rollup-space URLs everywhere now (except when writing an import path that is meant to be read by the browser). IIUC, what we should make sure of is that we use Rollup-space URL everywhere and we only go to Browser-space on the limits of the server when the browser is going to read these ids (this is why we convert to Rollup-space URL in the transform middleware plugin)
|
Perhaps you're right, it looks like the resolve plugin handles this when passed as an id too. I think I understand your point now and I could implement that too, but maybe we should get Evan's thoughts first so we don't accidentally re-define what |
/ecosystem-ci run |
📝 Ran ecosystem CI: Open
|
Looks like this PR passes ecosystem-ci. Laravel and Storybook is currently failing on |
I recommend updating terminology a bit. I'd go with:
|
HMR for virtual modules still don't work when resolving with |
Description
Fix withastro/astro#4727
In the module graph,
virtual:foo
that resolves to\0virtual:foo
could be represented as both/@id/__x00__virtual:foo
and\0virtual:foo
in the module graph (two separate modules). This is because in some cases we useunwrapId
and some not.This PR callsunwrapId
in the module graph to ensure they are deduped.unwrapId
in the import analysis so that urls passed to the module graph are already unwrapped.unwrapId
and addedwrapId
(not related to the bug, but I refactored along)Additional context
Note: The below questions has been addressed in the GitHub comments below
\0virtual:foo
is being treated as a "url" in module graph terms, which doesn't sound right. I tried to fix this by passing/@id/__x00__virtual:foo
as URLs but SSR seems to always fail to load and transform for some reason.unwrapId
in the module graph since it feels a bit hacky/catch-all, but there's many place where we're not properly unwrap the id that might further clutter the code.What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).