@vitejs/plugin-legacy 4.0.3 → 4.0.5

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
@@ -159,7 +159,7 @@ 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-p7PoC97FO+Lu90RNjGWxhbm13yALSR4xzV8vaDhaQBo=`
162
+ - `sha256-4y/gEB2/KIwZFTfNqwXJq4olzvmQ0S214m9jwKgNXoc=`
163
163
  - `sha256-+5XkZFazzJo8n0iOP4ti/cLCMUudTf//Mzkb7xNPXIc=`
164
164
 
165
165
  <!--
package/dist/index.cjs CHANGED
@@ -11,13 +11,20 @@ const MagicString = require('magic-string');
11
11
  const require$$0 = require('tty');
12
12
  const browserslist = require('browserslist');
13
13
 
14
- var picocolorsExports = {};
15
- var picocolors = {
16
- get exports(){ return picocolorsExports; },
17
- set exports(v){ picocolorsExports = v; },
18
- };
14
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
15
+
16
+ const path__default = /*#__PURE__*/_interopDefaultCompat(path);
17
+ const MagicString__default = /*#__PURE__*/_interopDefaultCompat(MagicString);
18
+ const require$$0__default = /*#__PURE__*/_interopDefaultCompat(require$$0);
19
+ const browserslist__default = /*#__PURE__*/_interopDefaultCompat(browserslist);
20
+
21
+ function getDefaultExportFromCjs (x) {
22
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
23
+ }
24
+
25
+ var picocolors = {exports: {}};
19
26
 
20
- let tty = require$$0;
27
+ let tty = require$$0__default;
21
28
 
22
29
  let isColorSupported =
23
30
  !("NO_COLOR" in process.env || process.argv.includes("--no-color")) &&
@@ -74,7 +81,10 @@ let createColors = (enabled = isColorSupported) => ({
74
81
  });
75
82
 
76
83
  picocolors.exports = createColors();
77
- picocolorsExports.createColors = createColors;
84
+ picocolors.exports.createColors = createColors;
85
+
86
+ var picocolorsExports = picocolors.exports;
87
+ const colors = /*@__PURE__*/getDefaultExportFromCjs(picocolorsExports);
78
88
 
79
89
  const safari10NoModuleFix = `!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",(function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()}),!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();`;
80
90
  const legacyPolyfillId = "vite-legacy-polyfill";
@@ -93,7 +103,7 @@ async function loadBabel() {
93
103
  }
94
104
  return babel;
95
105
  }
96
- const { loadConfig: browserslistLoadConfig } = browserslist;
106
+ const { loadConfig: browserslistLoadConfig } = browserslist__default;
97
107
  function toOutputFilePathInHtml(filename, type, hostId, hostType, config, toRelative) {
98
108
  const { renderBuiltUrl } = config.experimental;
99
109
  let relative = config.base === "" || config.base === "./";
@@ -124,13 +134,13 @@ function toOutputFilePathInHtml(filename, type, hostId, hostType, config, toRela
124
134
  }
125
135
  }
