@vitejs/plugin-legacy 1.6.4 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ # [1.7.0](https://github.com/vitejs/vite/compare/plugin-legacy@1.6.4...plugin-legacy@1.7.0) (2022-02-09)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * don't force terser on non-legacy (fix [#6266](https://github.com/vitejs/vite/issues/6266)) ([#6272](https://github.com/vitejs/vite/issues/6272)) ([1da104e](https://github.com/vitejs/vite/commit/1da104e8597e2965313e8cd582d032bca551e4ee))
7
+ * **legacy:** fix conflict with the modern build on css emitting ([#6584](https://github.com/vitejs/vite/issues/6584)) ([f48255e](https://github.com/vitejs/vite/commit/f48255e6e0058e973b949fb4a2372974f0480e11)), closes [#3296](https://github.com/vitejs/vite/issues/3296) [#3317](https://github.com/vitejs/vite/issues/3317) [/github.com/vitejs/vite/commit/6bce1081991501f3779bff1a81e5dd1e63e5d38e#diff-2cfbd4f4d8c32727cd8e1a561cffbde0b384a3ce0789340440e144f9d64c10f6R262-R263](https://github.com//github.com/vitejs/vite/commit/6bce1081991501f3779bff1a81e5dd1e63e5d38e/issues/diff-2cfbd4f4d8c32727cd8e1a561cffbde0b384a3ce0789340440e144f9d64c10f6R262-R263)
8
+
9
+
10
+
1
11
  ## [1.6.4](https://github.com/vitejs/vite/compare/plugin-legacy@1.6.3...plugin-legacy@1.6.4) (2021-12-07)
2
12
 
3
13
 
package/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Plugin } from 'vite'
1
+ import type { Plugin } from 'vite'
2
2
 
3
3
  export interface Options {
4
4
  /**
package/index.js CHANGED
@@ -37,8 +37,9 @@ function viteLegacyPlugin(options = {}) {
37
37
  const genLegacy = options.renderLegacyChunks !== false
38
38
  const genDynamicFallback = genLegacy
39
39
 
40
- const debugFlag = process.env.DEBUG
41
- const isDebug = debugFlag === 'vite:*' || debugFlag === 'vite:legacy'
40
+ const debugFlags = (process.env.DEBUG || '').split(',')
41
+ const isDebug =
42
+ debugFlags.includes('vite:*') || debugFlags.includes('vite:legacy')
42
43
 
43
44
  const facadeToLegacyChunkMap = new Map()
44
45
  const facadeToLegacyPolyfillMap = new Map()
@@ -105,23 +106,6 @@ function viteLegacyPlugin(options = {}) {
105
106
  name: 'vite:legacy-generate-polyfill-chunk',
106
107
  apply: 'build',
107
108
 
108
- config() {
109
- return {
110
- build: {
111
- minify: 'terser'
112
- }
113
- }
114
- },
115
-
116
- configResolved(config) {
117
- if (!config.build.ssr && genLegacy && config.build.minify === 'esbuild') {
118
- throw new Error(
119
- `Can't use esbuild as the minifier when targeting legacy browsers ` +
120
- `because esbuild minification is not legacy safe.`
121
- )
122
- }
123
- },
124
-
125
109
  async generateBundle(opts, bundle) {
126
110
  if (config.build.ssr) {
127
111
  return
@@ -297,6 +281,19 @@ function viteLegacyPlugin(options = {}) {
297
281
  // legacy-unsafe code - e.g. rewriting object properties into shorthands
298
282
  opts.__vite_skip_esbuild__ = true
299
283
 
284
+ // @ts-ignore force terser for legacy chunks. This only takes effect if
285
+ // minification isn't disabled, because that leaves out the terser plugin
286
+ // entirely.
287
+ opts.__vite_force_terser__ = true
288
+
289
+ // @ts-ignore
290
+ // In the `generateBundle` hook,
291
+ // we'll delete the assets from the legacy bundle to avoid emitting duplicate assets.
292
+ // But that's still a waste of computing resource.
293
+ // So we add this flag to avoid emitting the asset in the first place whenever possible.
294
+ opts.__vite_skip_asset_emit__ = true
295
+
296
+ // @ts-ignore avoid emitting assets for legacy bundle
300
297
  const needPolyfills =
301
298
  options.polyfills !== false && !Array.isArray(options.polyfills)
302
299
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitejs/plugin-legacy",
3
- "version": "1.6.4",
3
+ "version": "1.7.0",
4
4
  "license": "MIT",
5
5
  "author": "Evan You",
6
6
  "files": [
@@ -11,7 +11,7 @@
11
11
  "types": "index.d.ts",
12
12
  "scripts": {
13
13
  "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s --commit-path . --lerna-package plugin-legacy",
14
- "release": "node ../../scripts/release.cjs --skipBuild"
14
+ "release": "ts-node ../../scripts/release.ts --skipBuild"
15
15
  },
16
16
  "engines": {
17
17
  "node": ">=12.0.0"
@@ -26,13 +26,13 @@
26
26
  },
27
27
  "homepage": "https://github.com/vitejs/vite/tree/main/packages/plugin-legacy#readme",
28
28
  "dependencies": {
29
- "@babel/standalone": "^7.16.4",
30
- "core-js": "^3.19.1",
29
+ "@babel/standalone": "^7.16.12",
30
+ "core-js": "^3.20.3",
31
31
  "magic-string": "^0.25.7",
32
32
  "regenerator-runtime": "^0.13.9",
33
- "systemjs": "^6.11.0"
33
+ "systemjs": "^6.12.1"
34
34
  },
35
35
  "peerDependencies": {
36
- "vite": "^2.0.0"
36
+ "vite": "^2.7.8"
37
37
  }
38
38
  }