@vitejs/plugin-legacy 2.1.0-beta.0 → 2.2.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/README.md +1 -1
- package/dist/index.cjs +81 -0
- package/dist/index.mjs +80 -0
- package/package.json +7 -6
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @vitejs/plugin-legacy [](https://npmjs.com/package/@vitejs/plugin-legacy)
|
|
2
2
|
|
|
3
|
-
Vite's default browser support baseline is [Native ESM](https://caniuse.com/es6-module). This plugin provides support for legacy browsers that do not support
|
|
3
|
+
Vite's default browser support baseline is [Native ESM](https://caniuse.com/es6-module), [native ESM dynamic import](https://caniuse.com/es6-module-dynamic-import), and [`import.meta`](https://caniuse.com/mdn-javascript_operators_import_meta). This plugin provides support for legacy browsers that do not support those features when building for production.
|
|
4
4
|
|
|
5
5
|
By default, this plugin will:
|
|
6
6
|
|
package/dist/index.cjs
CHANGED
|
@@ -8,11 +8,74 @@ const node_module = require('node:module');
|
|
|
8
8
|
const node_url = require('node:url');
|
|
9
9
|
const vite = require('vite');
|
|
10
10
|
const MagicString = require('magic-string');
|
|
11
|
+
const require$$0 = require('tty');
|
|
11
12
|
|
|
12
13
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
|
|
13
14
|
|
|
14
15
|
const path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
|
15
16
|
const MagicString__default = /*#__PURE__*/_interopDefaultLegacy(MagicString);
|
|
17
|
+
const require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
|
|
18
|
+
|
|
19
|
+
var picocolors = {exports: {}};
|
|
20
|
+
|
|
21
|
+
let tty = require$$0__default;
|
|
22
|
+
|
|
23
|
+
let isColorSupported =
|
|
24
|
+
!("NO_COLOR" in process.env || process.argv.includes("--no-color")) &&
|
|
25
|
+
("FORCE_COLOR" in process.env ||
|
|
26
|
+
process.argv.includes("--color") ||
|
|
27
|
+
process.platform === "win32" ||
|
|
28
|
+
(tty.isatty(1) && process.env.TERM !== "dumb") ||
|
|
29
|
+
"CI" in process.env);
|
|
30
|
+
|
|
31
|
+
let formatter =
|
|
32
|
+
(open, close, replace = open) =>
|
|
33
|
+
input => {
|
|
34
|
+
let string = "" + input;
|
|
35
|
+
let index = string.indexOf(close, open.length);
|
|
36
|
+
return ~index
|
|
37
|
+
? open + replaceClose(string, close, replace, index) + close
|
|
38
|
+
: open + string + close
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
let replaceClose = (string, close, replace, index) => {
|
|
42
|
+
let start = string.substring(0, index) + replace;
|
|
43
|
+
let end = string.substring(index + close.length);
|
|
44
|
+
let nextIndex = end.indexOf(close);
|
|
45
|
+
return ~nextIndex ? start + replaceClose(end, close, replace, nextIndex) : start + end
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
let createColors = (enabled = isColorSupported) => ({
|
|
49
|
+
isColorSupported: enabled,
|
|
50
|
+
reset: enabled ? s => `\x1b[0m${s}\x1b[0m` : String,
|
|
51
|
+
bold: enabled ? formatter("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m") : String,
|
|
52
|
+
dim: enabled ? formatter("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m") : String,
|
|
53
|
+
italic: enabled ? formatter("\x1b[3m", "\x1b[23m") : String,
|
|
54
|
+
underline: enabled ? formatter("\x1b[4m", "\x1b[24m") : String,
|
|
55
|
+
inverse: enabled ? formatter("\x1b[7m", "\x1b[27m") : String,
|
|
56
|
+
hidden: enabled ? formatter("\x1b[8m", "\x1b[28m") : String,
|
|
57
|
+
strikethrough: enabled ? formatter("\x1b[9m", "\x1b[29m") : String,
|
|
58
|
+
black: enabled ? formatter("\x1b[30m", "\x1b[39m") : String,
|
|
59
|
+
red: enabled ? formatter("\x1b[31m", "\x1b[39m") : String,
|
|
60
|
+
green: enabled ? formatter("\x1b[32m", "\x1b[39m") : String,
|
|
61
|
+
yellow: enabled ? formatter("\x1b[33m", "\x1b[39m") : String,
|
|
62
|
+
blue: enabled ? formatter("\x1b[34m", "\x1b[39m") : String,
|
|
63
|
+
magenta: enabled ? formatter("\x1b[35m", "\x1b[39m") : String,
|
|
64
|
+
cyan: enabled ? formatter("\x1b[36m", "\x1b[39m") : String,
|
|
65
|
+
white: enabled ? formatter("\x1b[37m", "\x1b[39m") : String,
|
|
66
|
+
gray: enabled ? formatter("\x1b[90m", "\x1b[39m") : String,
|
|
67
|
+
bgBlack: enabled ? formatter("\x1b[40m", "\x1b[49m") : String,
|
|
68
|
+
bgRed: enabled ? formatter("\x1b[41m", "\x1b[49m") : String,
|
|
69
|
+
bgGreen: enabled ? formatter("\x1b[42m", "\x1b[49m") : String,
|
|
70
|
+
bgYellow: enabled ? formatter("\x1b[43m", "\x1b[49m") : String,
|
|
71
|
+
bgBlue: enabled ? formatter("\x1b[44m", "\x1b[49m") : String,
|
|
72
|
+
bgMagenta: enabled ? formatter("\x1b[45m", "\x1b[49m") : String,
|
|
73
|
+
bgCyan: enabled ? formatter("\x1b[46m", "\x1b[49m") : String,
|
|
74
|
+
bgWhite: enabled ? formatter("\x1b[47m", "\x1b[49m") : String,
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
picocolors.exports = createColors();
|
|
78
|
+
picocolors.exports.createColors = createColors;
|
|
16
79
|
|
|
17
80
|
let babel;
|
|
18
81
|
async function loadBabel() {
|
|
@@ -113,6 +176,7 @@ function viteLegacyPlugin(options = {}) {
|
|
|
113
176
|
legacyPolyfills.add(i);
|
|
114
177
|
});
|
|
115
178
|
}
|
|
179
|
+
let overriddenBuildTarget = false;
|
|
116
180
|
const legacyConfigPlugin = {
|
|
117
181
|
name: "vite:legacy-config",
|
|
118
182
|
config(config2, env) {
|
|
@@ -123,12 +187,29 @@ function viteLegacyPlugin(options = {}) {
|
|
|
123
187
|
if (!config2.build.cssTarget) {
|
|
124
188
|
config2.build.cssTarget = "chrome61";
|
|
125
189
|
}
|
|
190
|
+
overriddenBuildTarget = config2.build.target !== void 0;
|
|
191
|
+
config2.build.target = [
|
|
192
|
+
"es2020",
|
|
193
|
+
"edge79",
|
|
194
|
+
"firefox67",
|
|
195
|
+
"chrome64",
|
|
196
|
+
"safari11.1"
|
|
197
|
+
];
|
|
126
198
|
}
|
|
127
199
|
return {
|
|
128
200
|
define: {
|
|
129
201
|
"import.meta.env.LEGACY": env.command === "serve" || config2.build?.ssr ? false : legacyEnvVarMarker
|
|
130
202
|
}
|
|
131
203
|
};
|
|
204
|
+
},
|
|
205
|
+
configResolved(config2) {
|
|
206
|
+
if (overriddenBuildTarget) {
|
|
207
|
+
config2.logger.warn(
|
|
208
|
+
picocolors.exports.yellow(
|
|
209
|
+
`plugin-legacy overrode 'build.target'. You should pass 'targets' as an option to this plugin with the list of legacy browsers to support instead.`
|
|
210
|
+
)
|
|
211
|
+
);
|
|
212
|
+
}
|
|
132
213
|
}
|
|
133
214
|
};
|
|
134
215
|
const legacyGenerateBundlePlugin = {
|
package/dist/index.mjs
CHANGED
|
@@ -4,6 +4,68 @@ import { createRequire } from 'node:module';
|
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
5
|
import { build, normalizePath } from 'vite';
|
|
6
6
|
import MagicString from 'magic-string';
|
|
7
|
+
import require$$0 from 'tty';
|
|
8
|
+
|
|
9
|
+
var picocolors = {exports: {}};
|
|
10
|
+
|
|
11
|
+
let tty = require$$0;
|
|
12
|
+
|
|
13
|
+
let isColorSupported =
|
|
14
|
+
!("NO_COLOR" in process.env || process.argv.includes("--no-color")) &&
|
|
15
|
+
("FORCE_COLOR" in process.env ||
|
|
16
|
+
process.argv.includes("--color") ||
|
|
17
|
+
process.platform === "win32" ||
|
|
18
|
+
(tty.isatty(1) && process.env.TERM !== "dumb") ||
|
|
19
|
+
"CI" in process.env);
|
|
20
|
+
|
|
21
|
+
let formatter =
|
|
22
|
+
(open, close, replace = open) =>
|
|
23
|
+
input => {
|
|
24
|
+
let string = "" + input;
|
|
25
|
+
let index = string.indexOf(close, open.length);
|
|
26
|
+
return ~index
|
|
27
|
+
? open + replaceClose(string, close, replace, index) + close
|
|
28
|
+
: open + string + close
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
let replaceClose = (string, close, replace, index) => {
|
|
32
|
+
let start = string.substring(0, index) + replace;
|
|
33
|
+
let end = string.substring(index + close.length);
|
|
34
|
+
let nextIndex = end.indexOf(close);
|
|
35
|
+
return ~nextIndex ? start + replaceClose(end, close, replace, nextIndex) : start + end
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
let createColors = (enabled = isColorSupported) => ({
|
|
39
|
+
isColorSupported: enabled,
|
|
40
|
+
reset: enabled ? s => `\x1b[0m${s}\x1b[0m` : String,
|
|
41
|
+
bold: enabled ? formatter("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m") : String,
|
|
42
|
+
dim: enabled ? formatter("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m") : String,
|
|
43
|
+
italic: enabled ? formatter("\x1b[3m", "\x1b[23m") : String,
|
|
44
|
+
underline: enabled ? formatter("\x1b[4m", "\x1b[24m") : String,
|
|
45
|
+
inverse: enabled ? formatter("\x1b[7m", "\x1b[27m") : String,
|
|
46
|
+
hidden: enabled ? formatter("\x1b[8m", "\x1b[28m") : String,
|
|
47
|
+
strikethrough: enabled ? formatter("\x1b[9m", "\x1b[29m") : String,
|
|
48
|
+
black: enabled ? formatter("\x1b[30m", "\x1b[39m") : String,
|
|
49
|
+
red: enabled ? formatter("\x1b[31m", "\x1b[39m") : String,
|
|
50
|
+
green: enabled ? formatter("\x1b[32m", "\x1b[39m") : String,
|
|
51
|
+
yellow: enabled ? formatter("\x1b[33m", "\x1b[39m") : String,
|
|
52
|
+
blue: enabled ? formatter("\x1b[34m", "\x1b[39m") : String,
|
|
53
|
+
magenta: enabled ? formatter("\x1b[35m", "\x1b[39m") : String,
|
|
54
|
+
cyan: enabled ? formatter("\x1b[36m", "\x1b[39m") : String,
|
|
55
|
+
white: enabled ? formatter("\x1b[37m", "\x1b[39m") : String,
|
|
56
|
+
gray: enabled ? formatter("\x1b[90m", "\x1b[39m") : String,
|
|
57
|
+
bgBlack: enabled ? formatter("\x1b[40m", "\x1b[49m") : String,
|
|
58
|
+
bgRed: enabled ? formatter("\x1b[41m", "\x1b[49m") : String,
|
|
59
|
+
bgGreen: enabled ? formatter("\x1b[42m", "\x1b[49m") : String,
|
|
60
|
+
bgYellow: enabled ? formatter("\x1b[43m", "\x1b[49m") : String,
|
|
61
|
+
bgBlue: enabled ? formatter("\x1b[44m", "\x1b[49m") : String,
|
|
62
|
+
bgMagenta: enabled ? formatter("\x1b[45m", "\x1b[49m") : String,
|
|
63
|
+
bgCyan: enabled ? formatter("\x1b[46m", "\x1b[49m") : String,
|
|
64
|
+
bgWhite: enabled ? formatter("\x1b[47m", "\x1b[49m") : String,
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
picocolors.exports = createColors();
|
|
68
|
+
picocolors.exports.createColors = createColors;
|
|
7
69
|
|
|
8
70
|
let babel;
|
|
9
71
|
async function loadBabel() {
|
|
@@ -104,6 +166,7 @@ function viteLegacyPlugin(options = {}) {
|
|
|
104
166
|
legacyPolyfills.add(i);
|
|
105
167
|
});
|
|
106
168
|
}
|
|
169
|
+
let overriddenBuildTarget = false;
|
|
107
170
|
const legacyConfigPlugin = {
|
|
108
171
|
name: "vite:legacy-config",
|
|
109
172
|
config(config2, env) {
|
|
@@ -114,12 +177,29 @@ function viteLegacyPlugin(options = {}) {
|
|
|
114
177
|
if (!config2.build.cssTarget) {
|
|
115
178
|
config2.build.cssTarget = "chrome61";
|
|
116
179
|
}
|
|
180
|
+
overriddenBuildTarget = config2.build.target !== void 0;
|
|
181
|
+
config2.build.target = [
|
|
182
|
+
"es2020",
|
|
183
|
+
"edge79",
|
|
184
|
+
"firefox67",
|
|
185
|
+
"chrome64",
|
|
186
|
+
"safari11.1"
|
|
187
|
+
];
|
|
117
188
|
}
|
|
118
189
|
return {
|
|
119
190
|
define: {
|
|
120
191
|
"import.meta.env.LEGACY": env.command === "serve" || config2.build?.ssr ? false : legacyEnvVarMarker
|
|
121
192
|
}
|
|
122
193
|
};
|
|
194
|
+
},
|
|
195
|
+
configResolved(config2) {
|
|
196
|
+
if (overriddenBuildTarget) {
|
|
197
|
+
config2.logger.warn(
|
|
198
|
+
picocolors.exports.yellow(
|
|
199
|
+
`plugin-legacy overrode 'build.target'. You should pass 'targets' as an option to this plugin with the list of legacy browsers to support instead.`
|
|
200
|
+
)
|
|
201
|
+
);
|
|
202
|
+
}
|
|
123
203
|
}
|
|
124
204
|
};
|
|
125
205
|
const legacyGenerateBundlePlugin = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitejs/plugin-legacy",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Evan You",
|
|
6
6
|
"files": [
|
|
@@ -35,18 +35,19 @@
|
|
|
35
35
|
},
|
|
36
36
|
"homepage": "https://github.com/vitejs/vite/tree/main/packages/plugin-legacy#readme",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@babel/standalone": "^7.
|
|
39
|
-
"core-js": "^3.25.
|
|
40
|
-
"magic-string": "^0.26.
|
|
38
|
+
"@babel/standalone": "^7.19.0",
|
|
39
|
+
"core-js": "^3.25.1",
|
|
40
|
+
"magic-string": "^0.26.3",
|
|
41
41
|
"regenerator-runtime": "^0.13.9",
|
|
42
|
-
"systemjs": "^6.12.
|
|
42
|
+
"systemjs": "^6.12.6"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"terser": "^5.4.0",
|
|
46
46
|
"vite": "^3.0.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@babel/core": "^7.
|
|
49
|
+
"@babel/core": "^7.19.0",
|
|
50
|
+
"picocolors": "^1.0.0",
|
|
50
51
|
"vite": "workspace:*"
|
|
51
52
|
}
|
|
52
53
|
}
|