Skip to content

Commit

Permalink
fix: more robust plugin.sharedDuringBuild (#18351)
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev authored Oct 15, 2024
1 parent 5ea4b00 commit 47b1270
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions packages/vite/src/node/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1576,25 +1576,20 @@ export async function createBuilderWithResolvedConfig(
}
const patchPlugins = (resolvedPlugins: Plugin[]) => {
// Force opt-in shared plugins
const environmentPlugins = [...resolvedPlugins]
let validMixedPlugins = true
for (let i = 0; i < environmentPlugins.length; i++) {
const environmentPlugin = environmentPlugins[i]
const sharedPlugin = config.plugins[i]
let j = 0
for (let i = 0; i < resolvedPlugins.length; i++) {
const environmentPlugin = resolvedPlugins[i]
if (
config.builder.sharedPlugins ||
environmentPlugin.sharedDuringBuild
) {
if (environmentPlugin.name !== sharedPlugin.name) {
validMixedPlugins = false
break
for (let k = j; k < config.plugins.length; k++) {
if (environmentPlugin.name === config.plugins[k].name) {
resolvedPlugins[i] = config.plugins[k]
j = k + 1
break
}
}
environmentPlugins[i] = sharedPlugin
}
}
if (validMixedPlugins) {
for (let i = 0; i < environmentPlugins.length; i++) {
resolvedPlugins[i] = environmentPlugins[i]
}
}
}
Expand Down

0 comments on commit 47b1270

Please sign in to comment.