@vitejs/plugin-legacy 1.6.1 → 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 +32 -0
- package/index.d.ts +1 -1
- package/index.js +26 -20
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,35 @@
|
|
|
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
|
+
|
|
11
|
+
## [1.6.4](https://github.com/vitejs/vite/compare/plugin-legacy@1.6.3...plugin-legacy@1.6.4) (2021-12-07)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## [1.6.3](https://github.com/vitejs/vite/compare/plugin-legacy@1.6.2...plugin-legacy@1.6.3) (2021-11-22)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* **build:** resolve `rollupOptions.input` paths ([#5601](https://github.com/vitejs/vite/issues/5601)) ([5b6b016](https://github.com/vitejs/vite/commit/5b6b01693720290e8998b2613f0dcb2d699ee84f))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
## [1.6.2](https://github.com/vitejs/vite/compare/plugin-legacy@1.6.1...plugin-legacy@1.6.2) (2021-10-11)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### Features
|
|
28
|
+
|
|
29
|
+
* add `build.cssTarget` option ([#5132](https://github.com/vitejs/vite/issues/5132)) ([b17444f](https://github.com/vitejs/vite/commit/b17444fd97b02bc54410c8575e7d3cb25e4058c2)), closes [#4746](https://github.com/vitejs/vite/issues/4746) [#5070](https://github.com/vitejs/vite/issues/5070) [#4930](https://github.com/vitejs/vite/issues/4930)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
1
33
|
## [1.6.1](https://github.com/vitejs/vite/compare/plugin-legacy@1.6.0...plugin-legacy@1.6.1) (2021-10-05)
|
|
2
34
|
|
|
3
35
|
|
package/index.d.ts
CHANGED
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
|
|
41
|
-
const isDebug =
|
|
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()
|
|
@@ -86,6 +87,15 @@ function viteLegacyPlugin(options = {}) {
|
|
|
86
87
|
if (!config.build) {
|
|
87
88
|
config.build = {}
|
|
88
89
|
}
|
|
90
|
+
|
|
91
|
+
if (!config.build.cssTarget) {
|
|
92
|
+
// Hint for esbuild that we are targeting legacy browsers when minifying CSS.
|
|
93
|
+
// Full CSS compat table available at https://github.com/evanw/esbuild/blob/78e04680228cf989bdd7d471e02bbc2c8d345dc9/internal/compat/css_table.go
|
|
94
|
+
// But note that only the `HexRGBA` feature affects the minify outcome.
|
|
95
|
+
// HSL & rebeccapurple values will be minified away regardless the target.
|
|
96
|
+
// So targeting `chrome61` suffices to fix the compatiblity issue.
|
|
97
|
+
config.build.cssTarget = 'chrome61'
|
|
98
|
+
}
|
|
89
99
|
}
|
|
90
100
|
}
|
|
91
101
|
|
|
@@ -96,23 +106,6 @@ function viteLegacyPlugin(options = {}) {
|
|
|
96
106
|
name: 'vite:legacy-generate-polyfill-chunk',
|
|
97
107
|
apply: 'build',
|
|
98
108
|
|
|
99
|
-
config() {
|
|
100
|
-
return {
|
|
101
|
-
build: {
|
|
102
|
-
minify: 'terser'
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
|
|
107
|
-
configResolved(config) {
|
|
108
|
-
if (!config.build.ssr && genLegacy && config.build.minify === 'esbuild') {
|
|
109
|
-
throw new Error(
|
|
110
|
-
`Can't use esbuild as the minifier when targeting legacy browsers ` +
|
|
111
|
-
`because esbuild minification is not legacy safe.`
|
|
112
|
-
)
|
|
113
|
-
}
|
|
114
|
-
},
|
|
115
|
-
|
|
116
109
|
async generateBundle(opts, bundle) {
|
|
117
110
|
if (config.build.ssr) {
|
|
118
111
|
return
|
|
@@ -288,6 +281,19 @@ function viteLegacyPlugin(options = {}) {
|
|
|
288
281
|
// legacy-unsafe code - e.g. rewriting object properties into shorthands
|
|
289
282
|
opts.__vite_skip_esbuild__ = true
|
|
290
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
|
|
291
297
|
const needPolyfills =
|
|
292
298
|
options.polyfills !== false && !Array.isArray(options.polyfills)
|
|
293
299
|
|
|
@@ -587,7 +593,7 @@ async function buildPolyfillChunk(
|
|
|
587
593
|
bundle[polyfillChunk.name] = polyfillChunk
|
|
588
594
|
}
|
|
589
595
|
|
|
590
|
-
const polyfillId = '
|
|
596
|
+
const polyfillId = '\0vite/legacy-polyfills'
|
|
591
597
|
|
|
592
598
|
/**
|
|
593
599
|
* @param {Set<string>} imports
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitejs/plugin-legacy",
|
|
3
|
-
"version": "1.
|
|
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.
|
|
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.
|
|
30
|
-
"core-js": "^3.
|
|
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.
|
|
33
|
+
"systemjs": "^6.12.1"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"vite": "^2.
|
|
36
|
+
"vite": "^2.7.8"
|
|
37
37
|
}
|
|
38
38
|
}
|