@vitejs/plugin-legacy 4.0.0 → 4.0.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/README.md +2 -2
- package/dist/index.cjs +5 -4
- package/dist/index.mjs +4 -3
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -159,8 +159,8 @@ The legacy plugin requires inline scripts for [Safari 10.1 `nomodule` fix](https
|
|
|
159
159
|
|
|
160
160
|
- `sha256-MS6/3FCg4WjP9gwgaBGwLpRCY6fZBgwmhVCdrPrNf3E=`
|
|
161
161
|
- `sha256-tQjf8gvb2ROOMapIxFvFAYBeUJ0v1HCbOcSmDNXGtDo=`
|
|
162
|
-
- `sha256-
|
|
163
|
-
- `sha256
|
|
162
|
+
- `sha256-p7PoC97FO+Lu90RNjGWxhbm13yALSR4xzV8vaDhaQBo=`
|
|
163
|
+
- `sha256-+5XkZFazzJo8n0iOP4ti/cLCMUudTf//Mzkb7xNPXIc=`
|
|
164
164
|
|
|
165
165
|
<!--
|
|
166
166
|
Run `node --input-type=module -e "import {cspHashes} from '@vitejs/plugin-legacy'; console.log(cspHashes.map(h => 'sha256-'+h))"` to retrieve the value.
|
package/dist/index.cjs
CHANGED
|
@@ -93,6 +93,7 @@ async function loadBabel() {
|
|
|
93
93
|
}
|
|
94
94
|
return babel;
|
|
95
95
|
}
|
|
96
|
+
const { loadConfig: browserslistLoadConfig } = browserslist;
|
|
96
97
|
function toOutputFilePathInHtml(filename, type, hostId, hostType, config, toRelative) {
|
|
97
98
|
const { renderBuiltUrl } = config.experimental;
|
|
98
99
|
let relative = config.base === "" || config.base === "./";
|
|
@@ -141,7 +142,7 @@ function toAssetPathFromHtml(filename, htmlPath, config) {
|
|
|
141
142
|
);
|
|
142
143
|
}
|
|
143
144
|
const legacyEnvVarMarker = `__VITE_IS_LEGACY__`;
|
|
144
|
-
const _require = node_module.createRequire((typeof document === 'undefined' ?
|
|
145
|
+
const _require = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('index.cjs', document.baseURI).href)));
|
|
145
146
|
function viteLegacyPlugin(options = {}) {
|
|
146
147
|
let config;
|
|
147
148
|
let targets;
|
|
@@ -180,7 +181,7 @@ function viteLegacyPlugin(options = {}) {
|
|
|
180
181
|
const legacyConfigPlugin = {
|
|
181
182
|
name: "vite:legacy-config",
|
|
182
183
|
config(config2, env) {
|
|
183
|
-
if (env.command === "build") {
|
|
184
|
+
if (env.command === "build" && !config2.build?.ssr) {
|
|
184
185
|
if (!config2.build) {
|
|
185
186
|
config2.build = {};
|
|
186
187
|
}
|
|
@@ -281,7 +282,7 @@ function viteLegacyPlugin(options = {}) {
|
|
|
281
282
|
if (!genLegacy || config.build.ssr) {
|
|
282
283
|
return;
|
|
283
284
|
}
|
|
284
|
-
targets = options.targets ||
|
|
285
|
+
targets = options.targets || browserslistLoadConfig({ path: config.root }) || "last 2 versions and not dead, > 0.3%, Firefox ESR";
|
|
285
286
|
isDebug && console.log(`[@vitejs/plugin-legacy] targets:`, targets);
|
|
286
287
|
const getLegacyOutputFileName = (fileNames, defaultFileName = "[name]-legacy-[hash].js") => {
|
|
287
288
|
if (!fileNames) {
|
|
@@ -560,7 +561,7 @@ async function buildPolyfillChunk(mode, imports, bundle, facadeToChunkMap, build
|
|
|
560
561
|
const res = await vite.build({
|
|
561
562
|
mode,
|
|
562
563
|
// so that everything is resolved from here
|
|
563
|
-
root: path.dirname(node_url.fileURLToPath((typeof document === 'undefined' ?
|
|
564
|
+
root: path.dirname(node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('index.cjs', document.baseURI).href)))),
|
|
564
565
|
configFile: false,
|
|
565
566
|
logLevel: "error",
|
|
566
567
|
plugins: [polyfillsPlugin(imports, excludeSystemJS)],
|
package/dist/index.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
5
5
|
import { build, normalizePath } from 'vite';
|
|
6
6
|
import MagicString from 'magic-string';
|
|
7
7
|
import require$$0 from 'tty';
|
|
8
|
-
import
|
|
8
|
+
import browserslist from 'browserslist';
|
|
9
9
|
|
|
10
10
|
var picocolorsExports = {};
|
|
11
11
|
var picocolors = {
|
|
@@ -89,6 +89,7 @@ async function loadBabel() {
|
|
|
89
89
|
}
|
|
90
90
|
return babel;
|
|
91
91
|
}
|
|
92
|
+
const { loadConfig: browserslistLoadConfig } = browserslist;
|
|
92
93
|
function toOutputFilePathInHtml(filename, type, hostId, hostType, config, toRelative) {
|
|
93
94
|
const { renderBuiltUrl } = config.experimental;
|
|
94
95
|
let relative = config.base === "" || config.base === "./";
|
|
@@ -176,7 +177,7 @@ function viteLegacyPlugin(options = {}) {
|
|
|
176
177
|
const legacyConfigPlugin = {
|
|
177
178
|
name: "vite:legacy-config",
|
|
178
179
|
config(config2, env) {
|
|
179
|
-
if (env.command === "build") {
|
|
180
|
+
if (env.command === "build" && !config2.build?.ssr) {
|
|
180
181
|
if (!config2.build) {
|
|
181
182
|
config2.build = {};
|
|
182
183
|
}
|
|
@@ -277,7 +278,7 @@ function viteLegacyPlugin(options = {}) {
|
|
|
277
278
|
if (!genLegacy || config.build.ssr) {
|
|
278
279
|
return;
|
|
279
280
|
}
|
|
280
|
-
targets = options.targets ||
|
|
281
|
+
targets = options.targets || browserslistLoadConfig({ path: config.root }) || "last 2 versions and not dead, > 0.3%, Firefox ESR";
|
|
281
282
|
isDebug && console.log(`[@vitejs/plugin-legacy] targets:`, targets);
|
|
282
283
|
const getLegacyOutputFileName = (fileNames, defaultFileName = "[name]-legacy-[hash].js") => {
|
|
283
284
|
if (!fileNames) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitejs/plugin-legacy",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Evan You",
|
|
6
6
|
"files": [
|
|
@@ -41,13 +41,13 @@
|
|
|
41
41
|
},
|
|
42
42
|
"homepage": "https://github.com/vitejs/vite/tree/main/packages/plugin-legacy#readme",
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@babel/core": "^7.
|
|
44
|
+
"@babel/core": "^7.21.0",
|
|
45
45
|
"@babel/preset-env": "^7.20.2",
|
|
46
|
-
"browserslist": "^4.21.
|
|
47
|
-
"core-js": "^3.
|
|
48
|
-
"magic-string": "^0.
|
|
46
|
+
"browserslist": "^4.21.5",
|
|
47
|
+
"core-js": "^3.29.0",
|
|
48
|
+
"magic-string": "^0.30.0",
|
|
49
49
|
"regenerator-runtime": "^0.13.11",
|
|
50
|
-
"systemjs": "^6.
|
|
50
|
+
"systemjs": "^6.14.0"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"terser": "^5.4.0",
|