@vitejs/plugin-legacy 5.3.0 → 5.3.2
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/dist/index.cjs +9 -5
- package/dist/index.mjs +9 -5
- package/package.json +8 -8
package/dist/index.cjs
CHANGED
|
@@ -10,7 +10,6 @@ const vite = require('vite');
|
|
|
10
10
|
const MagicString = require('magic-string');
|
|
11
11
|
const require$$0 = require('tty');
|
|
12
12
|
const browserslist = require('browserslist');
|
|
13
|
-
const esbuildPluginBrowserslist = require('esbuild-plugin-browserslist');
|
|
14
13
|
|
|
15
14
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
16
15
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
@@ -210,7 +209,7 @@ function viteLegacyPlugin(options = {}) {
|
|
|
210
209
|
let overriddenDefaultModernTargets = false;
|
|
211
210
|
const legacyConfigPlugin = {
|
|
212
211
|
name: "vite:legacy-config",
|
|
213
|
-
config(config2, env) {
|
|
212
|
+
async config(config2, env) {
|
|
214
213
|
if (env.command === "build" && !config2.build?.ssr) {
|
|
215
214
|
if (!config2.build) {
|
|
216
215
|
config2.build = {};
|
|
@@ -221,7 +220,12 @@ function viteLegacyPlugin(options = {}) {
|
|
|
221
220
|
if (genLegacy) {
|
|
222
221
|
overriddenBuildTarget = config2.build.target !== void 0;
|
|
223
222
|
overriddenDefaultModernTargets = options.modernTargets !== void 0;
|
|
224
|
-
|
|
223
|
+
if (options.modernTargets) {
|
|
224
|
+
const { default: browserslistToEsbuild } = await import('browserslist-to-esbuild');
|
|
225
|
+
config2.build.target = browserslistToEsbuild(options.modernTargets);
|
|
226
|
+
} else {
|
|
227
|
+
config2.build.target = modernTargetsEsbuild;
|
|
228
|
+
}
|
|
225
229
|
}
|
|
226
230
|
}
|
|
227
231
|
return {
|
|
@@ -316,13 +320,13 @@ function viteLegacyPlugin(options = {}) {
|
|
|
316
320
|
throw new Error("@vitejs/plugin-legacy does not support library mode.");
|
|
317
321
|
}
|
|
318
322
|
config = _config;
|
|
323
|
+
modernTargets = options.modernTargets || modernTargetsBabel;
|
|
324
|
+
isDebug && console.log(`[@vitejs/plugin-legacy] modernTargets:`, modernTargets);
|
|
319
325
|
if (!genLegacy || config.build.ssr) {
|
|
320
326
|
return;
|
|
321
327
|
}
|
|
322
328
|
targets = options.targets || browserslistLoadConfig({ path: config.root }) || "last 2 versions and not dead, > 0.3%, Firefox ESR";
|
|
323
329
|
isDebug && console.log(`[@vitejs/plugin-legacy] targets:`, targets);
|
|
324
|
-
modernTargets = options.modernTargets || modernTargetsBabel;
|
|
325
|
-
isDebug && console.log(`[@vitejs/plugin-legacy] modernTargets:`, modernTargets);
|
|
326
330
|
const getLegacyOutputFileName = (fileNames, defaultFileName = "[name]-legacy-[hash].js") => {
|
|
327
331
|
if (!fileNames) {
|
|
328
332
|
return path__default.posix.join(config.build.assetsDir, defaultFileName);
|
package/dist/index.mjs
CHANGED
|
@@ -6,7 +6,6 @@ import { build, normalizePath } from 'vite';
|
|
|
6
6
|
import MagicString from 'magic-string';
|
|
7
7
|
import require$$0 from 'tty';
|
|
8
8
|
import browserslist from 'browserslist';
|
|
9
|
-
import { resolveToEsbuildTarget } from 'esbuild-plugin-browserslist';
|
|
10
9
|
|
|
11
10
|
function getDefaultExportFromCjs (x) {
|
|
12
11
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
@@ -198,7 +197,7 @@ function viteLegacyPlugin(options = {}) {
|
|
|
198
197
|
let overriddenDefaultModernTargets = false;
|
|
199
198
|
const legacyConfigPlugin = {
|
|
200
199
|
name: "vite:legacy-config",
|
|
201
|
-
config(config2, env) {
|
|
200
|
+
async config(config2, env) {
|
|
202
201
|
if (env.command === "build" && !config2.build?.ssr) {
|
|
203
202
|
if (!config2.build) {
|
|
204
203
|
config2.build = {};
|
|
@@ -209,7 +208,12 @@ function viteLegacyPlugin(options = {}) {
|
|
|
209
208
|
if (genLegacy) {
|
|
210
209
|
overriddenBuildTarget = config2.build.target !== void 0;
|
|
211
210
|
overriddenDefaultModernTargets = options.modernTargets !== void 0;
|
|
212
|
-
|
|
211
|
+
if (options.modernTargets) {
|
|
212
|
+
const { default: browserslistToEsbuild } = await import('browserslist-to-esbuild');
|
|
213
|
+
config2.build.target = browserslistToEsbuild(options.modernTargets);
|
|
214
|
+
} else {
|
|
215
|
+
config2.build.target = modernTargetsEsbuild;
|
|
216
|
+
}
|
|
213
217
|
}
|
|
214
218
|
}
|
|
215
219
|
return {
|
|
@@ -304,13 +308,13 @@ function viteLegacyPlugin(options = {}) {
|
|
|
304
308
|
throw new Error("@vitejs/plugin-legacy does not support library mode.");
|
|
305
309
|
}
|
|
306
310
|
config = _config;
|
|
311
|
+
modernTargets = options.modernTargets || modernTargetsBabel;
|
|
312
|
+
isDebug && console.log(`[@vitejs/plugin-legacy] modernTargets:`, modernTargets);
|
|
307
313
|
if (!genLegacy || config.build.ssr) {
|
|
308
314
|
return;
|
|
309
315
|
}
|
|
310
316
|
targets = options.targets || browserslistLoadConfig({ path: config.root }) || "last 2 versions and not dead, > 0.3%, Firefox ESR";
|
|
311
317
|
isDebug && console.log(`[@vitejs/plugin-legacy] targets:`, targets);
|
|
312
|
-
modernTargets = options.modernTargets || modernTargetsBabel;
|
|
313
|
-
isDebug && console.log(`[@vitejs/plugin-legacy] modernTargets:`, modernTargets);
|
|
314
318
|
const getLegacyOutputFileName = (fileNames, defaultFileName = "[name]-legacy-[hash].js") => {
|
|
315
319
|
if (!fileNames) {
|
|
316
320
|
return path.posix.join(config.build.assetsDir, defaultFileName);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitejs/plugin-legacy",
|
|
3
|
-
"version": "5.3.
|
|
3
|
+
"version": "5.3.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Evan You",
|
|
6
6
|
"files": [
|
|
@@ -35,12 +35,12 @@
|
|
|
35
35
|
"homepage": "https://github.com/vitejs/vite/tree/main/packages/plugin-legacy#readme",
|
|
36
36
|
"funding": "https://github.com/vitejs/vite?sponsor=1",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@babel/core": "^7.23.
|
|
39
|
-
"@babel/preset-env": "^7.23.
|
|
40
|
-
"browserslist": "^4.
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"magic-string": "^0.30.
|
|
38
|
+
"@babel/core": "^7.23.9",
|
|
39
|
+
"@babel/preset-env": "^7.23.9",
|
|
40
|
+
"browserslist": "^4.23.0",
|
|
41
|
+
"browserslist-to-esbuild": "^2.1.1",
|
|
42
|
+
"core-js": "^3.36.0",
|
|
43
|
+
"magic-string": "^0.30.7",
|
|
44
44
|
"regenerator-runtime": "^0.14.1",
|
|
45
45
|
"systemjs": "^6.14.3"
|
|
46
46
|
},
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"acorn": "^8.11.3",
|
|
53
53
|
"picocolors": "^1.0.0",
|
|
54
|
-
"vite": "5.1.
|
|
54
|
+
"vite": "5.1.5"
|
|
55
55
|
},
|
|
56
56
|
"scripts": {
|
|
57
57
|
"dev": "unbuild --stub",
|