-
-
Notifications
You must be signed in to change notification settings - Fork 7.2k
fix(optimizer): incorrect incompatible error #20439
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,7 +42,7 @@ export function optimizedDepsPlugin(): Plugin { | |
if (depsOptimizer?.isOptimizedDepFile(id)) { | ||
const metadata = depsOptimizer.metadata | ||
const file = cleanUrl(id) | ||
const versionMatch = DEP_VERSION_RE.exec(file) | ||
const versionMatch = DEP_VERSION_RE.exec(id) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
sapphi-red marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const browserHash = versionMatch | ||
? versionMatch[1].split('=')[1] | ||
: undefined | ||
|
@@ -77,9 +77,8 @@ export function optimizedDepsPlugin(): Plugin { | |
try { | ||
return await fsp.readFile(file, 'utf-8') | ||
} catch { | ||
const newMetadata = depsOptimizer.metadata | ||
if (optimizedDepInfoFromFile(newMetadata, file)) { | ||
// Outdated non-entry points (CHUNK), loaded after a rerun | ||
if (browserHash) { | ||
// Outdated optimized files loaded after a rerun | ||
Comment on lines
-80
to
+81
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This old condition did not match requests for stale optimized files. Assuming that cases like |
||
throwOutdatedRequest(id) | ||
sapphi-red marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
throwFileNotFoundInOptimizedDep(id) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was causing
moduleGraph._ensureEntryFromUrl
below to be called withand caused the
moduleGraph.urlToModuleMap
to have a mapping from "url with v query" to "id without v query".This lead
id
indoTransform
to resolve "url with v query" to "id without v query", and made the new condition invite:optimized-deps
plugin to fail.vite/packages/vite/src/node/server/transformRequest.ts
Lines 166 to 171 in c4d5940
https://github.com/vitejs/vite/pull/20439/files#diff-0648e3b1da8ac697354cfca37ada638d3a353be4b3312211c6b131597f6ca101R80
To fix that, I moved this if block after the
moduleGraph._ensureEntryFromUrl
call.Given that
_ensureEntryFromUrl
removes some query internally,vite/packages/vite/src/node/server/moduleGraph.ts
Line 350 in c4d5940
I think not adding
?v=
for the URL passed to_ensureEntryFromUrl
should be fine.