@vitejs/plugin-legacy 2.2.0 → 2.3.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/dist/index.cjs +18 -22
- package/dist/index.mjs +10 -8
- package/package.json +7 -7
package/dist/index.cjs
CHANGED
|
@@ -10,15 +10,9 @@ const vite = require('vite');
|
|
|
10
10
|
const MagicString = require('magic-string');
|
|
11
11
|
const require$$0 = require('tty');
|
|
12
12
|
|
|
13
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
|
|
14
|
-
|
|
15
|
-
const path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
|
16
|
-
const MagicString__default = /*#__PURE__*/_interopDefaultLegacy(MagicString);
|
|
17
|
-
const require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
|
|
18
|
-
|
|
19
13
|
var picocolors = {exports: {}};
|
|
20
14
|
|
|
21
|
-
let tty = require$$
|
|
15
|
+
let tty = require$$0;
|
|
22
16
|
|
|
23
17
|
let isColorSupported =
|
|
24
18
|
!("NO_COLOR" in process.env || process.argv.includes("--no-color")) &&
|
|
@@ -114,13 +108,13 @@ function toOutputFilePathInHtml(filename, type, hostId, hostType, config, toRela
|
|
|
114
108
|
}
|
|
115
109
|
}
|
|
116
110
|
function getBaseInHTML(urlRelativePath, config) {
|
|
117
|
-
return config.base === "./" || config.base === "" ?
|
|
118
|
-
|
|
111
|
+
return config.base === "./" || config.base === "" ? path.posix.join(
|
|
112
|
+
path.posix.relative(urlRelativePath, "").slice(0, -2),
|
|
119
113
|
"./"
|
|
120
114
|
) : config.base;
|
|
121
115
|
}
|
|
122
116
|
function toAssetPathFromHtml(filename, htmlPath, config) {
|
|
123
|
-
const relativeUrlPath = vite.normalizePath(
|
|
117
|
+
const relativeUrlPath = vite.normalizePath(path.relative(config.root, htmlPath));
|
|
124
118
|
const toRelative = (filename2, hostId) => getBaseInHTML(relativeUrlPath, config) + filename2;
|
|
125
119
|
return toOutputFilePathInHtml(
|
|
126
120
|
filename,
|
|
@@ -187,14 +181,16 @@ function viteLegacyPlugin(options = {}) {
|
|
|
187
181
|
if (!config2.build.cssTarget) {
|
|
188
182
|
config2.build.cssTarget = "chrome61";
|
|
189
183
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
184
|
+
if (genLegacy) {
|
|
185
|
+
overriddenBuildTarget = config2.build.target !== void 0;
|
|
186
|
+
config2.build.target = [
|
|
187
|
+
"es2020",
|
|
188
|
+
"edge79",
|
|
189
|
+
"firefox67",
|
|
190
|
+
"chrome64",
|
|
191
|
+
"safari11.1"
|
|
192
|
+
];
|
|
193
|
+
}
|
|
198
194
|
}
|
|
199
195
|
return {
|
|
200
196
|
define: {
|
|
@@ -279,7 +275,7 @@ function viteLegacyPlugin(options = {}) {
|
|
|
279
275
|
}
|
|
280
276
|
const getLegacyOutputFileName = (fileNames, defaultFileName = "[name]-legacy.[hash].js") => {
|
|
281
277
|
if (!fileNames) {
|
|
282
|
-
return
|
|
278
|
+
return path.posix.join(config.build.assetsDir, defaultFileName);
|
|
283
279
|
}
|
|
284
280
|
return (chunkInfo) => {
|
|
285
281
|
let fileName = typeof fileNames === "function" ? fileNames(chunkInfo) : fileNames;
|
|
@@ -315,7 +311,7 @@ function viteLegacyPlugin(options = {}) {
|
|
|
315
311
|
if (options.modernPolyfills && !Array.isArray(options.modernPolyfills)) {
|
|
316
312
|
await detectPolyfills(raw, { esmodules: true }, modernPolyfills);
|
|
317
313
|
}
|
|
318
|
-
const ms = new
|
|
314
|
+
const ms = new MagicString(raw);
|
|
319
315
|
if (genDynamicFallback && chunk.isEntry) {
|
|
320
316
|
ms.prepend(forceDynamicImportUsage);
|
|
321
317
|
}
|
|
@@ -545,7 +541,7 @@ async function buildPolyfillChunk(mode, imports, bundle, facadeToChunkMap, build
|
|
|
545
541
|
minify = minify ? "terser" : false;
|
|
546
542
|
const res = await vite.build({
|
|
547
543
|
mode,
|
|
548
|
-
root:
|
|
544
|
+
root: path.dirname(node_url.fileURLToPath((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('index.cjs', document.baseURI).href)))),
|
|
549
545
|
configFile: false,
|
|
550
546
|
logLevel: "error",
|
|
551
547
|
plugins: [polyfillsPlugin(imports, excludeSystemJS)],
|
|
@@ -658,5 +654,5 @@ const cspHashes = [
|
|
|
658
654
|
|
|
659
655
|
module.exports = viteLegacyPlugin;
|
|
660
656
|
module.exports.cspHashes = cspHashes;
|
|
661
|
-
module.exports
|
|
657
|
+
module.exports.default = viteLegacyPlugin;
|
|
662
658
|
module.exports.detectPolyfills = detectPolyfills;
|
package/dist/index.mjs
CHANGED
|
@@ -177,14 +177,16 @@ function viteLegacyPlugin(options = {}) {
|
|
|
177
177
|
if (!config2.build.cssTarget) {
|
|
178
178
|
config2.build.cssTarget = "chrome61";
|
|
179
179
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
180
|
+
if (genLegacy) {
|
|
181
|
+
overriddenBuildTarget = config2.build.target !== void 0;
|
|
182
|
+
config2.build.target = [
|
|
183
|
+
"es2020",
|
|
184
|
+
"edge79",
|
|
185
|
+
"firefox67",
|
|
186
|
+
"chrome64",
|
|
187
|
+
"safari11.1"
|
|
188
|
+
];
|
|
189
|
+
}
|
|
188
190
|
}
|
|
189
191
|
return {
|
|
190
192
|
define: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitejs/plugin-legacy",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Evan You",
|
|
6
6
|
"files": [
|
|
@@ -35,18 +35,18 @@
|
|
|
35
35
|
},
|
|
36
36
|
"homepage": "https://github.com/vitejs/vite/tree/main/packages/plugin-legacy#readme",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@babel/standalone": "^7.19.
|
|
39
|
-
"core-js": "^3.
|
|
40
|
-
"magic-string": "^0.26.
|
|
41
|
-
"regenerator-runtime": "^0.13.
|
|
42
|
-
"systemjs": "^6.
|
|
38
|
+
"@babel/standalone": "^7.19.6",
|
|
39
|
+
"core-js": "^3.26.0",
|
|
40
|
+
"magic-string": "^0.26.7",
|
|
41
|
+
"regenerator-runtime": "^0.13.10",
|
|
42
|
+
"systemjs": "^6.13.0"
|
|
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.19.
|
|
49
|
+
"@babel/core": "^7.19.6",
|
|
50
50
|
"picocolors": "^1.0.0",
|
|
51
51
|
"vite": "workspace:*"
|
|
52
52
|
}
|