@vitejs/plugin-legacy 5.4.2 → 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.
- package/LICENSE +1 -1
- package/dist/index.cjs +151 -101
- package/dist/index.d.cts +1 -3
- package/dist/index.d.mts +1 -3
- package/dist/index.d.ts +1 -3
- package/dist/index.mjs +148 -98
- package/package.json +14 -13
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2019-present,
|
|
3
|
+
Copyright (c) 2019-present, VoidZero Inc. and Vite contributors
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/dist/index.cjs
CHANGED
|
@@ -3,99 +3,111 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const path = require('node:path');
|
|
6
|
-
const
|
|
6
|
+
const crypto = require('node:crypto');
|
|
7
7
|
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');
|
|
12
11
|
const browserslist = require('browserslist');
|
|
13
12
|
|
|
14
13
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
15
14
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
16
15
|
|
|
17
16
|
const path__default = /*#__PURE__*/_interopDefaultCompat(path);
|
|
17
|
+
const crypto__default = /*#__PURE__*/_interopDefaultCompat(crypto);
|
|
18
18
|
const MagicString__default = /*#__PURE__*/_interopDefaultCompat(MagicString);
|
|
19
|
-
const require$$0__default = /*#__PURE__*/_interopDefaultCompat(require$$0);
|
|
20
19
|
const browserslist__default = /*#__PURE__*/_interopDefaultCompat(browserslist);
|
|
21
20
|
|
|
22
21
|
function getDefaultExportFromCjs (x) {
|
|
23
22
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
24
23
|
}
|
|
25
24
|
|
|
26
|
-
function commonjsRequire(path) {
|
|
27
|
-
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
|
|
28
|
-
}
|
|
29
|
-
|
|
30
25
|
var picocolors = {exports: {}};
|
|
31
26
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
(
|
|
40
|
-
"
|
|
27
|
+
var hasRequiredPicocolors;
|
|
28
|
+
|
|
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);
|
|
41
36
|
|
|
42
|
-
let formatter =
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
+
};
|
|
42
|
+
|
|
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)
|
|
50
51
|
};
|
|
51
52
|
|
|
52
|
-
let
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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"),
|
|
65
|
+
|
|
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"),
|
|
62
75
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
underline: init("\x1b[4m", "\x1b[24m"),
|
|
72
|
-
inverse: init("\x1b[7m", "\x1b[27m"),
|
|
73
|
-
hidden: init("\x1b[8m", "\x1b[28m"),
|
|
74
|
-
strikethrough: init("\x1b[9m", "\x1b[29m"),
|
|
75
|
-
black: init("\x1b[30m", "\x1b[39m"),
|
|
76
|
-
red: init("\x1b[31m", "\x1b[39m"),
|
|
77
|
-
green: init("\x1b[32m", "\x1b[39m"),
|
|
78
|
-
yellow: init("\x1b[33m", "\x1b[39m"),
|
|
79
|
-
blue: init("\x1b[34m", "\x1b[39m"),
|
|
80
|
-
magenta: init("\x1b[35m", "\x1b[39m"),
|
|
81
|
-
cyan: init("\x1b[36m", "\x1b[39m"),
|
|
82
|
-
white: init("\x1b[37m", "\x1b[39m"),
|
|
83
|
-
gray: init("\x1b[90m", "\x1b[39m"),
|
|
84
|
-
bgBlack: init("\x1b[40m", "\x1b[49m"),
|
|
85
|
-
bgRed: init("\x1b[41m", "\x1b[49m"),
|
|
86
|
-
bgGreen: init("\x1b[42m", "\x1b[49m"),
|
|
87
|
-
bgYellow: init("\x1b[43m", "\x1b[49m"),
|
|
88
|
-
bgBlue: init("\x1b[44m", "\x1b[49m"),
|
|
89
|
-
bgMagenta: init("\x1b[45m", "\x1b[49m"),
|
|
90
|
-
bgCyan: init("\x1b[46m", "\x1b[49m"),
|
|
91
|
-
bgWhite: init("\x1b[47m", "\x1b[49m"),
|
|
92
|
-
}
|
|
93
|
-
};
|
|
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"),
|
|
94
84
|
|
|
95
|
-
|
|
96
|
-
|
|
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"),
|
|
93
|
+
|
|
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
|
+
};
|
|
104
|
+
|
|
105
|
+
picocolors.exports = createColors();
|
|
106
|
+
picocolors.exports.createColors = createColors;
|
|
107
|
+
return picocolors.exports;
|
|
108
|
+
}
|
|
97
109
|
|
|
98
|
-
var picocolorsExports =
|
|
110
|
+
var picocolorsExports = /*@__PURE__*/ requirePicocolors();
|
|
99
111
|
const colors = /*@__PURE__*/getDefaultExportFromCjs(picocolorsExports);
|
|
100
112
|
|
|
101
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()}}();`;
|
|
@@ -165,7 +177,7 @@ function joinUrlSegments(a, b) {
|
|
|
165
177
|
}
|
|
166
178
|
function toAssetPathFromHtml(filename, htmlPath, config) {
|
|
167
179
|
const relativeUrlPath = vite.normalizePath(path__default.relative(config.root, htmlPath));
|
|
168
|
-
const toRelative = (filename2,
|
|
180
|
+
const toRelative = (filename2, _hostId) => getBaseInHTML(relativeUrlPath, config) + filename2;
|
|
169
181
|
return toOutputFilePathInHtml(
|
|
170
182
|
filename,
|
|
171
183
|
"asset",
|
|
@@ -176,7 +188,7 @@ function toAssetPathFromHtml(filename, htmlPath, config) {
|
|
|
176
188
|
);
|
|
177
189
|
}
|
|
178
190
|
const legacyEnvVarMarker = `__VITE_IS_LEGACY__`;
|
|
179
|
-
const _require = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
|
|
191
|
+
const _require = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
|
|
180
192
|
const nonLeadingHashInFileNameRE = /[^/]+\[hash(?::\d+)?\]/;
|
|
181
193
|
const prefixedHashInFileNameRE = /\W?\[hash(?::\d+)?\]/;
|
|
182
194
|
function viteLegacyPlugin(options = {}) {
|
|
@@ -300,11 +312,13 @@ function viteLegacyPlugin(options = {}) {
|
|
|
300
312
|
if (!modernPolyfills.size) {
|
|
301
313
|
return;
|
|
302
314
|
}
|
|
303
|
-
isDebug
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
315
|
+
if (isDebug) {
|
|
316
|
+
console.log(
|
|
317
|
+
`[@vitejs/plugin-legacy] modern polyfills:`,
|
|
318
|
+
modernPolyfills
|
|
319
|
+
);
|
|
320
|
+
}
|
|
321
|
+
await buildPolyfillChunk(
|
|
308
322
|
config.mode,
|
|
309
323
|
modernPolyfills,
|
|
310
324
|
bundle,
|
|
@@ -312,11 +326,9 @@ function viteLegacyPlugin(options = {}) {
|
|
|
312
326
|
config.build,
|
|
313
327
|
"es",
|
|
314
328
|
opts,
|
|
315
|
-
true
|
|
329
|
+
true,
|
|
330
|
+
genLegacy
|
|
316
331
|
);
|
|
317
|
-
if (genLegacy && polyfillChunk) {
|
|
318
|
-
polyfillChunk.code = modernChunkLegacyGuard + polyfillChunk.code;
|
|
319
|
-
}
|
|
320
332
|
return;
|
|
321
333
|
}
|
|
322
334
|
if (!genLegacy) {
|
|
@@ -333,10 +345,12 @@ function viteLegacyPlugin(options = {}) {
|
|
|
333
345
|
);
|
|
334
346
|
}
|
|
335
347
|
if (legacyPolyfills.size || !options.externalSystemJS) {
|
|
336
|
-
isDebug
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
348
|
+
if (isDebug) {
|
|
349
|
+
console.log(
|
|
350
|
+
`[@vitejs/plugin-legacy] legacy polyfills:`,
|
|
351
|
+
legacyPolyfills
|
|
352
|
+
);
|
|
353
|
+
}
|
|
340
354
|
await buildPolyfillChunk(
|
|
341
355
|
config.mode,
|
|
342
356
|
legacyPolyfills,
|
|
@@ -365,12 +379,16 @@ function viteLegacyPlugin(options = {}) {
|
|
|
365
379
|
}
|
|
366
380
|
config = _config;
|
|
367
381
|
modernTargets = options.modernTargets || modernTargetsBabel;
|
|
368
|
-
|
|
382
|
+
if (isDebug) {
|
|
383
|
+
console.log(`[@vitejs/plugin-legacy] modernTargets:`, modernTargets);
|
|
384
|
+
}
|
|
369
385
|
if (!genLegacy || config.build.ssr) {
|
|
370
386
|
return;
|
|
371
387
|
}
|
|
372
388
|
targets = options.targets || browserslistLoadConfig({ path: config.root }) || "last 2 versions and not dead, > 0.3%, Firefox ESR";
|
|
373
|
-
|
|
389
|
+
if (isDebug) {
|
|
390
|
+
console.log(`[@vitejs/plugin-legacy] targets:`, targets);
|
|
391
|
+
}
|
|
374
392
|
const getLegacyOutputFileName = (fileNames, defaultFileName = "[name]-legacy-[hash].js") => {
|
|
375
393
|
if (!fileNames) {
|
|
376
394
|
return path__default.posix.join(config.build.assetsDir, defaultFileName);
|
|
@@ -474,7 +492,6 @@ function viteLegacyPlugin(options = {}) {
|
|
|
474
492
|
compact: !!config.build.minify,
|
|
475
493
|
sourceMaps,
|
|
476
494
|
inputSourceMap: void 0,
|
|
477
|
-
// sourceMaps ? chunk.map : undefined, `.map` TODO: moved to OutputChunk?
|
|
478
495
|
presets: [
|
|
479
496
|
// forcing our plugin to run before preset-env by wrapping it in a
|
|
480
497
|
// preset so we can catch the injected import statements...
|
|
@@ -493,15 +510,12 @@ function viteLegacyPlugin(options = {}) {
|
|
|
493
510
|
]
|
|
494
511
|
]
|
|
495
512
|
});
|
|
496
|
-
if (result)
|
|
497
|
-
return { code: result.code, map: result.map };
|
|
513
|
+
if (result) return { code: result.code, map: result.map };
|
|
498
514
|
return null;
|
|
499
515
|
},
|
|
500
516
|
transformIndexHtml(html, { chunk }) {
|
|
501
|
-
if (config.build.ssr)
|
|
502
|
-
|
|
503
|
-
if (!chunk)
|
|
504
|
-
return;
|
|
517
|
+
if (config.build.ssr) return;
|
|
518
|
+
if (!chunk) return;
|
|
505
519
|
if (chunk.fileName.includes("-legacy")) {
|
|
506
520
|
facadeToLegacyChunkMap.set(chunk.facadeModuleId, chunk.fileName);
|
|
507
521
|
if (genModern) {
|
|
@@ -669,20 +683,24 @@ function createBabelPresetEnvOptions(targets, { needPolyfills = true }) {
|
|
|
669
683
|
ignoreBrowserslistConfig: true
|
|
670
684
|
};
|
|
671
685
|
}
|
|
672
|
-
async function buildPolyfillChunk(mode, imports, bundle, facadeToChunkMap, buildOptions, format, rollupOutputOptions, excludeSystemJS) {
|
|
673
|
-
let { minify, assetsDir } = buildOptions;
|
|
686
|
+
async function buildPolyfillChunk(mode, imports, bundle, facadeToChunkMap, buildOptions, format, rollupOutputOptions, excludeSystemJS, prependModenChunkLegacyGuard) {
|
|
687
|
+
let { minify, assetsDir, sourcemap } = buildOptions;
|
|
674
688
|
minify = minify ? "terser" : false;
|
|
675
689
|
const res = await vite.build({
|
|
676
690
|
mode,
|
|
677
691
|
// so that everything is resolved from here
|
|
678
|
-
root: path__default.dirname(node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)))),
|
|
692
|
+
root: path__default.dirname(node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)))),
|
|
679
693
|
configFile: false,
|
|
680
694
|
logLevel: "error",
|
|
681
|
-
plugins: [
|
|
695
|
+
plugins: [
|
|
696
|
+
polyfillsPlugin(imports, excludeSystemJS),
|
|
697
|
+
prependModenChunkLegacyGuard && prependModenChunkLegacyGuardPlugin()
|
|
698
|
+
],
|
|
682
699
|
build: {
|
|
683
700
|
write: false,
|
|
684
701
|
minify,
|
|
685
702
|
assetsDir,
|
|
703
|
+
sourcemap,
|
|
686
704
|
rollupOptions: {
|
|
687
705
|
input: {
|
|
688
706
|
polyfills: polyfillId
|
|
@@ -707,9 +725,10 @@ async function buildPolyfillChunk(mode, imports, bundle, facadeToChunkMap, build
|
|
|
707
725
|
}
|
|
708
726
|
});
|
|
709
727
|
const _polyfillChunk = Array.isArray(res) ? res[0] : res;
|
|
710
|
-
if (!("output" in _polyfillChunk))
|
|
711
|
-
|
|
712
|
-
|
|
728
|
+
if (!("output" in _polyfillChunk)) return;
|
|
729
|
+
const polyfillChunk = _polyfillChunk.output.find(
|
|
730
|
+
(chunk) => chunk.type === "chunk" && chunk.isEntry
|
|
731
|
+
);
|
|
713
732
|
for (const key in bundle) {
|
|
714
733
|
const chunk = bundle[key];
|
|
715
734
|
if (chunk.type === "chunk" && chunk.facadeModuleId) {
|
|
@@ -717,7 +736,14 @@ async function buildPolyfillChunk(mode, imports, bundle, facadeToChunkMap, build
|
|
|
717
736
|
}
|
|
718
737
|
}
|
|
719
738
|
bundle[polyfillChunk.fileName] = polyfillChunk;
|
|
720
|
-
|
|
739
|
+
if (polyfillChunk.sourcemapFileName) {
|
|
740
|
+
const polyfillChunkMapAsset = _polyfillChunk.output.find(
|
|
741
|
+
(chunk) => chunk.type === "asset" && chunk.fileName === polyfillChunk.sourcemapFileName
|
|
742
|
+
);
|
|
743
|
+
if (polyfillChunkMapAsset) {
|
|
744
|
+
bundle[polyfillChunk.sourcemapFileName] = polyfillChunkMapAsset;
|
|
745
|
+
}
|
|
746
|
+
}
|
|
721
747
|
}
|
|
722
748
|
const polyfillId = "\0vite/legacy-polyfills";
|
|
723
749
|
function polyfillsPlugin(imports, excludeSystemJS) {
|
|
@@ -735,6 +761,26 @@ function polyfillsPlugin(imports, excludeSystemJS) {
|
|
|
735
761
|
}
|
|
736
762
|
};
|
|
737
763
|
}
|
|
764
|
+
function prependModenChunkLegacyGuardPlugin() {
|
|
765
|
+
let sourceMapEnabled;
|
|
766
|
+
return {
|
|
767
|
+
name: "vite:legacy-prepend-moden-chunk-legacy-guard",
|
|
768
|
+
configResolved(config) {
|
|
769
|
+
sourceMapEnabled = !!config.build.sourcemap;
|
|
770
|
+
},
|
|
771
|
+
renderChunk(code) {
|
|
772
|
+
if (!sourceMapEnabled) {
|
|
773
|
+
return modernChunkLegacyGuard + code;
|
|
774
|
+
}
|
|
775
|
+
const ms = new MagicString__default(code);
|
|
776
|
+
ms.prepend(modernChunkLegacyGuard);
|
|
777
|
+
return {
|
|
778
|
+
code: ms.toString(),
|
|
779
|
+
map: ms.generateMap({ hires: "boundary" })
|
|
780
|
+
};
|
|
781
|
+
}
|
|
782
|
+
};
|
|
783
|
+
}
|
|
738
784
|
function isLegacyChunk(chunk, options) {
|
|
739
785
|
return options.format === "system" && chunk.fileName.includes("-legacy");
|
|
740
786
|
}
|
|
@@ -786,12 +832,16 @@ function wrapIIFEBabelPlugin() {
|
|
|
786
832
|
};
|
|
787
833
|
};
|
|
788
834
|
}
|
|
835
|
+
const hash = (
|
|
836
|
+
// eslint-disable-next-line n/no-unsupported-features/node-builtins -- crypto.hash is supported in Node 21.7.0+, 20.12.0+
|
|
837
|
+
crypto__default.hash ?? ((algorithm, data, outputEncoding) => crypto__default.createHash(algorithm).update(data).digest(outputEncoding))
|
|
838
|
+
);
|
|
789
839
|
const cspHashes = [
|
|
790
840
|
safari10NoModuleFix,
|
|
791
841
|
systemJSInlineCode,
|
|
792
842
|
detectModernBrowserCode,
|
|
793
843
|
dynamicFallbackInlineCode
|
|
794
|
-
].map((i) =>
|
|
844
|
+
].map((i) => hash("sha256", i, "base64"));
|
|
795
845
|
|
|
796
846
|
module.exports = viteLegacyPlugin;
|
|
797
847
|
module.exports.cspHashes = cspHashes;
|
package/dist/index.d.cts
CHANGED
|
@@ -4,9 +4,7 @@ interface Options {
|
|
|
4
4
|
/**
|
|
5
5
|
* default: 'defaults'
|
|
6
6
|
*/
|
|
7
|
-
targets?: string | string[] |
|
|
8
|
-
[key: string]: string;
|
|
9
|
-
};
|
|
7
|
+
targets?: string | string[] | Record<string, string>;
|
|
10
8
|
/**
|
|
11
9
|
* default: 'edge>=79, firefox>=67, chrome>=64, safari>=12, chromeAndroid>=64, iOS>=12'
|
|
12
10
|
*/
|
package/dist/index.d.mts
CHANGED
|
@@ -4,9 +4,7 @@ interface Options {
|
|
|
4
4
|
/**
|
|
5
5
|
* default: 'defaults'
|
|
6
6
|
*/
|
|
7
|
-
targets?: string | string[] |
|
|
8
|
-
[key: string]: string;
|
|
9
|
-
};
|
|
7
|
+
targets?: string | string[] | Record<string, string>;
|
|
10
8
|
/**
|
|
11
9
|
* default: 'edge>=79, firefox>=67, chrome>=64, safari>=12, chromeAndroid>=64, iOS>=12'
|
|
12
10
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -4,9 +4,7 @@ interface Options {
|
|
|
4
4
|
/**
|
|
5
5
|
* default: 'defaults'
|
|
6
6
|
*/
|
|
7
|
-
targets?: string | string[] |
|
|
8
|
-
[key: string]: string;
|
|
9
|
-
};
|
|
7
|
+
targets?: string | string[] | Record<string, string>;
|
|
10
8
|
/**
|
|
11
9
|
* default: 'edge>=79, firefox>=67, chrome>=64, safari>=12, chromeAndroid>=64, iOS>=12'
|
|
12
10
|
*/
|
package/dist/index.mjs
CHANGED
|
@@ -1,89 +1,101 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
|
-
import
|
|
2
|
+
import crypto from 'node:crypto';
|
|
3
3
|
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
7
|
import browserslist from 'browserslist';
|
|
9
8
|
|
|
10
9
|
function getDefaultExportFromCjs (x) {
|
|
11
10
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
12
11
|
}
|
|
13
12
|
|
|
14
|
-
function commonjsRequire(path) {
|
|
15
|
-
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
|
|
16
|
-
}
|
|
17
|
-
|
|
18
13
|
var picocolors = {exports: {}};
|
|
19
14
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
(
|
|
28
|
-
"
|
|
15
|
+
var hasRequiredPicocolors;
|
|
16
|
+
|
|
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);
|
|
29
24
|
|
|
30
|
-
let formatter =
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
+
};
|
|
30
|
+
|
|
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)
|
|
38
39
|
};
|
|
39
40
|
|
|
40
|
-
let
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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"),
|
|
53
|
+
|
|
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"),
|
|
50
63
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
underline: init("\x1b[4m", "\x1b[24m"),
|
|
60
|
-
inverse: init("\x1b[7m", "\x1b[27m"),
|
|
61
|
-
hidden: init("\x1b[8m", "\x1b[28m"),
|
|
62
|
-
strikethrough: init("\x1b[9m", "\x1b[29m"),
|
|
63
|
-
black: init("\x1b[30m", "\x1b[39m"),
|
|
64
|
-
red: init("\x1b[31m", "\x1b[39m"),
|
|
65
|
-
green: init("\x1b[32m", "\x1b[39m"),
|
|
66
|
-
yellow: init("\x1b[33m", "\x1b[39m"),
|
|
67
|
-
blue: init("\x1b[34m", "\x1b[39m"),
|
|
68
|
-
magenta: init("\x1b[35m", "\x1b[39m"),
|
|
69
|
-
cyan: init("\x1b[36m", "\x1b[39m"),
|
|
70
|
-
white: init("\x1b[37m", "\x1b[39m"),
|
|
71
|
-
gray: init("\x1b[90m", "\x1b[39m"),
|
|
72
|
-
bgBlack: init("\x1b[40m", "\x1b[49m"),
|
|
73
|
-
bgRed: init("\x1b[41m", "\x1b[49m"),
|
|
74
|
-
bgGreen: init("\x1b[42m", "\x1b[49m"),
|
|
75
|
-
bgYellow: init("\x1b[43m", "\x1b[49m"),
|
|
76
|
-
bgBlue: init("\x1b[44m", "\x1b[49m"),
|
|
77
|
-
bgMagenta: init("\x1b[45m", "\x1b[49m"),
|
|
78
|
-
bgCyan: init("\x1b[46m", "\x1b[49m"),
|
|
79
|
-
bgWhite: init("\x1b[47m", "\x1b[49m"),
|
|
80
|
-
}
|
|
81
|
-
};
|
|
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"),
|
|
82
72
|
|
|
83
|
-
|
|
84
|
-
|
|
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"),
|
|
81
|
+
|
|
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
|
+
};
|
|
92
|
+
|
|
93
|
+
picocolors.exports = createColors();
|
|
94
|
+
picocolors.exports.createColors = createColors;
|
|
95
|
+
return picocolors.exports;
|
|
96
|
+
}
|
|
85
97
|
|
|
86
|
-
var picocolorsExports =
|
|
98
|
+
var picocolorsExports = /*@__PURE__*/ requirePicocolors();
|
|
87
99
|
const colors = /*@__PURE__*/getDefaultExportFromCjs(picocolorsExports);
|
|
88
100
|
|
|
89
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()}}();`;
|
|
@@ -153,7 +165,7 @@ function joinUrlSegments(a, b) {
|
|
|
153
165
|
}
|
|
154
166
|
function toAssetPathFromHtml(filename, htmlPath, config) {
|
|
155
167
|
const relativeUrlPath = normalizePath(path.relative(config.root, htmlPath));
|
|
156
|
-
const toRelative = (filename2,
|
|
168
|
+
const toRelative = (filename2, _hostId) => getBaseInHTML(relativeUrlPath, config) + filename2;
|
|
157
169
|
return toOutputFilePathInHtml(
|
|
158
170
|
filename,
|
|
159
171
|
"asset",
|
|
@@ -288,11 +300,13 @@ function viteLegacyPlugin(options = {}) {
|
|
|
288
300
|
if (!modernPolyfills.size) {
|
|
289
301
|
return;
|
|
290
302
|
}
|
|
291
|
-
isDebug
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
303
|
+
if (isDebug) {
|
|
304
|
+
console.log(
|
|
305
|
+
`[@vitejs/plugin-legacy] modern polyfills:`,
|
|
306
|
+
modernPolyfills
|
|
307
|
+
);
|
|
308
|
+
}
|
|
309
|
+
await buildPolyfillChunk(
|
|
296
310
|
config.mode,
|
|
297
311
|
modernPolyfills,
|
|
298
312
|
bundle,
|
|
@@ -300,11 +314,9 @@ function viteLegacyPlugin(options = {}) {
|
|
|
300
314
|
config.build,
|
|
301
315
|
"es",
|
|
302
316
|
opts,
|
|
303
|
-
true
|
|
317
|
+
true,
|
|
318
|
+
genLegacy
|
|
304
319
|
);
|
|
305
|
-
if (genLegacy && polyfillChunk) {
|
|
306
|
-
polyfillChunk.code = modernChunkLegacyGuard + polyfillChunk.code;
|
|
307
|
-
}
|
|
308
320
|
return;
|
|
309
321
|
}
|
|
310
322
|
if (!genLegacy) {
|
|
@@ -321,10 +333,12 @@ function viteLegacyPlugin(options = {}) {
|
|
|
321
333
|
);
|
|
322
334
|
}
|
|
323
335
|
if (legacyPolyfills.size || !options.externalSystemJS) {
|
|
324
|
-
isDebug
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
336
|
+
if (isDebug) {
|
|
337
|
+
console.log(
|
|
338
|
+
`[@vitejs/plugin-legacy] legacy polyfills:`,
|
|
339
|
+
legacyPolyfills
|
|
340
|
+
);
|
|
341
|
+
}
|
|
328
342
|
await buildPolyfillChunk(
|
|
329
343
|
config.mode,
|
|
330
344
|
legacyPolyfills,
|
|
@@ -353,12 +367,16 @@ function viteLegacyPlugin(options = {}) {
|
|
|
353
367
|
}
|
|
354
368
|
config = _config;
|
|
355
369
|
modernTargets = options.modernTargets || modernTargetsBabel;
|
|
356
|
-
|
|
370
|
+
if (isDebug) {
|
|
371
|
+
console.log(`[@vitejs/plugin-legacy] modernTargets:`, modernTargets);
|
|
372
|
+
}
|
|
357
373
|
if (!genLegacy || config.build.ssr) {
|
|
358
374
|
return;
|
|
359
375
|
}
|
|
360
376
|
targets = options.targets || browserslistLoadConfig({ path: config.root }) || "last 2 versions and not dead, > 0.3%, Firefox ESR";
|
|
361
|
-
|
|
377
|
+
if (isDebug) {
|
|
378
|
+
console.log(`[@vitejs/plugin-legacy] targets:`, targets);
|
|
379
|
+
}
|
|
362
380
|
const getLegacyOutputFileName = (fileNames, defaultFileName = "[name]-legacy-[hash].js") => {
|
|
363
381
|
if (!fileNames) {
|
|
364
382
|
return path.posix.join(config.build.assetsDir, defaultFileName);
|
|
@@ -462,7 +480,6 @@ function viteLegacyPlugin(options = {}) {
|
|
|
462
480
|
compact: !!config.build.minify,
|
|
463
481
|
sourceMaps,
|
|
464
482
|
inputSourceMap: void 0,
|
|
465
|
-
// sourceMaps ? chunk.map : undefined, `.map` TODO: moved to OutputChunk?
|
|
466
483
|
presets: [
|
|
467
484
|
// forcing our plugin to run before preset-env by wrapping it in a
|
|
468
485
|
// preset so we can catch the injected import statements...
|
|
@@ -481,15 +498,12 @@ function viteLegacyPlugin(options = {}) {
|
|
|
481
498
|
]
|
|
482
499
|
]
|
|
483
500
|
});
|
|
484
|
-
if (result)
|
|
485
|
-
return { code: result.code, map: result.map };
|
|
501
|
+
if (result) return { code: result.code, map: result.map };
|
|
486
502
|
return null;
|
|
487
503
|
},
|
|
488
504
|
transformIndexHtml(html, { chunk }) {
|
|
489
|
-
if (config.build.ssr)
|
|
490
|
-
|
|
491
|
-
if (!chunk)
|
|
492
|
-
return;
|
|
505
|
+
if (config.build.ssr) return;
|
|
506
|
+
if (!chunk) return;
|
|
493
507
|
if (chunk.fileName.includes("-legacy")) {
|
|
494
508
|
facadeToLegacyChunkMap.set(chunk.facadeModuleId, chunk.fileName);
|
|
495
509
|
if (genModern) {
|
|
@@ -657,8 +671,8 @@ function createBabelPresetEnvOptions(targets, { needPolyfills = true }) {
|
|
|
657
671
|
ignoreBrowserslistConfig: true
|
|
658
672
|
};
|
|
659
673
|
}
|
|
660
|
-
async function buildPolyfillChunk(mode, imports, bundle, facadeToChunkMap, buildOptions, format, rollupOutputOptions, excludeSystemJS) {
|
|
661
|
-
let { minify, assetsDir } = buildOptions;
|
|
674
|
+
async function buildPolyfillChunk(mode, imports, bundle, facadeToChunkMap, buildOptions, format, rollupOutputOptions, excludeSystemJS, prependModenChunkLegacyGuard) {
|
|
675
|
+
let { minify, assetsDir, sourcemap } = buildOptions;
|
|
662
676
|
minify = minify ? "terser" : false;
|
|
663
677
|
const res = await build({
|
|
664
678
|
mode,
|
|
@@ -666,11 +680,15 @@ async function buildPolyfillChunk(mode, imports, bundle, facadeToChunkMap, build
|
|
|
666
680
|
root: path.dirname(fileURLToPath(import.meta.url)),
|
|
667
681
|
configFile: false,
|
|
668
682
|
logLevel: "error",
|
|
669
|
-
plugins: [
|
|
683
|
+
plugins: [
|
|
684
|
+
polyfillsPlugin(imports, excludeSystemJS),
|
|
685
|
+
prependModenChunkLegacyGuard && prependModenChunkLegacyGuardPlugin()
|
|
686
|
+
],
|
|
670
687
|
build: {
|
|
671
688
|
write: false,
|
|
672
689
|
minify,
|
|
673
690
|
assetsDir,
|
|
691
|
+
sourcemap,
|
|
674
692
|
rollupOptions: {
|
|
675
693
|
input: {
|
|
676
694
|
polyfills: polyfillId
|
|
@@ -695,9 +713,10 @@ async function buildPolyfillChunk(mode, imports, bundle, facadeToChunkMap, build
|
|
|
695
713
|
}
|
|
696
714
|
});
|
|
697
715
|
const _polyfillChunk = Array.isArray(res) ? res[0] : res;
|
|
698
|
-
if (!("output" in _polyfillChunk))
|
|
699
|
-
|
|
700
|
-
|
|
716
|
+
if (!("output" in _polyfillChunk)) return;
|
|
717
|
+
const polyfillChunk = _polyfillChunk.output.find(
|
|
718
|
+
(chunk) => chunk.type === "chunk" && chunk.isEntry
|
|
719
|
+
);
|
|
701
720
|
for (const key in bundle) {
|
|
702
721
|
const chunk = bundle[key];
|
|
703
722
|
if (chunk.type === "chunk" && chunk.facadeModuleId) {
|
|
@@ -705,7 +724,14 @@ async function buildPolyfillChunk(mode, imports, bundle, facadeToChunkMap, build
|
|
|
705
724
|
}
|
|
706
725
|
}
|
|
707
726
|
bundle[polyfillChunk.fileName] = polyfillChunk;
|
|
708
|
-
|
|
727
|
+
if (polyfillChunk.sourcemapFileName) {
|
|
728
|
+
const polyfillChunkMapAsset = _polyfillChunk.output.find(
|
|
729
|
+
(chunk) => chunk.type === "asset" && chunk.fileName === polyfillChunk.sourcemapFileName
|
|
730
|
+
);
|
|
731
|
+
if (polyfillChunkMapAsset) {
|
|
732
|
+
bundle[polyfillChunk.sourcemapFileName] = polyfillChunkMapAsset;
|
|
733
|
+
}
|
|
734
|
+
}
|
|
709
735
|
}
|
|
710
736
|
const polyfillId = "\0vite/legacy-polyfills";
|
|
711
737
|
function polyfillsPlugin(imports, excludeSystemJS) {
|
|
@@ -723,6 +749,26 @@ function polyfillsPlugin(imports, excludeSystemJS) {
|
|
|
723
749
|
}
|
|
724
750
|
};
|
|
725
751
|
}
|
|
752
|
+
function prependModenChunkLegacyGuardPlugin() {
|
|
753
|
+
let sourceMapEnabled;
|
|
754
|
+
return {
|
|
755
|
+
name: "vite:legacy-prepend-moden-chunk-legacy-guard",
|
|
756
|
+
configResolved(config) {
|
|
757
|
+
sourceMapEnabled = !!config.build.sourcemap;
|
|
758
|
+
},
|
|
759
|
+
renderChunk(code) {
|
|
760
|
+
if (!sourceMapEnabled) {
|
|
761
|
+
return modernChunkLegacyGuard + code;
|
|
762
|
+
}
|
|
763
|
+
const ms = new MagicString(code);
|
|
764
|
+
ms.prepend(modernChunkLegacyGuard);
|
|
765
|
+
return {
|
|
766
|
+
code: ms.toString(),
|
|
767
|
+
map: ms.generateMap({ hires: "boundary" })
|
|
768
|
+
};
|
|
769
|
+
}
|
|
770
|
+
};
|
|
771
|
+
}
|
|
726
772
|
function isLegacyChunk(chunk, options) {
|
|
727
773
|
return options.format === "system" && chunk.fileName.includes("-legacy");
|
|
728
774
|
}
|
|
@@ -774,11 +820,15 @@ function wrapIIFEBabelPlugin() {
|
|
|
774
820
|
};
|
|
775
821
|
};
|
|
776
822
|
}
|
|
823
|
+
const hash = (
|
|
824
|
+
// eslint-disable-next-line n/no-unsupported-features/node-builtins -- crypto.hash is supported in Node 21.7.0+, 20.12.0+
|
|
825
|
+
crypto.hash ?? ((algorithm, data, outputEncoding) => crypto.createHash(algorithm).update(data).digest(outputEncoding))
|
|
826
|
+
);
|
|
777
827
|
const cspHashes = [
|
|
778
828
|
safari10NoModuleFix,
|
|
779
829
|
systemJSInlineCode,
|
|
780
830
|
detectModernBrowserCode,
|
|
781
831
|
dynamicFallbackInlineCode
|
|
782
|
-
].map((i) =>
|
|
832
|
+
].map((i) => hash("sha256", i, "base64"));
|
|
783
833
|
|
|
784
834
|
export { cspHashes, viteLegacyPlugin as default, detectPolyfills };
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitejs/plugin-legacy",
|
|
3
|
-
"version": "
|
|
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 ||
|
|
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.
|
|
39
|
-
"@babel/preset-env": "^7.
|
|
40
|
-
"browserslist": "^4.
|
|
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.
|
|
43
|
-
"magic-string": "^0.30.
|
|
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.
|
|
49
|
-
"vite": "^
|
|
49
|
+
"terser": "^5.16.0",
|
|
50
|
+
"vite": "^6.0.0"
|
|
50
51
|
},
|
|
51
52
|
"devDependencies": {
|
|
52
|
-
"acorn": "^8.
|
|
53
|
-
"picocolors": "^1.
|
|
54
|
-
"unbuild": "^
|
|
55
|
-
"vite": "
|
|
53
|
+
"acorn": "^8.14.0",
|
|
54
|
+
"picocolors": "^1.1.1",
|
|
55
|
+
"unbuild": "^3.0.0-rc.11",
|
|
56
|
+
"vite": "6.0.0"
|
|
56
57
|
},
|
|
57
58
|
"scripts": {
|
|
58
59
|
"dev": "unbuild --stub",
|