-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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: skip the plugin if it has been called before with the same id and importer #19016
fix: skip the plugin if it has been called before with the same id and importer #19016
Conversation
if (sameCallIndex !== -1) { | ||
skipCallsTemp[sameCallIndex] = { | ||
...skipCallsTemp[sameCallIndex], | ||
called: true, | ||
} |
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.
Awesome investigation!
The fix looks good to merge, but while trying to understand the logic, I cannot tell why we cannot immediately do return null
for such call as this seems to be destined to go resolve loop.
The new test case seems to pass with "just return null
". Do you have a case such approach fails?
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.
I added a test case that fails with return null
: 67c4a66
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.
Thanks!
Call flow is still mind bending to me, but I'll try to understand this in a different time 😅
| datasource | package | from | to | | ---------- | ------- | ----- | ----- | | npm | vite | 6.0.6 | 6.0.7 | ## [v6.0.7](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small607-2025-01-02-small) - fix: fix `minify` when `builder.sharedPlugins: true` ([#19025](vitejs/vite#19025)) ([f7b1964](vitejs/vite@f7b1964)), closes [#19025](vitejs/vite#19025) - fix: skip the plugin if it has been called before with the same id and importer ([#19016](vitejs/vite#19016)) ([b178c90](vitejs/vite@b178c90)), closes [#19016](vitejs/vite#19016) - fix(html): error while removing `vite-ignore` attribute for inline script ([#19062](vitejs/vite#19062)) ([a492253](vitejs/vite@a492253)), closes [#19062](vitejs/vite#19062) - fix(ssr): fix semicolon injection by ssr transform ([#19097](vitejs/vite#19097)) ([1c102d5](vitejs/vite@1c102d5)), closes [#19097](vitejs/vite#19097) - perf: skip globbing for static path in warmup ([#19107](vitejs/vite#19107)) ([677508b](vitejs/vite@677508b)), closes [#19107](vitejs/vite#19107) - feat(css): show lightningcss warnings ([#19076](vitejs/vite#19076)) ([b07c036](vitejs/vite@b07c036)), closes [#19076](vitejs/vite#19076)
| datasource | package | from | to | | ---------- | ------- | ----- | ----- | | npm | vite | 6.0.6 | 6.0.7 | ## [v6.0.7](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small607-2025-01-02-small) - fix: fix `minify` when `builder.sharedPlugins: true` ([#19025](vitejs/vite#19025)) ([f7b1964](vitejs/vite@f7b1964)), closes [#19025](vitejs/vite#19025) - fix: skip the plugin if it has been called before with the same id and importer ([#19016](vitejs/vite#19016)) ([b178c90](vitejs/vite@b178c90)), closes [#19016](vitejs/vite#19016) - fix(html): error while removing `vite-ignore` attribute for inline script ([#19062](vitejs/vite#19062)) ([a492253](vitejs/vite@a492253)), closes [#19062](vitejs/vite#19062) - fix(ssr): fix semicolon injection by ssr transform ([#19097](vitejs/vite#19097)) ([1c102d5](vitejs/vite@1c102d5)), closes [#19097](vitejs/vite#19097) - perf: skip globbing for static path in warmup ([#19107](vitejs/vite#19107)) ([677508b](vitejs/vite@677508b)), closes [#19107](vitejs/vite#19107) - feat(css): show lightningcss warnings ([#19076](vitejs/vite#19076)) ([b07c036](vitejs/vite@b07c036)), closes [#19076](vitejs/vite#19076)
Description
#18903 changed the
skipSelf
behavior to align with rollup.In Nuxt + Vitest scenario, a recursive call happened because of that change (it happens with rollup: rollup/rollup#5768).
Nuxt has
nuxt:resolve-bare-imports
plugin that callsthis.resolve(id, nuxtRoot)
and Vitest hasvitest:resolve-core
plugin that callsthis.resolve(id, viteIndexHtml)
.These plugins were calling each other after #18903.
This didn't happen before #18903 because the plugins were skipped even if the
importer
is different.In this PR,
this.resolve(id, importer)
with the same id and importer will be skipped when it's called inside the sameid
andimporter
even if it's called inside a differentthis.resolve
.For example,
this.resolve('foo', 'bar')
->this.resolve('foo', 'bar')
was skipped before this PR.this.resolve('foo', 'bar')
->this.resolve('foo', 'bar2')
->this.resolve('foo', 'bar')
was not skipped before this PR, but now this case is also skipped.fixes this CI failure in nuxt: https://github.com/nuxt/nuxt/actions/runs/12418711683/job/34672477920?pr=30306
refs #18903