@vitejs/plugin-legacy 5.4.3 → 6.0.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.
Files changed (3) hide show
  1. package/dist/index.cjs +79 -76
  2. package/dist/index.mjs +79 -76
  3. package/package.json +13 -12
package/dist/index.cjs CHANGED
@@ -24,83 +24,90 @@ function getDefaultExportFromCjs (x) {
24
24
 
25
25
  var picocolors = {exports: {}};
26
26
 
27
- let p = process || {}, argv = p.argv || [], env = p.env || {};
28
- let isColorSupported =
29
- !(!!env.NO_COLOR || argv.includes("--no-color")) &&
30
- (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || ((p.stdout || {}).isTTY && env.TERM !== "dumb") || !!env.CI);
27
+ var hasRequiredPicocolors;
31
28
 
32
- let formatter = (open, close, replace = open) =>
33
- input => {
34
- let string = "" + input, index = string.indexOf(close, open.length);
35
- return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close
36
- };
29
+ function requirePicocolors () {
30
+ if (hasRequiredPicocolors) return picocolors.exports;
31
+ hasRequiredPicocolors = 1;
32
+ let p = process || {}, argv = p.argv || [], env = p.env || {};
33
+ let isColorSupported =
34
+ !(!!env.NO_COLOR || argv.includes("--no-color")) &&
35
+ (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || ((p.stdout || {}).isTTY && env.TERM !== "dumb") || !!env.CI);
37
36
 
38
- let replaceClose = (string, close, replace, index) => {
39
- let result = "", cursor = 0;
40
- do {
41
- result += string.substring(cursor, index) + replace;
42
- cursor = index + close.length;
43
- index = string.indexOf(close, cursor);
44
- } while (~index)
45
- return result + string.substring(cursor)
46
- };
37
+ let formatter = (open, close, replace = open) =>
38
+ input => {
39
+ let string = "" + input, index = string.indexOf(close, open.length);
40
+ return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close
41
+ };
47
42
 
48
- let createColors = (enabled = isColorSupported) => {
49
- let f = enabled ? formatter : () => String;
50
- return {
51
- isColorSupported: enabled,
52
- reset: f("\x1b[0m", "\x1b[0m"),
53
- bold: f("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m"),
54
- dim: f("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m"),
55
- italic: f("\x1b[3m", "\x1b[23m"),
56
- underline: f("\x1b[4m", "\x1b[24m"),
57
- inverse: f("\x1b[7m", "\x1b[27m"),
58
- hidden: f("\x1b[8m", "\x1b[28m"),
59
- strikethrough: f("\x1b[9m", "\x1b[29m"),
43
+ let replaceClose = (string, close, replace, index) => {
44
+ let result = "", cursor = 0;
45
+ do {
46
+ result += string.substring(cursor, index) + replace;
47
+ cursor = index + close.length;
48
+ index = string.indexOf(close, cursor);
49
+ } while (~index)
50
+ return result + string.substring(cursor)
51
+ };
60
52
 
61
- black: f("\x1b[30m", "\x1b[39m"),
62
- red: f("\x1b[31m", "\x1b[39m"),
63
- green: f("\x1b[32m", "\x1b[39m"),
64
- yellow: f("\x1b[33m", "\x1b[39m"),
65
- blue: f("\x1b[34m", "\x1b[39m"),
66
- magenta: f("\x1b[35m", "\x1b[39m"),
67
- cyan: f("\x1b[36m", "\x1b[39m"),
68
- white: f("\x1b[37m", "\x1b[39m"),
69
- gray: f("\x1b[90m", "\x1b[39m"),
53
+ let createColors = (enabled = isColorSupported) => {
54
+ let f = enabled ? formatter : () => String;
55
+ return {
56
+ isColorSupported: enabled,
57
+ reset: f("\x1b[0m", "\x1b[0m"),
58
+ bold: f("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m"),
59
+ dim: f("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m"),
60
+ italic: f("\x1b[3m", "\x1b[23m"),
61
+ underline: f("\x1b[4m", "\x1b[24m"),
62
+ inverse: f("\x1b[7m", "\x1b[27m"),
63
+ hidden: f("\x1b[8m", "\x1b[28m"),
64
+ strikethrough: f("\x1b[9m", "\x1b[29m"),
70
65
 
71
- bgBlack: f("\x1b[40m", "\x1b[49m"),
72
- bgRed: f("\x1b[41m", "\x1b[49m"),
73
- bgGreen: f("\x1b[42m", "\x1b[49m"),
74
- bgYellow: f("\x1b[43m", "\x1b[49m"),
75
- bgBlue: f("\x1b[44m", "\x1b[49m"),
76
- bgMagenta: f("\x1b[45m", "\x1b[49m"),
77
- bgCyan: f("\x1b[46m", "\x1b[49m"),
78
- bgWhite: f("\x1b[47m", "\x1b[49m"),
66
+ black: f("\x1b[30m", "\x1b[39m"),
67
+ red: f("\x1b[31m", "\x1b[39m"),
68
+ green: f("\x1b[32m", "\x1b[39m"),
69
+ yellow: f("\x1b[33m", "\x1b[39m"),
70
+ blue: f("\x1b[34m", "\x1b[39m"),
71
+ magenta: f("\x1b[35m", "\x1b[39m"),
72
+ cyan: f("\x1b[36m", "\x1b[39m"),
73
+ white: f("\x1b[37m", "\x1b[39m"),
74
+ gray: f("\x1b[90m", "\x1b[39m"),
79
75
 
80
- blackBright: f("\x1b[90m", "\x1b[39m"),
81
- redBright: f("\x1b[91m", "\x1b[39m"),
82
- greenBright: f("\x1b[92m", "\x1b[39m"),
83
- yellowBright: f("\x1b[93m", "\x1b[39m"),
84
- blueBright: f("\x1b[94m", "\x1b[39m"),
85
- magentaBright: f("\x1b[95m", "\x1b[39m"),
86
- cyanBright: f("\x1b[96m", "\x1b[39m"),
87
- whiteBright: f("\x1b[97m", "\x1b[39m"),
76
+ bgBlack: f("\x1b[40m", "\x1b[49m"),
77
+ bgRed: f("\x1b[41m", "\x1b[49m"),
78
+ bgGreen: f("\x1b[42m", "\x1b[49m"),
79
+ bgYellow: f("\x1b[43m", "\x1b[49m"),
80
+ bgBlue: f("\x1b[44m", "\x1b[49m"),
81
+ bgMagenta: f("\x1b[45m", "\x1b[49m"),
82
+ bgCyan: f("\x1b[46m", "\x1b[49m"),
83
+ bgWhite: f("\x1b[47m", "\x1b[49m"),
88
84
 
89
- bgBlackBright: f("\x1b[100m", "\x1b[49m"),
90
- bgRedBright: f("\x1b[101m", "\x1b[49m"),
91
- bgGreenBright: f("\x1b[102m", "\x1b[49m"),
92
- bgYellowBright: f("\x1b[103m", "\x1b[49m"),
93
- bgBlueBright: f("\x1b[104m", "\x1b[49m"),
94
- bgMagentaBright: f("\x1b[105m", "\x1b[49m"),
95
- bgCyanBright: f("\x1b[106m", "\x1b[49m"),
96
- bgWhiteBright: f("\x1b[107m", "\x1b[49m"),
97
- }
98
- };
85
+ blackBright: f("\x1b[90m", "\x1b[39m"),
86
+ redBright: f("\x1b[91m", "\x1b[39m"),
87
+ greenBright: f("\x1b[92m", "\x1b[39m"),
88
+ yellowBright: f("\x1b[93m", "\x1b[39m"),
89
+ blueBright: f("\x1b[94m", "\x1b[39m"),
90
+ magentaBright: f("\x1b[95m", "\x1b[39m"),
91
+ cyanBright: f("\x1b[96m", "\x1b[39m"),
92
+ whiteBright: f("\x1b[97m", "\x1b[39m"),
99
93
 
100
- picocolors.exports = createColors();
101
- picocolors.exports.createColors = createColors;
94
+ bgBlackBright: f("\x1b[100m", "\x1b[49m"),
95
+ bgRedBright: f("\x1b[101m", "\x1b[49m"),
96
+ bgGreenBright: f("\x1b[102m", "\x1b[49m"),
97
+ bgYellowBright: f("\x1b[103m", "\x1b[49m"),
98
+ bgBlueBright: f("\x1b[104m", "\x1b[49m"),
99
+ bgMagentaBright: f("\x1b[105m", "\x1b[49m"),
100
+ bgCyanBright: f("\x1b[106m", "\x1b[49m"),
101
+ bgWhiteBright: f("\x1b[107m", "\x1b[49m"),
102
+ }
103
+ };
102
104
 
103
- var picocolorsExports = picocolors.exports;
105
+ picocolors.exports = createColors();
106
+ picocolors.exports.createColors = createColors;
107
+ return picocolors.exports;
108
+ }
109
+
110
+ var picocolorsExports = /*@__PURE__*/ requirePicocolors();
104
111
  const colors = /*@__PURE__*/getDefaultExportFromCjs(picocolorsExports);
105
112
 
106
113
  const safari10NoModuleFix = `!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",(function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()}),!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();`;
@@ -503,15 +510,12 @@ function viteLegacyPlugin(options = {}) {
503
510
  ]
504
511
  ]
