Skip to content
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

feat: enable tree-shaking for lib es #8737

Merged
merged 1 commit into from
Jun 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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