@vitejs/plugin-legacy 6.1.1 → 7.0.0-beta.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/README.md CHANGED
@@ -129,6 +129,8 @@ npm add -D terser
129
129
 
130
130
  Set to `false` to only output the legacy bundles that support all target browsers.
131
131
 
132
+ This is also useful when running the project locally using `file:` protocol, as loading modern chunks with `type="module"` may trigger CORS restrictions. To avoid this issue, simply set `renderModernChunks` to `false` to exclusively use legacy chunks instead.
133
+
132
134
  ## Browsers that supports ESM but does not support widely-available features
133
135
 
134
136
  The legacy plugin offers a way to use widely-available features natively in the modern build, while falling back to the legacy build in browsers with native ESM but without those features supported (e.g. Legacy Edge). This feature works by injecting a runtime check and loading the legacy bundle with SystemJs runtime if needed. There are the following drawbacks:
@@ -179,7 +181,7 @@ The current values are:
179
181
 
180
182
  - `sha256-MS6/3FCg4WjP9gwgaBGwLpRCY6fZBgwmhVCdrPrNf3E=`
181
183
  - `sha256-tQjf8gvb2ROOMapIxFvFAYBeUJ0v1HCbOcSmDNXGtDo=`
182
- - `sha256-VA8O2hAdooB288EpSTrGLl7z3QikbWU9wwoebO/QaYk=`
184
+ - `sha256-ZxAi3a7m9Mzbc+Z1LGuCCK5Xee6reDkEPRas66H9KSo=`
183
185
  - `sha256-+5XkZFazzJo8n0iOP4ti/cLCMUudTf//Mzkb7xNPXIc=`
184
186
 
185
187
  <!--
package/dist/index.d.ts CHANGED
@@ -1,47 +1,49 @@
1
- import { Plugin } from 'vite';
1
+ import { Plugin } from "vite";
2
2
 
3
+ //#region src/types.d.ts
3
4
  interface Options {
4
- /**
5
- * default: 'defaults'
6
- */
7
- targets?: string | string[] | Record<string, string>;
8
- /**
9
- * default: 'edge>=79, firefox>=67, chrome>=64, safari>=12, chromeAndroid>=64, iOS>=12'
10
- */
11
- modernTargets?: string | string[];
12
- /**
13
- * default: true
14
- */
15
- polyfills?: boolean | string[];
16
- additionalLegacyPolyfills?: string[];
17
- additionalModernPolyfills?: string[];
18
- /**
19
- * default: false
20
- */
21
- modernPolyfills?: boolean | string[];
22
- /**
23
- * default: true
24
- */
25
- renderLegacyChunks?: boolean;
26
- /**
27
- * default: false
28
- */
29
- externalSystemJS?: boolean;
30
- /**
31
- * default: true
32
- */
33
- renderModernChunks?: boolean;
34
- /**
35
- * @see https://babeljs.io/docs/assumptions
36
- *
37
- * default: {}
38
- */
39
- assumptions?: Record<string, boolean>;
5
+ /**
6
+ * default: 'defaults'
7
+ */
8
+ targets?: string | string[] | Record<string, string>;
9
+ /**
10
+ * default: 'edge>=79, firefox>=67, chrome>=64, safari>=12, chromeAndroid>=64, iOS>=12'
11
+ */
12
+ modernTargets?: string | string[];
13
+ /**
14
+ * default: true
15
+ */
16
+ polyfills?: boolean | string[];
17
+ additionalLegacyPolyfills?: string[];
18
+ additionalModernPolyfills?: string[];
19
+ /**
20
+ * default: false
21
+ */
22
+ modernPolyfills?: boolean | string[];
23
+ /**
24
+ * default: true
25
+ */
26
+ renderLegacyChunks?: boolean;
27
+ /**
28
+ * default: false
29
+ */
30
+ externalSystemJS?: boolean;
31
+ /**
32
+ * default: true
33
+ */
34
+ renderModernChunks?: boolean;
35
+ /**
36
+ * @see https://babeljs.io/docs/assumptions
37
+ *
38
+ * default: {}
39
+ */
40
+ assumptions?: Record<string, boolean>;
40
41
  }
41
-
42
+ //#endregion
43
+ //#region src/index.d.ts
42
44
  declare function viteLegacyPlugin(options?: Options): Plugin[];
43
45
  declare function detectPolyfills(code: string, targets: any, assumptions: Record<string, boolean>, list: Set<string>): Promise<void>;
44
46
  declare const cspHashes: string[];
45
-
46
- export { cspHashes, viteLegacyPlugin as default, detectPolyfills };
47
- export type { Options };
47
+ declare function viteLegacyPluginCjs(this: unknown, options: Options): Plugin[];
48
+ //#endregion
49
+ export { Options, cspHashes, viteLegacyPlugin as default, detectPolyfills, viteLegacyPluginCjs as "module.exports" };