@vitejs/plugin-legacy 7.0.0 → 7.0.1
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.js +22 -19
- package/package.json +9 -7
package/dist/index.js
CHANGED
|
@@ -200,7 +200,7 @@ function viteLegacyPlugin(options = {}) {
|
|
|
200
200
|
async config(config$1, env$1) {
|
|
201
201
|
if (env$1.command === "build" && !config$1.build?.ssr) {
|
|
202
202
|
if (!config$1.build) config$1.build = {};
|
|
203
|
-
if (!config$1.build.cssTarget) config$1.build.cssTarget = "chrome61";
|
|
203
|
+
if (genLegacy && !config$1.build.cssTarget) config$1.build.cssTarget = "chrome61";
|
|
204
204
|
if (genLegacy) {
|
|
205
205
|
overriddenBuildTarget = config$1.build.target !== void 0;
|
|
206
206
|
overriddenDefaultModernTargets = options.modernTargets !== void 0;
|
|
@@ -320,12 +320,23 @@ function viteLegacyPlugin(options = {}) {
|
|
|
320
320
|
compact: !!config.build.minify,
|
|
321
321
|
sourceMaps,
|
|
322
322
|
inputSourceMap: void 0,
|
|
323
|
+
targets,
|
|
323
324
|
assumptions,
|
|
325
|
+
browserslistConfigFile: false,
|
|
324
326
|
presets: [[() => ({ plugins: [
|
|
325
327
|
recordAndRemovePolyfillBabelPlugin(polyfillsDiscovered.legacy),
|
|
326
328
|
replaceLegacyEnvBabelPlugin(),
|
|
327
329
|
wrapIIFEBabelPlugin()
|
|
328
|
-
] })], [(await import("@babel/preset-env")).default,
|
|
330
|
+
] })], [(await import("@babel/preset-env")).default, {
|
|
331
|
+
bugfixes: true,
|
|
332
|
+
modules: false,
|
|
333
|
+
useBuiltIns: needPolyfills ? "usage" : false,
|
|
334
|
+
corejs: needPolyfills ? {
|
|
335
|
+
version: _require("core-js/package.json").version,
|
|
336
|
+
proposals: false
|
|
337
|
+
} : void 0,
|
|
338
|
+
shippedProposals: true
|
|
339
|
+
}]]
|
|
329
340
|
});
|
|
330
341
|
if (result) return {
|
|
331
342
|
code: result.code,
|
|
@@ -412,7 +423,7 @@ function viteLegacyPlugin(options = {}) {
|
|
|
412
423
|
generateBundle(opts, bundle) {
|
|
413
424
|
if (config.build.ssr) return;
|
|
414
425
|
if (isLegacyBundle(bundle, opts) && genModern) {
|
|
415
|
-
for (const name in bundle) if (bundle[name].type === "asset" &&
|
|
426
|
+
for (const name in bundle) if (bundle[name].type === "asset" && !name.endsWith(".map")) delete bundle[name];
|
|
416
427
|
}
|
|
417
428
|
}
|
|
418
429
|
};
|
|
@@ -426,32 +437,24 @@ async function detectPolyfills(code, targets, assumptions, list) {
|
|
|
426
437
|
const babel$1 = await loadBabel();
|
|
427
438
|
const result = babel$1.transform(code, {
|
|
428
439
|
ast: true,
|
|
440
|
+
code: false,
|
|
429
441
|
babelrc: false,
|
|
430
442
|
configFile: false,
|
|
431
443
|
compact: false,
|
|
444
|
+
targets,
|
|
432
445
|
assumptions,
|
|
433
|
-
|
|
446
|
+
browserslistConfigFile: false,
|
|
447
|
+
plugins: [[(await import("babel-plugin-polyfill-corejs3")).default, {
|
|
448
|
+
method: "usage-global",
|
|
449
|
+
version: _require("core-js/package.json").version,
|
|
450
|
+
shippedProposals: true
|
|
451
|
+
}], [(await import("babel-plugin-polyfill-regenerator")).default, { method: "usage-global" }]]
|
|
434
452
|
});
|
|
435
453
|
for (const node of result.ast.program.body) if (node.type === "ImportDeclaration") {
|
|
436
454
|
const source = node.source.value;
|
|
437
455
|
if (source.startsWith("core-js/") || source.startsWith("regenerator-runtime/")) list.add(source);
|
|
438
456
|
}
|
|
439
457
|
}
|
|
440
|
-
function createBabelPresetEnvOptions(targets, { needPolyfills = true }) {
|
|
441
|
-
return {
|
|
442
|
-
targets,
|
|
443
|
-
bugfixes: true,
|
|
444
|
-
loose: false,
|
|
445
|
-
modules: false,
|
|
446
|
-
useBuiltIns: needPolyfills ? "usage" : false,
|
|
447
|
-
corejs: needPolyfills ? {
|
|
448
|
-
version: _require("core-js/package.json").version,
|
|
449
|
-
proposals: false
|
|
450
|
-
} : void 0,
|
|
451
|
-
shippedProposals: true,
|
|
452
|
-
ignoreBrowserslistConfig: true
|
|
453
|
-
};
|
|
454
|
-
}
|
|
455
458
|
async function buildPolyfillChunk(mode, imports, bundle, facadeToChunkMap, buildOptions, format, rollupOutputOptions, excludeSystemJS, prependModenChunkLegacyGuard) {
|
|
456
459
|
let { minify, assetsDir, sourcemap } = buildOptions;
|
|
457
460
|
minify = minify ? "terser" : false;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitejs/plugin-legacy",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Evan You",
|
|
@@ -28,11 +28,13 @@
|
|
|
28
28
|
"homepage": "https://github.com/vitejs/vite/tree/main/packages/plugin-legacy#readme",
|
|
29
29
|
"funding": "https://github.com/vitejs/vite?sponsor=1",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@babel/core": "^7.
|
|
32
|
-
"@babel/preset-env": "^7.
|
|
33
|
-
"
|
|
31
|
+
"@babel/core": "^7.28.0",
|
|
32
|
+
"@babel/preset-env": "^7.28.0",
|
|
33
|
+
"babel-plugin-polyfill-corejs3": "^0.13.0",
|
|
34
|
+
"babel-plugin-polyfill-regenerator": "^0.6.5",
|
|
35
|
+
"browserslist": "^4.25.1",
|
|
34
36
|
"browserslist-to-esbuild": "^2.1.1",
|
|
35
|
-
"core-js": "^3.
|
|
37
|
+
"core-js": "^3.44.0",
|
|
36
38
|
"magic-string": "^0.30.17",
|
|
37
39
|
"regenerator-runtime": "^0.14.1",
|
|
38
40
|
"systemjs": "^6.15.1"
|
|
@@ -44,8 +46,8 @@
|
|
|
44
46
|
"devDependencies": {
|
|
45
47
|
"acorn": "^8.15.0",
|
|
46
48
|
"picocolors": "^1.1.1",
|
|
47
|
-
"tsdown": "^0.12.
|
|
48
|
-
"vite": "7.0.
|
|
49
|
+
"tsdown": "^0.12.9",
|
|
50
|
+
"vite": "7.0.5"
|
|
49
51
|
},
|
|
50
52
|
"scripts": {
|
|
51
53
|
"dev": "tsdown --watch",
|