505
512
  });
506
- if (result)
507
- return { code: result.code, map: result.map };
513
+ if (result) return { code: result.code, map: result.map };
508
514
  return null;
509
515
  },
510
516
  transformIndexHtml(html, { chunk }) {
511
- if (config.build.ssr)
512
- return;
513
- if (!chunk)
514
- return;
517
+ if (config.build.ssr) return;
518
+ if (!chunk) return;
515
519
  if (chunk.fileName.includes("-legacy")) {
516
520
  facadeToLegacyChunkMap.set(chunk.facadeModuleId, chunk.fileName);
517
521
  if (genModern) {
@@ -721,8 +725,7 @@ async function buildPolyfillChunk(mode, imports, bundle, facadeToChunkMap, build
721
725
  }
722
726
  });
723
727
  const _polyfillChunk = Array.isArray(res) ? res[0] : res;
724
- if (!("output" in _polyfillChunk))
725
- return;
728
+ if (!("output" in _polyfillChunk)) return;
726
729
  const polyfillChunk = _polyfillChunk.output.find(
727
730
  (chunk) => chunk.type === "chunk" && chunk.isEntry
728
731
  );
package/dist/index.mjs CHANGED
@@ -12,83 +12,90 @@ function getDefaultExportFromCjs (x) {
12
12
 
13
13
  var picocolors = {exports: {}};
14
14
 
15
- let p = process || {}, argv = p.argv || [], env = p.env || {};
16
- let isColorSupported =
17
- !(!!env.NO_COLOR || argv.includes("--no-color")) &&
18
- (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || ((p.stdout || {}).isTTY && env.TERM !== "dumb") || !!env.CI);
15
+ var hasRequiredPicocolors;
19
16
 
20
- let formatter = (open, close, replace = open) =>
21
- input => {
22
- let string = "" + input, index = string.indexOf(close, open.length);
23
- return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close
24
- };
17
+ function requirePicocolors () {
18
+ if (hasRequiredPicocolors) return picocolors.exports;
19
+ hasRequiredPicocolors = 1;
20
+ let p = process || {}, argv = p.argv || [], env = p.env || {};
21
+ let isColorSupported =
22
+ !(!!env.NO_COLOR || argv.includes("--no-color")) &&
23
+ (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || ((p.stdout || {}).isTTY && env.TERM !== "dumb") || !!env.CI);
25
24
 
26
- let replaceClose = (string, close, replace, index) => {
27
- let result = "", cursor = 0;
28
- do {
29
- result += string.substring(cursor, index) + replace;
30
- cursor = index + close.length;
31
- index = string.indexOf(close, cursor);
32
- } while (~index)
33
- return result + string.substring(cursor)
34
- };
25
+ let formatter = (open, close, replace = open) =>
26
+ input => {
27
+ let string = "" + input, index = string.indexOf(close, open.length);
28
+ return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close
29
+ };
35
30
 
36
- let createColors = (enabled = isColorSupported) => {
37
- let f = enabled ? formatter : () => String;
38
- return {
39
- isColorSupported: enabled,
40
- reset: f("\x1b[0m", "\x1b[0m"),
41
- bold: f("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m"),
42
- dim: f("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m"),
43
- italic: f("\x1b[3m", "\x1b[23m"),
44
- underline: f("\x1b[4m", "\x1b[24m"),
45
- inverse: f("\x1b[7m", "\x1b[27m"),
46
- hidden: f("\x1b[8m", "\x1b[28m"),
47
- strikethrough: f("\x1b[9m", "\x1b[29m"),
31
+ let replaceClose = (string, close, replace, index) => {
32
+ let result = "", cursor = 0;
33
+ do {
34
+ result += string.substring(cursor, index) + replace;
35
+ cursor = index + close.length;
36
+ index = string.indexOf(close, cursor);
37
+ } while (~index)
38
+ return result + string.substring(cursor)
39
+ };
48
40
 
49
- black: f("\x1b[30m", "\x1b[39m"),
50
- red: f("\x1b[31m", "\x1b[39m"),
51
- green: f("\x1b[32m", "\x1b[39m"),
52
- yellow: f("\x1b[33m", "\x1b[39m"),
53
- blue: f("\x1b[34m", "\x1b[39m"),
54
- magenta: f("\x1b[35m", "\x1b[39m"),
55
- cyan: f("\x1b[36m", "\x1b[39m"),
56
- white: f("\x1b[37m", "\x1b[39m"),
57
- gray: f("\x1b[90m", "\x1b[39m"),
41
+ let createColors = (enabled = isColorSupported) => {
42
+ let f = enabled ? formatter : () => String;
43
+ return {
44
+ isColorSupported: enabled,
45
+ reset: f("\x1b[0m", "\x1b[0m"),
46
+ bold: f("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m"),
47
+ dim: f("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m"),
48
+ italic: f("\x1b[3m", "\x1b[23m"),
49
+ underline: f("\x1b[4m", "\x1b[24m"),
50
+ inverse: f("\x1b[7m", "\x1b[27m"),
51
+ hidden: f("\x1b[8m", "\x1b[28m"),
52
+ strikethrough: f("\x1b[9m", "\x1b[29m"),
58
53
 
59
- bgBlack: f("\x1b[40m", "\x1b[49m"),
60
- bgRed: f("\x1b[41m", "\x1b[49m"),
61
- bgGreen: f("\x1b[42m", "\x1b[49m"),
62
- bgYellow: f("\x1b[43m", "\x1b[49m"),
63
- bgBlue: f("\x1b[44m", "\x1b[49m"),
64
- bgMagenta: f("\x1b[45m", "\x1b[49m"),
65
- bgCyan: f("\x1b[46m", "\x1b[49m"),
66
- bgWhite: f("\x1b[47m", "\x1b[49m"),
54
+ black: f("\x1b[30m", "\x1b[39m"),
55
+ red: f("\x1b[31m", "\x1b[39m"),
56
+ green: f("\x1b[32m", "\x1b[39m"),
57
+ yellow: f("\x1b[33m", "\x1b[39m"),
58
+ blue: f("\x1b[34m", "\x1b[39m"),
59
+ magenta: f("\x1b[35m", "\x1b[39m"),
60
+ cyan: f("\x1b[36m", "\x1b[39m"),
61
+ white: f("\x1b[37m", "\x1b[39m"),
62
+ gray: f("\x1b[90m", "\x1b[39m"),
67
63
 
68
- blackBright: f("\x1b[90m", "\x1b[39m"),
69
- redBright: f("\x1b[91m", "\x1b[39m"),
70
- greenBright: f("\x1b[92m", "\x1b[39m"),
71
- yellowBright: f("\x1b[93m", "\x1b[39m"),
72
- blueBright: f("\x1b[94m", "\x1b[39m"),
73
- magentaBright: f("\x1b[95m", "\x1b[39m"),
74
- cyanBright: f("\x1b[96m", "\x1b[39m"),
75
- whiteBright: f("\x1b[97m", "\x1b[39m"),
64
+ bgBlack: f("\x1b[40m", "\x1b[49m"),
65
+ bgRed: f("\x1b[41m", "\x1b[49m"),
66
+ bgGreen: f("\x1b[42m", "\x1b[49m"),
67
+ bgYellow: f("\x1b[43m", "\x1b[49m"),
68
+ bgBlue: f("\x1b[44m", "\x1b[49m"),
69
+ bgMagenta: f("\x1b[45m", "\x1b[49m"),
70
+ bgCyan: f("\x1b[46m", "\x1b[49m"),
71
+ bgWhite: f("\x1b[47m", "\x1b[49m"),
76
72
 
77
- bgBlackBright: f("\x1b[100m", "\x1b[49m"),
78
- bgRedBright: f("\x1b[101m", "\x1b[49m"),
79
- bgGreenBright: f("\x1b[102m", "\x1b[49m"),
80
- bgYellowBright: f("\x1b[103m", "\x1b[49m"),
81
- bgBlueBright: f("\x1b[104m", "\x1b[49m"),
82
- bgMagentaBright: f("\x1b[105m", "\x1b[49m"),
83
- bgCyanBright: f("\x1b[106m", "\x1b[49m"),
84
- bgWhiteBright: f("\x1b[107m", "\x1b[49m"),
85
- }
86
- };
73
+ blackBright: f("\x1b[90m", "\x1b[39m"),
74
+ redBright: f("\x1b[91m", "\x1b[39m"),
75
+ greenBright: f("\x1b[92m", "\x1b[39m"),
76
+ yellowBright: f("\x1b[93m", "\x1b[39m"),
77
+ blueBright: f("\x1b[94m", "\x1b[39m"),
78
+ magentaBright: f("\x1b[95m", "\x1b[39m"),
79
+ cyanBright: f("\x1b[96m", "\x1b[39m"),
80
+ whiteBright: f("\x1b[97m", "\x1b[39m"),
87
81
 
88
- picocolors.exports = createColors();
89
- picocolors.exports.createColors = createColors;
82
+ bgBlackBright: f("\x1b[100m", "\x1b[49m"),
83
+ bgRedBright: f("\x1b[101m", "\x1b[49m"),
84
+ bgGreenBright: f("\x1b[102m", "\x1b[49m"),
85
+ bgYellowBright: f("\x1b[103m", "\x1b[49m"),
86
+ bgBlueBright: f("\x1b[104m", "\x1b[49m"),
87
+ bgMagentaBright: f("\x1b[105m", "\x1b[49m"),
88
+ bgCyanBright: f("\x1b[106m", "\x1b[49m"),
89
+ bgWhiteBright: f("\x1b[107m", "\x1b[49m"),
90
+ }
91
+ };
90
92
 
91
- var picocolorsExports = picocolors.exports;
93
+ picocolors.exports = createColors();
94
+ picocolors.exports.createColors = createColors;
95
+ return picocolors.exports;
96
+ }
97
+
98
+ var picocolorsExports = /*@__PURE__*/ requirePicocolors();
92
99
  const colors = /*@__PURE__*/getDefaultExportFromCjs(picocolorsExports);
93
100
 
94
101
  const safari10NoModuleFix = `!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",(function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()}),!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();`;
@@ -491,15 +498,12 @@ function viteLegacyPlugin(options = {}) {
491
498
  ]
492
499
  ]
493
500
  });
