Skip to content

Commit

Permalink
fix: allow cache overlap in parallel builds (#8592)
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev committed Jun 16, 2022
1 parent 739175b commit 2dd0b49
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 14 deletions.
6 changes: 5 additions & 1 deletion packages/vite/src/node/optimizer/index.ts
Expand Up @@ -615,7 +615,11 @@ export function getOptimizedDepPath(
function getDepsCacheSuffix(config: ResolvedConfig): string {
let suffix = ''
if (config.command === 'build') {
suffix += '_build'
// Differentiate build caches depending on outDir to allow parallel builds
const { outDir } = config.build
const buildId =
outDir.length > 8 || outDir.includes('/') ? getHash(outDir) : outDir
suffix += `_build-${buildId}`
if (config.build.ssr) {
suffix += '_ssr'
}
Expand Down
3 changes: 1 addition & 2 deletions playground/assets/vite.config-relative-base.js
Expand Up @@ -22,6 +22,5 @@ module.exports = {
},
testConfig: {
baseRoute: '/relative-base/'
},
cacheDir: 'node_modules/.vite/relative-base'
}
}
3 changes: 1 addition & 2 deletions playground/assets/vite.config.js
Expand Up @@ -17,6 +17,5 @@ module.exports = {
assetsInlineLimit: 8192, // 8kb
manifest: true,
watch: {}
},
cacheDir: 'node_modules/.vite/foo'
}
}
3 changes: 1 addition & 2 deletions playground/worker/vite.config-es.js
Expand Up @@ -38,6 +38,5 @@ module.exports = vite.defineConfig({
}
}
}
],
cacheDir: 'node_modules/.vite/es'
]
})
3 changes: 1 addition & 2 deletions playground/worker/vite.config-relative-base.js
Expand Up @@ -40,6 +40,5 @@ module.exports = vite.defineConfig({
}
}
}
],
cacheDir: 'node_modules/.vite/relative-base'
]
})
3 changes: 0 additions & 3 deletions playground/worker/vite.config-sourcemap.js
Expand Up @@ -21,9 +21,6 @@ module.exports = vite.defineConfig((sourcemap) => {
}
}
},
cacheDir: `node_modules/.vite/iife-${
typeof sourcemap === 'boolean' ? 'sourcemap' : 'sourcemap-' + sourcemap
}`,
build: {
outDir: `dist/iife-${
typeof sourcemap === 'boolean' ? 'sourcemap' : 'sourcemap-' + sourcemap
Expand Down
3 changes: 1 addition & 2 deletions playground/worker/vite.config.js
Expand Up @@ -23,6 +23,5 @@ module.exports = vite.defineConfig({
entryFileNames: 'assets/[name].js'
}
}
},
cacheDir: 'node_modules/.vite/iife'
}
})

0 comments on commit 2dd0b49

Please sign in to comment.