Skip to content

Commit

Permalink
feat: enable tree-shaking for lib es (#8737)
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red authored Jun 23, 2022
1 parent 31348b5 commit 5dc0f72
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions packages/vite/src/node/plugins/esbuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,7 @@ export const buildEsbuildPlugin = (config: ResolvedConfig): Plugin => {
}

const target = config.build.target
const minify =
config.build.minify === 'esbuild' &&
// Do not minify ES lib output since that would remove pure annotations
// and break tree-shaking
// https://github.com/vuejs/core/issues/2860#issuecomment-926882793
!(config.build.lib && opts.format === 'es')
const minify = config.build.minify === 'esbuild'

if ((!target || target === 'esnext') && !minify) {
return null
Expand All @@ -253,7 +248,10 @@ export const buildEsbuildPlugin = (config: ResolvedConfig): Plugin => {
target: target || undefined,
...(minify
? {
minify,
// Do not minify ES lib output since that would remove pure annotations
// and break tree-shaking
// https://github.com/vuejs/core/issues/2860#issuecomment-926882793
minify: !(config.build.lib && opts.format === 'es'),
treeShaking: true,
format: rollupToEsbuildFormatMap[opts.format]
}
Expand Down

0 comments on commit 5dc0f72

Please sign in to comment.