494
- if (result)
495
- return { code: result.code, map: result.map };
501
+ if (result) return { code: result.code, map: result.map };
496
502
  return null;
497
503
  },
498
504
  transformIndexHtml(html, { chunk }) {
499
- if (config.build.ssr)
500
- return;
501
- if (!chunk)
502
- return;
505
+ if (config.build.ssr) return;
506
+ if (!chunk) return;
503
507
  if (chunk.fileName.includes("-legacy")) {
504
508
  facadeToLegacyChunkMap.set(chunk.facadeModuleId, chunk.fileName);
505
509
  if (genModern) {
@@ -709,8 +713,7 @@ async function buildPolyfillChunk(mode, imports, bundle, facadeToChunkMap, build
709
713
  }
710
714
  });
711
715
  const _polyfillChunk = Array.isArray(res) ? res[0] : res;
712
- if (!("output" in _polyfillChunk))
713
- return;
716
+ if (!("output" in _polyfillChunk)) return;
714
717
  const polyfillChunk = _polyfillChunk.output.find(
715
718
  (chunk) => chunk.type === "chunk" && chunk.isEntry
716
719
  );
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@vitejs/plugin-legacy",
3
- "version": "5.4.3",
3
+ "version": "6.0.0",
4
+ "type": "module",
4
5
  "license": "MIT",
5
6
  "author": "Evan You",
6
7
  "files": [
@@ -22,7 +23,7 @@
22
23
  }
23
24
  },