126
136
  function getBaseInHTML(urlRelativePath, config) {
127
- return config.base === "./" || config.base === "" ? path.posix.join(
128
- path.posix.relative(urlRelativePath, "").slice(0, -2),
137
+ return config.base === "./" || config.base === "" ? path__default.posix.join(
138
+ path__default.posix.relative(urlRelativePath, "").slice(0, -2),
129
139
  "./"
130
140
  ) : config.base;
131
141
  }
132
142
  function toAssetPathFromHtml(filename, htmlPath, config) {
133
- const relativeUrlPath = vite.normalizePath(path.relative(config.root, htmlPath));
143
+ const relativeUrlPath = vite.normalizePath(path__default.relative(config.root, htmlPath));
134
144
  const toRelative = (filename2, hostId) => getBaseInHTML(relativeUrlPath, config) + filename2;
135
145
  return toOutputFilePathInHtml(
136
146
  filename,
@@ -208,7 +218,7 @@ function viteLegacyPlugin(options = {}) {
208
218
  configResolved(config2) {
209
219
  if (overriddenBuildTarget) {
210
220
  config2.logger.warn(
211
- picocolorsExports.yellow(
221
+ colors.yellow(
212
222
  `plugin-legacy overrode 'build.target'. You should pass 'targets' as an option to this plugin with the list of legacy browsers to support instead.`
213
223
  )
214
224
  );
@@ -286,7 +296,7 @@ function viteLegacyPlugin(options = {}) {
286
296
  isDebug && console.log(`[@vitejs/plugin-legacy] targets:`, targets);
287
297
  const getLegacyOutputFileName = (fileNames, defaultFileName = "[name]-legacy-[hash].js") => {
288
298
  if (!fileNames) {
289
- return path.posix.join(config.build.assetsDir, defaultFileName);
299
+ return path__default.posix.join(config.build.assetsDir, defaultFileName);
290
300
  }
291
301
  return (chunkInfo) => {
292
302
  let fileName = typeof fileNames === "function" ? fileNames(chunkInfo) : fileNames;
@@ -322,7 +332,7 @@ function viteLegacyPlugin(options = {}) {
322
332
  if (options.modernPolyfills && !Array.isArray(options.modernPolyfills)) {
323
333
  await detectPolyfills(raw, { esmodules: true }, modernPolyfills);
324
334
  }
325
- const ms = new MagicString(raw);
335
+ const ms = new MagicString__default(raw);
326
336
  if (genLegacy && chunk.isEntry) {
327
337
  ms.prepend(modernChunkLegacyGuard);
328
338
  }
@@ -376,7 +386,7 @@ function viteLegacyPlugin(options = {}) {
376
386
  })
377
387
  ],
378
388
  [
379
- "@babel/preset-env",
389
+ (await import('@babel/preset-env')).default,
380
390
  createBabelPresetEnvOptions(targets, {
381
391
  needPolyfills,
382
392
  ignoreBrowserslistConfig: options.ignoreBrowserslistConfig
@@ -521,7 +531,7 @@ async function detectPolyfills(code, targets, list) {
521
531
  configFile: false,
522
532
  presets: [
523
533
  [
524
- "@babel/preset-env",
534
+ (await import('@babel/preset-env')).default,
525
535
  createBabelPresetEnvOptions(targets, {
526
536
  ignoreBrowserslistConfig: true
527
537
  })
@@ -561,7 +571,7 @@ async function buildPolyfillChunk(mode, imports, bundle, facadeToChunkMap, build
561
571
  const res = await vite.build({
562
572
  mode,
563
573
  // so that everything is resolved from here
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)))),
574
+ root: path__default.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)))),
565
575
  configFile: false,
566
576
  logLevel: "error",
567
577
  plugins: [polyfillsPlugin(imports, excludeSystemJS)],
package/dist/index.mjs CHANGED
@@ -7,11 +7,11 @@ import MagicString from 'magic-string';
7
7
  import require$$0 from 'tty';
8
8
  import browserslist from 'browserslist';
9
9
 
10
- var picocolorsExports = {};
11
- var picocolors = {
12
- get exports(){ return picocolorsExports; },
13
- set exports(v){ picocolorsExports = v; },
14
- };
10
+ function getDefaultExportFromCjs (x) {
11
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
12
+ }
13
+
14
+ var picocolors = {exports: {}};
15
15
 
16
16
  let tty = require$$0;
17
17
 
@@ -70,7 +70,10 @@ let createColors = (enabled = isColorSupported) => ({
70
70
  });
71
71
 
72
72
  picocolors.exports = createColors();
73
- picocolorsExports.createColors = createColors;
73
+ picocolors.exports.createColors = createColors;
74
+
75
+ var picocolorsExports = picocolors.exports;
76
+ const colors = /*@__PURE__*/getDefaultExportFromCjs(picocolorsExports);
74
77
 
75
78
  const safari10NoModuleFix = `!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",(function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()}),!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();`;
76
79
  const legacyPolyfillId = "vite-legacy-polyfill";
@@ -204,7 +207,7 @@ function viteLegacyPlugin(options = {}) {
204
207
  configResolved(config2) {
205
208
  if (overriddenBuildTarget) {
206
209
  config2.logger.warn(
207
- picocolorsExports.yellow(
210
+ colors.yellow(
208
211
  `plugin-legacy overrode 'build.target'. You should pass 'targets' as an option to this plugin with the list of legacy browsers to support instead.`
209
212
  )
210
213
  );
@@ -372,7 +375,7 @@ function viteLegacyPlugin(options = {}) {
372
375
  })
373
376
  ],
374
377
  [
375
- "@babel/preset-env",
378
+ (await import('@babel/preset-env')).default,
376
379
  createBabelPresetEnvOptions(targets, {
377
380
  needPolyfills,
378
381
  ignoreBrowserslistConfig: options.ignoreBrowserslistConfig
@@ -517,7 +520,7 @@ async function detectPolyfills(code, targets, list) {
517
520
  configFile: false,
518
521
  presets: [
519
522
  [
520
- "@babel/preset-env",
523
+ (await import('@babel/preset-env')).default,
521
524
  createBabelPresetEnvOptions(targets, {
522
525
  ignoreBrowserslistConfig: true
523
526
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitejs/plugin-legacy",
3
- "version": "4.0.3",
3
+ "version": "4.0.5",
4
4
  "license": "MIT",
5
5
  "author": "Evan You",
6
6
  "files": [
@@ -40,21 +40,22 @@
40
40
  "url": "https://github.com/vitejs/vite/issues"
41
41
  },
42
42
  "homepage": "https://github.com/vitejs/vite/tree/main/packages/plugin-legacy#readme",
43
+ "funding": "https://github.com/vitejs/vite?sponsor=1",
43
44
  "dependencies": {
44
- "@babel/core": "^7.21.3",
45
- "@babel/preset-env": "^7.20.2",
46
- "browserslist": "^4.21.5",
47
- "core-js": "^3.29.1",
45
+ "@babel/core": "^7.22.5",
46
+ "@babel/preset-env": "^7.22.5",
47
+ "browserslist": "^4.21.9",
48
+ "core-js": "^3.31.0",
48
49
  "magic-string": "^0.30.0",
49
50
  "regenerator-runtime": "^0.13.11",
50
- "systemjs": "^6.14.0"
51
+ "systemjs": "^6.14.1"
51
52
  },
52
53
  "peerDependencies": {
53
54
  "terser": "^5.4.0",
54
55
  "vite": "^4.0.0"
55
56
  },
56
57
  "devDependencies": {
57
- "acorn": "^8.8.2",
58
+ "acorn": "^8.9.0",
58
59
  "picocolors": "^1.0.0",
59
60
  "vite": "workspace:*"
60
61
  }