Skip to content

Conversation

sapphi-red
Copy link
Member

Description

Since fetchModule may return a different value depending on importer even if url is the same, I think this.concurrentModuleNodePromises should have url + importer as a key.

I noticed this while reading the code and haven't encountered any specific issues.

@sapphi-red sapphi-red added feat: ssr p2-edge-case Bug, but has workaround or limited in scope (priority) labels Oct 15, 2025
Copy link
Contributor

@hi-ogawa hi-ogawa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. Externalized dep (i.e. bare specifier) is resolved based on importer in fetchModule, so it would technically get mixed up if there are two different node_modules separately.

@sheremet-va
Copy link
Member

sheremet-va commented Oct 15, 2025

Strange that you did not encounter any issue. We had the code work like this before, but it actually doesn't make sense because it will only cache modules inside the same module in that case, so the cache will almost never be hit.

The url is almost always already resolved by the import analyser plugin, and dynamic imports also resolves it manually before calling fetch.

I will try to find the issue why we changed it back to only url

@hi-ogawa
Copy link
Contributor

Oh right. Caching module for already resolved url was the point. I guess this is technically desired only for unresolved url at this point, which is externalized dep, but I'd imagine that's less problematic than changing it.

@hi-ogawa
Copy link
Contributor

/ecosystem-ci run

Copy link

pkg-pr-new bot commented Oct 15, 2025

Open in StackBlitz

npm i https://pkg.pr.new/vite@20944

commit: cbfc200

@sheremet-va
Copy link
Member

Oh right. Caching module for already resolved url was the point. I guess this is technically desired only for unresolved url at this point, which is externalized dep, but I'd imagine that's less problematic than changing it.

True, importer is only used by the externalized dependency, we can just have a guard like we do in

if (!isFileUrl && importer && url[0] !== '.' && url[0] !== '/') {

@vite-ecosystem-ci
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat: ssr p2-edge-case Bug, but has workaround or limited in scope (priority) trigger: preview

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants