From 8fb2511a02c163d85f60dfab0bef104756768e35 Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 19 Jan 2021 17:09:24 -0500 Subject: [PATCH] fix(plugin-legacy): throw error when using esbuild minify with legacy plugin --- packages/plugin-legacy/index.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/plugin-legacy/index.js b/packages/plugin-legacy/index.js index 1c8020877301e2..77f840cc811e99 100644 --- a/packages/plugin-legacy/index.js +++ b/packages/plugin-legacy/index.js @@ -69,6 +69,15 @@ function viteLegacyPlugin(options = {}) { name: 'legacy-generate-polyfill-chunk', apply: 'build', + configResolved(config) { + if (config.build.minify === 'esbuild') { + throw new Error( + `Can't use esbuild as the minifier when targeting legacy browsers ` + + `because esbuild minification is not legacy safe.` + ) + } + }, + async generateBundle(opts, bundle) { if (!isLegacyOutput(opts)) { if (!modernPolyfills.size) {