Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion packages/plugin-legacy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default {
}
```

Terser must be installed because plugin-legacy uses Terser for minification.
If `renderLegacyChunks` is not `false`, Terser must be installed because plugin-legacy uses Terser to minify legacy chunks.

```sh
npm add -D terser
Expand Down
5 changes: 5 additions & 0 deletions packages/plugin-legacy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@
"terser": "^5.4.0",
"vite": "^3.0.0"
},
"peerDependenciesMeta": {
"terser": {
"optional": true
}
},
"devDependencies": {
"@babel/core": "^7.18.9",
"vite": "workspace:*"
Expand Down
4 changes: 3 additions & 1 deletion packages/plugin-legacy/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,9 @@ async function buildPolyfillChunk(
excludeSystemJS?: boolean
) {
let { minify, assetsDir } = buildOptions
minify = minify ? 'terser' : false
if (format === 'iife') {
minify = minify ? 'terser' : false
}
Comment on lines +651 to +653
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: This function is only called in two places. One for building the modern polyfilll chunk, two for legacy polyfill chunk. They pass es and iife respectively. So this changes that modern polyfills uses esbuild instead, which should be fine.

const res = await build({
// so that everything is resolved from here
root: path.dirname(fileURLToPath(import.meta.url)),
Expand Down