24
25
  "engines": {
25
- "node": "^18.0.0 || >=20.0.0"
26
+ "node": "^18.0.0 || ^20.0.0 || >=22.0.0"
26
27
  },
27
28
  "repository": {
28
29
  "type": "git",
@@ -35,24 +36,24 @@
35
36
  "homepage": "https://github.com/vitejs/vite/tree/main/packages/plugin-legacy#readme",
36
37
  "funding": "https://github.com/vitejs/vite?sponsor=1",
37
38
  "dependencies": {
38
- "@babel/core": "^7.25.8",
39
- "@babel/preset-env": "^7.25.8",
40
- "browserslist": "^4.24.0",
39
+ "@babel/core": "^7.26.0",
40
+ "@babel/preset-env": "^7.26.0",
41
+ "browserslist": "^4.24.2",
41
42
  "browserslist-to-esbuild": "^2.1.1",
42
- "core-js": "^3.38.1",
43
- "magic-string": "^0.30.12",
43
+ "core-js": "^3.39.0",
44
+ "magic-string": "^0.30.13",
44
45
  "regenerator-runtime": "^0.14.1",
45
46
  "systemjs": "^6.15.1"
46
47
  },
47
48
  "peerDependencies": {
48
- "terser": "^5.4.0",
49
- "vite": "^5.0.0"
49
+ "terser": "^5.16.0",
50
+ "vite": "^6.0.0"
50
51
  },
51
52
  "devDependencies": {
52
- "acorn": "^8.13.0",
53
+ "acorn": "^8.14.0",
53
54
  "picocolors": "^1.1.1",
54
- "unbuild": "^2.0.0",
55
- "vite": "6.0.0-beta.5"
55
+ "unbuild": "^3.0.0-rc.11",
56
+ "vite": "6.0.0"
56
57
  },
57
58
  "scripts": {
58
59
  "dev": "unbuild --stub",