@vitejs/plugin-legacy 5.0.0-beta.3 → 5.1.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/README.md CHANGED
@@ -152,22 +152,26 @@ export default {
152
152
 
153
153
  ## Content Security Policy
154
154
 
155
- The legacy plugin requires inline scripts for [Safari 10.1 `nomodule` fix](https://gist.github.com/samthor/64b114e4a4f539915a95b91ffd340acc), SystemJS initialization, and dynamic import fallback. If you have a strict CSP policy requirement, you will need to [add the corresponding hashes to your `script-src` list](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src#unsafe_inline_script):
155
+ The legacy plugin requires inline scripts for [Safari 10.1 `nomodule` fix](https://gist.github.com/samthor/64b114e4a4f539915a95b91ffd340acc), SystemJS initialization, and dynamic import fallback. If you have a strict CSP policy requirement, you will need to [add the corresponding hashes to your `script-src` list](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src#unsafe_inline_script).
156
+
157
+ The hash values (without the `sha256-` prefix) can be retrieved via:
158
+
159
+ ```js
160
+ import { cspHashes } from '@vitejs/plugin-legacy'
161
+ ```
162
+
163
+ The current values are:
156
164
 
157
165
  - `sha256-MS6/3FCg4WjP9gwgaBGwLpRCY6fZBgwmhVCdrPrNf3E=`
158
166
  - `sha256-tQjf8gvb2ROOMapIxFvFAYBeUJ0v1HCbOcSmDNXGtDo=`
159
- - `sha256-8uUkKieevHiD3yYtzjkRvyDZWt+uZkBLuGEQWNiV3+c=`
167
+ - `sha256-6gxDO54HJkJNWi7H6ipFpWWSkWSRpyuZYMGDyG6bcNE=`
160
168
  - `sha256-+5XkZFazzJo8n0iOP4ti/cLCMUudTf//Mzkb7xNPXIc=`
161
169
 
162
170
  <!--
163
171
  Run `node --input-type=module -e "import {cspHashes} from '@vitejs/plugin-legacy'; console.log(cspHashes.map(h => 'sha256-'+h))"` to retrieve the value.
164
172
  -->
165
173
 
166
- These values (without the `sha256-` prefix) can also be retrieved via
167
-
168
- ```js
169
- import { cspHashes } from '@vitejs/plugin-legacy'
170
- ```
174
+ Note that these values could change between minor versions. Thus, we recommend generating the CSP header from the exported `cspHashes` variable. If you copy the values manually, then you should pin the minor version using `~`.
171
175
 
172
176
  When using the `regenerator-runtime` polyfill, it will attempt to use the `globalThis` object to register itself. If `globalThis` is not available (it is [fairly new](https://caniuse.com/?search=globalThis) and not widely supported, including IE 11), it attempts to perform dynamic `Function(...)` call which violates the CSP. To avoid dynamic `eval` in the absence of `globalThis` consider adding `core-js/proposals/global-this` to `additionalLegacyPolyfills` to define it.
173
177
 
package/dist/index.cjs CHANGED
@@ -92,7 +92,7 @@ const legacyPolyfillId = "vite-legacy-polyfill";
92
92
  const legacyEntryId = "vite-legacy-entry";
93
93
  const systemJSInlineCode = `System.import(document.getElementById('${legacyEntryId}').getAttribute('data-src'))`;
94
94
  const detectModernBrowserVarName = "__vite_is_modern_browser";
95
- const detectModernBrowserDetector = 'import.meta.url;import("_").catch(()=>1);(async function* g(){})();';
95
+ const detectModernBrowserDetector = `import.meta.url;import("_").catch(()=>1);(async function*(){})().next()`;
96
96
  const detectModernBrowserCode = `${detectModernBrowserDetector}if(location.protocol!="file:"){window.${detectModernBrowserVarName}=true}`;
97
97
  const dynamicFallbackInlineCode = `!function(){if(window.${detectModernBrowserVarName})return;console.warn("vite: loading legacy chunks, syntax error above and the same error below should be ignored");var e=document.getElementById("${legacyPolyfillId}"),n=document.createElement("script");n.src=e.src,n.onload=function(){${systemJSInlineCode}},document.body.appendChild(n)}();`;
98
98
  const modernChunkLegacyGuard = `export function __vite_legacy_guard(){${detectModernBrowserDetector}};`;
package/dist/index.mjs CHANGED
@@ -80,7 +80,7 @@ const legacyPolyfillId = "vite-legacy-polyfill";
80
80
  const legacyEntryId = "vite-legacy-entry";
81
81
  const systemJSInlineCode = `System.import(document.getElementById('${legacyEntryId}').getAttribute('data-src'))`;
82
82
  const detectModernBrowserVarName = "__vite_is_modern_browser";
83
- const detectModernBrowserDetector = 'import.meta.url;import("_").catch(()=>1);(async function* g(){})();';
83
+ const detectModernBrowserDetector = `import.meta.url;import("_").catch(()=>1);(async function*(){})().next()`;
84
84
  const detectModernBrowserCode = `${detectModernBrowserDetector}if(location.protocol!="file:"){window.${detectModernBrowserVarName}=true}`;
85
85
  const dynamicFallbackInlineCode = `!function(){if(window.${detectModernBrowserVarName})return;console.warn("vite: loading legacy chunks, syntax error above and the same error below should be ignored");var e=document.getElementById("${legacyPolyfillId}"),n=document.createElement("script");n.src=e.src,n.onload=function(){${systemJSInlineCode}},document.body.appendChild(n)}();`;
86
86
  const modernChunkLegacyGuard = `export function __vite_legacy_guard(){${detectModernBrowserDetector}};`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitejs/plugin-legacy",
3
- "version": "5.0.0-beta.3",
3
+ "version": "5.1.0",
4
4
  "license": "MIT",
5
5
  "author": "Evan You",
6
6
  "files": [
@@ -45,12 +45,12 @@
45
45
  },
46
46
  "peerDependencies": {
47
47
  "terser": "^5.4.0",
48
- "vite": "^4.0.0"
48
+ "vite": "^5.0.0"
49
49
  },
50
50
  "devDependencies": {
51
51
  "acorn": "^8.11.2",
52
52
  "picocolors": "^1.0.0",
53
- "vite": "5.0.0-beta.19"
53
+ "vite": "5.0.1"
54
54
  },
55
55
  "scripts": {
56
56
  "dev": "unbuild --stub",