vite 3.0.0-alpha.0 → 3.0.0-alpha.3

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.
Files changed (92) hide show
  1. package/LICENSE.md +1 -1
  2. package/bin/vite.js +5 -5
  3. package/client.d.ts +4 -2
  4. package/dist/client/client.mjs +23 -19
  5. package/dist/client/client.mjs.map +1 -1
  6. package/dist/node/build.d.ts +178 -0
  7. package/dist/node/certificate.d.ts +2 -0
  8. package/dist/node/chunks/{dep-a9015192.js → dep-24157481.js} +20 -20
  9. package/dist/node/chunks/{dep-dfbd0b0c.js → dep-5eede05c.js} +40 -37
  10. package/dist/node/chunks/{dep-fafc4143.js → dep-6f5ac69c.js} +1681 -1636
  11. package/dist/node/chunks/{dep-2d9eaf08.js → dep-b1fc04c1.js} +27 -29
  12. package/dist/node/chunks/{dep-63fe0f22.js → dep-da8244f4.js} +12 -6
  13. package/dist/node/chunks/{dep-2056ae8a.js → dep-e8ca8d40.js} +9 -3
  14. package/dist/node/cli.d.ts +1 -0
  15. package/dist/node/cli.js +43 -48
  16. package/dist/node/config.d.ts +240 -0
  17. package/dist/node/constants.d.ts +35 -0
  18. package/dist/node/constants.js +82 -0
  19. package/dist/node/env.d.ts +3 -0
  20. package/dist/node/http.d.ts +88 -0
  21. package/dist/node/index.d.ts +12 -4
  22. package/dist/node/index.js +37 -60
  23. package/dist/node/logger.d.ts +31 -0
  24. package/dist/node/optimizer/esbuildDepPlugin.d.ts +4 -0
  25. package/dist/node/optimizer/index.d.ts +154 -0
  26. package/dist/node/optimizer/registerMissing.d.ts +3 -0
  27. package/dist/node/optimizer/scan.d.ts +8 -0
  28. package/dist/node/packages.d.ts +27 -0
  29. package/dist/node/plugin.d.ts +129 -0
  30. package/dist/node/plugins/asset.d.ts +68 -0
  31. package/dist/node/plugins/assetImportMetaUrl.d.ts +13 -0
  32. package/dist/node/plugins/clientInjections.d.ts +7 -0
  33. package/dist/node/plugins/css.d.ts +86 -0
  34. package/dist/node/plugins/dataUri.d.ts +5 -0
  35. package/dist/node/plugins/define.d.ts +3 -0
  36. package/dist/node/plugins/dynamicImportVars.d.ts +9 -0
  37. package/dist/node/plugins/ensureWatch.d.ts +5 -0
  38. package/dist/node/plugins/esbuild.d.ts +15 -0
  39. package/dist/node/plugins/html.d.ts +120 -0
  40. package/dist/node/plugins/importAnalysis.d.ts +47 -0
  41. package/dist/node/plugins/importAnalysisBuild.d.ts +16 -0
  42. package/dist/node/plugins/importMetaGlob.d.ts +34 -0
  43. package/dist/node/plugins/index.d.ts +3 -0
  44. package/dist/node/plugins/json.d.ts +23 -0
  45. package/dist/node/plugins/loadFallback.d.ts +5 -0
  46. package/dist/node/plugins/manifest.d.ts +14 -0
  47. package/dist/node/plugins/metadata.d.ts +9 -0
  48. package/dist/node/plugins/modulePreloadPolyfill.d.ts +4 -0
  49. package/dist/node/plugins/optimizedDeps.d.ts +4 -0
  50. package/dist/node/plugins/preAlias.d.ts +5 -0
  51. package/dist/node/plugins/reporter.d.ts +3 -0
  52. package/dist/node/plugins/resolve.d.ts +39 -0
  53. package/dist/node/plugins/splitVendorChunk.d.ts +12 -0
  54. package/dist/node/plugins/ssrRequireHook.d.ts +12 -0
  55. package/dist/node/plugins/terser.d.ts +3 -0
  56. package/dist/node/plugins/wasm.d.ts +4 -0
  57. package/dist/node/plugins/worker.d.ts +9 -0
  58. package/dist/node/plugins/workerImportMetaUrl.d.ts +3 -0
  59. package/dist/node/preview.d.ts +33 -0
  60. package/dist/node/publicUtils.d.ts +11 -0
  61. package/dist/node/server/hmr.d.ts +39 -0
  62. package/dist/node/server/index.d.ts +198 -0
  63. package/dist/node/server/middlewares/base.d.ts +3 -0
  64. package/dist/node/server/middlewares/compression.d.ts +1 -0
  65. package/dist/node/server/middlewares/error.d.ts +8 -0
  66. package/dist/node/server/middlewares/indexHtml.d.ts +4 -0
  67. package/dist/node/server/middlewares/proxy.d.ts +20 -0
  68. package/dist/node/server/middlewares/spaFallback.d.ts +2 -0
  69. package/dist/node/server/middlewares/static.d.ts +6 -0
  70. package/dist/node/server/middlewares/time.d.ts +2 -0
  71. package/dist/node/server/middlewares/transform.d.ts +3 -0
  72. package/dist/node/server/moduleGraph.d.ts +55 -0
  73. package/dist/node/server/openBrowser.d.ts +15 -0
  74. package/dist/node/server/pluginContainer.d.ts +41 -0
  75. package/dist/node/server/searchRoot.d.ts +8 -0
  76. package/dist/node/server/send.d.ts +10 -0
  77. package/dist/node/server/sourcemap.d.ts +11 -0
  78. package/dist/node/server/transformRequest.d.ts +14 -0
  79. package/dist/node/server/ws.d.ts +55 -0
  80. package/dist/node/ssr/ssrExternal.d.ts +11 -0
  81. package/dist/node/ssr/ssrManifestPlugin.d.ts +3 -0
  82. package/dist/node/ssr/ssrModuleLoader.d.ts +7 -0
  83. package/dist/node/ssr/ssrStacktrace.d.ts +3 -0
  84. package/dist/node/ssr/ssrTransform.d.ts +14 -0
  85. package/dist/node/utils.d.ts +144 -0
  86. package/dist/node-cjs/publicUtils.cjs +2047 -0
  87. package/dist/{node/terser.js → node-cjs/terser.cjs} +0 -0
  88. package/index.cjs +33 -0
  89. package/package.json +23 -6
  90. package/src/client/client.ts +22 -16
  91. package/src/client/tsconfig.json +1 -1
  92. package/types/importGlob.d.ts +1 -3
@@ -1,15 +1,19 @@
1
- 'use strict';
2
-
3
- var require$$0 = require('postcss');
4
- var index$1 = require('./dep-fafc4143.js');
5
- var path$2 = require('path');
6
- var require$$1 = require('crypto');
7
- var fs = require('fs');
8
- var require$$0$1 = require('util');
9
- var index$2 = require('./dep-2056ae8a.js');
10
-
11
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
12
-
1
+ import require$$0 from 'postcss';
2
+ import { v as commonjsGlobal } from './dep-6f5ac69c.js';
3
+ import path$2 from 'path';
4
+ import require$$1 from 'crypto';
5
+ import fs__default from 'fs';
6
+ import require$$0$1 from 'util';
7
+ import { l as lib$1 } from './dep-e8ca8d40.js';
8
+
9
+ import { fileURLToPath as __cjs_fileURLToPath } from 'url';
10
+ import { dirname as __cjs_dirname } from 'path';
11
+ import { createRequire as __cjs_createRequire } from 'module';
12
+
13
+ const __filename = __cjs_fileURLToPath(import.meta.url);
14
+ const __dirname = __cjs_dirname(__filename);
15
+ const require = __cjs_createRequire(import.meta.url);
16
+ const __require = require;
13
17
  function _mergeNamespaces(n, m) {
14
18
  for (var i = 0; i < m.length; i++) {
15
19
  var e = m[i];
@@ -22,12 +26,6 @@ function _mergeNamespaces(n, m) {
22
26
  return n;
23
27
  }
24
28
 
25
- var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
26
- var path__default = /*#__PURE__*/_interopDefaultLegacy(path$2);
27
- var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);
28
- var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
29
- var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$1);
30
-
31
29
  var build$1 = {exports: {}};
32
30
 
33
31
  /**
@@ -181,7 +179,7 @@ var deburredLetters = {
181
179
  };
182
180
 
183
181
  /** Detect free variable `global` from Node.js. */
184
- var freeGlobal = typeof index$1.commonjsGlobal == 'object' && index$1.commonjsGlobal && index$1.commonjsGlobal.Object === Object && index$1.commonjsGlobal;
182
+ var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
185
183
 
186
184
  /** Detect free variable `self`. */
187
185
  var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
@@ -1138,7 +1136,7 @@ function getHashDigest$1(buffer, algorithm, digestType, maxLength) {
1138
1136
  hash = new BatchedHash(createMd4());
1139
1137
  } else if (algorithm === "native-md4") {
1140
1138
  if (typeof crypto === "undefined") {
1141
- crypto = require$$1__default;
1139
+ crypto = require$$1;
1142
1140
 
1143
1141
  if (BulkUpdateDecorator === undefined) {
1144
1142
  BulkUpdateDecorator = BulkUpdateDecorator_1;
@@ -1148,7 +1146,7 @@ function getHashDigest$1(buffer, algorithm, digestType, maxLength) {
1148
1146
  hash = new BulkUpdateDecorator(() => crypto.createHash("md4"), "md4");
1149
1147
  } else {
1150
1148
  if (typeof crypto === "undefined") {
1151
- crypto = require$$1__default;
1149
+ crypto = require$$1;
1152
1150
 
1153
1151
  if (BulkUpdateDecorator === undefined) {
1154
1152
  BulkUpdateDecorator = BulkUpdateDecorator_1;
@@ -1180,7 +1178,7 @@ function getHashDigest$1(buffer, algorithm, digestType, maxLength) {
1180
1178
 
1181
1179
  var getHashDigest_1 = getHashDigest$1;
1182
1180
 
1183
- const path$1 = path__default;
1181
+ const path$1 = path$2;
1184
1182
  const getHashDigest = getHashDigest_1;
1185
1183
 
1186
1184
  function interpolateName$1(loaderContext, name, options = {}) {
@@ -1296,7 +1294,7 @@ function interpolateName$1(loaderContext, name, options = {}) {
1296
1294
  var interpolateName_1 = interpolateName$1;
1297
1295
 
1298
1296
  var interpolateName = interpolateName_1;
1299
- var path = path__default;
1297
+ var path = path$2;
1300
1298
 
1301
1299
  /**
1302
1300
  * @param {string} pattern
@@ -1480,7 +1478,7 @@ Object.defineProperty(loader, "__esModule", {
1480
1478
  value: true
1481
1479
  });
1482
1480
 
1483
- var _postcss$1 = require$$0__default;
1481
+ var _postcss$1 = require$$0;
1484
1482
 
1485
1483
  var _postcss2$1 = _interopRequireDefault$5(_postcss$1);
1486
1484
 
@@ -1488,7 +1486,7 @@ var _fs$1 = fs__default;
1488
1486
 
1489
1487
  var _fs2 = _interopRequireDefault$5(_fs$1);
1490
1488
 
1491
- var _path = path__default;
1489
+ var _path = path$2;
1492
1490
 
1493
1491
  var _path2 = _interopRequireDefault$5(_path);
1494
1492
 
@@ -3113,7 +3111,7 @@ var attribute$1 = {};
3113
3111
  * For Node.js, simply re-export the core `util.deprecate` function.
3114
3112
  */
3115
3113
 
3116
- var node = require$$0__default$1.deprecate;
3114
+ var node = require$$0$1.deprecate;
3117
3115
 
3118
3116
  (function (exports) {
3119
3117
 
@@ -6001,7 +5999,7 @@ var src$3 = {
6001
5999
  };
6002
6000
 
6003
6001
  const selectorParser$1 = dist.exports;
6004
- const valueParser = index$2.lib;
6002
+ const valueParser = lib$1;
6005
6003
  const { extractICSS } = src$3;
6006
6004
 
6007
6005
  const isSpacing = (node) => node.type === "combinator" && node.value === " ";
@@ -7315,7 +7313,7 @@ function isValidBehaviour(behaviour) {
7315
7313
  return Object.keys(behaviours).map(key => behaviours[key]).indexOf(behaviour) > -1;
7316
7314
  }
7317
7315
 
7318
- var _postcss = require$$0__default;
7316
+ var _postcss = require$$0;
7319
7317
 
7320
7318
  var _postcss2 = _interopRequireDefault(_postcss);
7321
7319
 
@@ -7504,4 +7502,4 @@ var index = /*#__PURE__*/_mergeNamespaces({
7504
7502
  postcss: postcss
7505
7503
  }, [build$1.exports]);
7506
7504
 
7507
- exports.index = index;
7505
+ export { index as i };
@@ -1,7 +1,13 @@
1
- 'use strict';
1
+ import { w as getAugmentedNamespace, x as getDefaultExportFromCjs } from './dep-6f5ac69c.js';
2
2
 
3
- var index = require('./dep-fafc4143.js');
3
+ import { fileURLToPath as __cjs_fileURLToPath } from 'url';
4
+ import { dirname as __cjs_dirname } from 'path';
5
+ import { createRequire as __cjs_createRequire } from 'module';
4
6
 
7
+ const __filename = __cjs_fileURLToPath(import.meta.url);
8
+ const __dirname = __cjs_dirname(__filename);
9
+ const require = __cjs_createRequire(import.meta.url);
10
+ const __require = require;
5
11
  function _mergeNamespaces(n, m) {
6
12
  for (var i = 0; i < m.length; i++) {
7
13
  var e = m[i];
@@ -5642,9 +5648,9 @@ var compilerCore_esmBundler = {
5642
5648
  generateCodeFrame: generateCodeFrame
5643
5649
  };
5644
5650
 
5645
- var require$$0 = /*@__PURE__*/index.getAugmentedNamespace(compilerCore_esmBundler);
5651
+ var require$$0 = /*@__PURE__*/getAugmentedNamespace(compilerCore_esmBundler);
5646
5652
 
5647
- var require$$1 = /*@__PURE__*/index.getAugmentedNamespace(shared_esmBundler);
5653
+ var require$$1 = /*@__PURE__*/getAugmentedNamespace(shared_esmBundler);
5648
5654
 
5649
5655
  (function (exports) {
5650
5656
 
@@ -8747,11 +8753,11 @@ exports.parserOptions = parserOptions;
8747
8753
  exports.transformStyle = transformStyle;
8748
8754
  }(compilerDom_cjs$2));
8749
8755
 
8750
- var compilerDom_cjs = /*@__PURE__*/index.getDefaultExportFromCjs(compilerDom_cjs$2);
8756
+ var compilerDom_cjs = /*@__PURE__*/getDefaultExportFromCjs(compilerDom_cjs$2);
8751
8757
 
8752
8758
  var compilerDom_cjs$1 = /*#__PURE__*/_mergeNamespaces({
8753
8759
  __proto__: null,
8754
8760
  'default': compilerDom_cjs
8755
8761
  }, [compilerDom_cjs$2]);
8756
8762
 
8757
- exports.compilerDom_cjs = compilerDom_cjs$1;
8763
+ export { compilerDom_cjs$1 as c };
@@ -1,5 +1,11 @@
1
- 'use strict';
2
-
1
+ import { fileURLToPath as __cjs_fileURLToPath } from 'url';
2
+ import { dirname as __cjs_dirname } from 'path';
3
+ import { createRequire as __cjs_createRequire } from 'module';
4
+
5
+ const __filename = __cjs_fileURLToPath(import.meta.url);
6
+ const __dirname = __cjs_dirname(__filename);
7
+ const require = __cjs_createRequire(import.meta.url);
8
+ const __require = require;
3
9
  var openParentheses = "(".charCodeAt(0);
4
10
  var closeParentheses = ")".charCodeAt(0);
5
11
  var singleQuote = "'".charCodeAt(0);
@@ -544,4 +550,4 @@ ValueParser.stringify = stringify;
544
550
 
545
551
  var lib = ValueParser;
546
552
 
547
- exports.lib = lib;
553
+ export { lib as l };
@@ -0,0 +1 @@
1
+ export {};
package/dist/node/cli.js CHANGED
@@ -1,30 +1,29 @@
1
- 'use strict';
2
-
3
- var perf_hooks = require('perf_hooks');
4
- var require$$0 = require('events');
5
- var index = require('./chunks/dep-fafc4143.js');
6
- require('fs');
7
- require('path');
8
- require('url');
9
- require('tty');
10
- require('os');
11
- require('esbuild');
12
- require('assert');
13
- require('resolve');
14
- require('util');
15
- require('net');
16
- require('http');
17
- require('stream');
18
- require('child_process');
19
- require('crypto');
20
- require('module');
21
- require('buffer');
22
- require('querystring');
23
- require('zlib');
24
- require('https');
25
- require('tls');
26
- require('worker_threads');
27
- require('readline');
1
+ import { performance } from 'perf_hooks';
2
+ import { EventEmitter } from 'events';
3
+ import { u as colors, i as createLogger, e as resolveConfig } from './chunks/dep-6f5ac69c.js';
4
+ import { VERSION } from './constants.js';
5
+ import 'fs';
6
+ import 'path';
7
+ import 'url';
8
+ import 'module';
9
+ import 'tty';
10
+ import 'esbuild';
11
+ import 'assert';
12
+ import 'resolve';
13
+ import 'util';
14
+ import 'net';
15
+ import 'http';
16
+ import 'stream';
17
+ import 'os';
18
+ import 'child_process';
19
+ import 'crypto';
20
+ import 'buffer';
21
+ import 'querystring';
22
+ import 'zlib';
23
+ import 'https';
24
+ import 'tls';
25
+ import 'worker_threads';
26
+ import 'readline';
28
27
 
29
28
  function toArr(any) {
30
29
  return any == null ? [] : Array.isArray(any) ? any : [any];
@@ -449,7 +448,7 @@ class GlobalCommand extends Command {
449
448
  }
450
449
 
451
450
  var __assign = Object.assign;
452
- class CAC extends require$$0.EventEmitter {
451
+ class CAC extends EventEmitter {
453
452
  constructor(name = "") {
454
453
  super();
455
454
  this.name = name;
@@ -683,7 +682,7 @@ cli
683
682
  .action(async (root, options) => {
684
683
  // output structure is preserved even after bundling so require()
685
684
  // is ok here
686
- const { createServer } = await Promise.resolve().then(function () { return require('./chunks/dep-fafc4143.js'); }).then(function (n) { return n.index$1; });
685
+ const { createServer } = await import('./chunks/dep-6f5ac69c.js').then(function (n) { return n.A; });
687
686
  try {
688
687
  const server = await createServer({
689
688
  root,
@@ -699,20 +698,16 @@ cli
699
698
  }
700
699
  await server.listen();
701
700
  const info = server.config.logger.info;
702
- info(index.colors.cyan(`\n vite v${require('vite/package.json').version}`) +
703
- index.colors.green(` dev server running at:\n`), {
704
- clear: !server.config.logger.hasWarned
705
- });
706
- server.printUrls();
707
701
  // @ts-ignore
708
- if (global.__vite_start_time) {
709
- // @ts-ignore
710
- const startupDuration = perf_hooks.performance.now() - global.__vite_start_time;
711
- info(`\n ${index.colors.cyan(`ready in ${Math.ceil(startupDuration)}ms.`)}\n`);
712
- }
702
+ const viteStartTime = global.__vite_start_time ?? false;
703
+ const startupDurationString = viteStartTime
704
+ ? colors.dim(`ready in ${colors.white(colors.bold(Math.ceil(performance.now() - viteStartTime)))} ms`)
705
+ : '';
706
+ info(`\n ${colors.green(`${colors.bold('VITE')} v${VERSION}`)} ${startupDurationString}\n`, { clear: !server.config.logger.hasWarned });
707
+ server.printUrls();
713
708
  }
714
709
  catch (e) {
715
- index.createLogger(options.logLevel).error(index.colors.red(`error when starting dev server:\n${e.stack}`), { error: e });
710
+ createLogger(options.logLevel).error(colors.red(`error when starting dev server:\n${e.stack}`), { error: e });
716
711
  process.exit(1);
717
712
  }
718
713
  });
@@ -732,7 +727,7 @@ cli
732
727
  .option('--emptyOutDir', `[boolean] force empty outDir when it's outside of root`)
733
728
  .option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
734
729
  .action(async (root, options) => {
735
- const { build } = await Promise.resolve().then(function () { return require('./chunks/dep-fafc4143.js'); }).then(function (n) { return n.build$1; });
730
+ const { build } = await import('./chunks/dep-6f5ac69c.js').then(function (n) { return n.z; });
736
731
  const buildOptions = cleanOptions(options);
737
732
  try {
738
733
  await build({
@@ -746,7 +741,7 @@ cli
746
741
  });
747
742
  }
748
743
  catch (e) {
749
- index.createLogger(options.logLevel).error(index.colors.red(`error during build:\n${e.stack}`), { error: e });
744
+ createLogger(options.logLevel).error(colors.red(`error during build:\n${e.stack}`), { error: e });
750
745
  process.exit(1);
751
746
  }
752
747
  });
@@ -755,9 +750,9 @@ cli
755
750
  .command('optimize [root]', 'pre-bundle dependencies')
756
751
  .option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
757
752
  .action(async (root, options) => {
758
- const { optimizeDeps } = await Promise.resolve().then(function () { return require('./chunks/dep-fafc4143.js'); }).then(function (n) { return n.index; });
753
+ const { optimizeDeps } = await import('./chunks/dep-6f5ac69c.js').then(function (n) { return n.y; });
759
754
  try {
760
- const config = await index.resolveConfig({
755
+ const config = await resolveConfig({
761
756
  root,
762
757
  base: options.base,
763
758
  configFile: options.config,
@@ -766,7 +761,7 @@ cli
766
761
  await optimizeDeps(config, options.force, true);
767
762
  }
768
763
  catch (e) {
769
- index.createLogger(options.logLevel).error(index.colors.red(`error when optimizing deps:\n${e.stack}`), { error: e });
764
+ createLogger(options.logLevel).error(colors.red(`error when optimizing deps:\n${e.stack}`), { error: e });
770
765
  process.exit(1);
771
766
  }
772
767
  });
@@ -778,7 +773,7 @@ cli
778
773
  .option('--https', `[boolean] use TLS + HTTP/2`)
779
774
  .option('--open [path]', `[boolean | string] open browser on startup`)
780
775
  .action(async (root, options) => {
781
- const { preview } = await Promise.resolve().then(function () { return require('./chunks/dep-fafc4143.js'); }).then(function (n) { return n.preview$1; });
776
+ const { preview } = await import('./chunks/dep-6f5ac69c.js').then(function (n) { return n.B; });
782
777
  try {
783
778
  const server = await preview({
784
779
  root,
@@ -797,10 +792,10 @@ cli
797
792
  server.printUrls();
798
793
  }
799
794
  catch (e) {
800
- index.createLogger(options.logLevel).error(index.colors.red(`error when starting preview server:\n${e.stack}`), { error: e });
795
+ createLogger(options.logLevel).error(colors.red(`error when starting preview server:\n${e.stack}`), { error: e });
801
796
  process.exit(1);
802
797
  }
803
798
  });
804
799
  cli.help();
805
- cli.version(require('../../package.json').version);
800
+ cli.version(VERSION);
806
801
  cli.parse();
@@ -0,0 +1,240 @@
1
+ import type { Alias, AliasOptions } from 'types/alias';
2
+ import type { RollupOptions } from 'rollup';
3
+ import type { Plugin } from './plugin';
4
+ import type { BuildOptions, ResolvedBuildOptions } from './build';
5
+ import type { ResolvedServerOptions, ServerOptions } from './server';
6
+ import type { PreviewOptions, ResolvedPreviewOptions } from './preview';
7
+ import type { CSSOptions } from './plugins/css';
8
+ import type { ESBuildOptions } from './plugins/esbuild';
9
+ import type { InternalResolveOptions, ResolveOptions } from './plugins/resolve';
10
+ import type { LogLevel, Logger } from './logger';
11
+ import type { DepOptimizationOptions } from './optimizer';
12
+ import type { JsonOptions } from './plugins/json';
13
+ import type { PackageCache } from './packages';
14
+ export interface ConfigEnv {
15
+ command: 'build' | 'serve';
16
+ mode: string;
17
+ }
18
+ export declare type UserConfigFn = (env: ConfigEnv) => UserConfig | Promise<UserConfig>;
19
+ export declare type UserConfigExport = UserConfig | Promise<UserConfig> | UserConfigFn;
20
+ /**
21
+ * Type helper to make it easier to use vite.config.ts
22
+ * accepts a direct {@link UserConfig} object, or a function that returns it.
23
+ * The function receives a {@link ConfigEnv} object that exposes two properties:
24
+ * `command` (either `'build'` or `'serve'`), and `mode`.
25
+ */
26
+ export declare function defineConfig(config: UserConfigExport): UserConfigExport;
27
+ export declare type PluginOption = Plugin | false | null | undefined | PluginOption[];
28
+ export interface UserConfig {
29
+ /**
30
+ * Project root directory. Can be an absolute path, or a path relative from
31
+ * the location of the config file itself.
32
+ * @default process.cwd()
33
+ */
34
+ root?: string;
35
+ /**
36
+ * Base public path when served in development or production.
37
+ * @default '/'
38
+ */
39
+ base?: string;
40
+ /**
41
+ * Directory to serve as plain static assets. Files in this directory are
42
+ * served and copied to build dist dir as-is without transform. The value
43
+ * can be either an absolute file system path or a path relative to <root>.
44
+ *
45
+ * Set to `false` or an empty string to disable copied static assets to build dist dir.
46
+ * @default 'public'
47
+ */
48
+ publicDir?: string | false;
49
+ /**
50
+ * Directory to save cache files. Files in this directory are pre-bundled
51
+ * deps or some other cache files that generated by vite, which can improve
52
+ * the performance. You can use `--force` flag or manually delete the directory
53
+ * to regenerate the cache files. The value can be either an absolute file
54
+ * system path or a path relative to <root>.
55
+ * Default to `.vite` when no `package.json` is detected.
56
+ * @default 'node_modules/.vite'
57
+ */
58
+ cacheDir?: string;
59
+ /**
60
+ * Explicitly set a mode to run in. This will override the default mode for
61
+ * each command, and can be overridden by the command line --mode option.
62
+ */
63
+ mode?: string;
64
+ /**
65
+ * Define global variable replacements.
66
+ * Entries will be defined on `window` during dev and replaced during build.
67
+ */
68
+ define?: Record<string, any>;
69
+ /**
70
+ * Array of vite plugins to use.
71
+ */
72
+ plugins?: PluginOption[];
73
+ /**
74
+ * Configure resolver
75
+ */
76
+ resolve?: ResolveOptions & {
77
+ alias?: AliasOptions;
78
+ };
79
+ /**
80
+ * CSS related options (preprocessors and CSS modules)
81
+ */
82
+ css?: CSSOptions;
83
+ /**
84
+ * JSON loading options
85
+ */
86
+ json?: JsonOptions;
87
+ /**
88
+ * Transform options to pass to esbuild.
89
+ * Or set to `false` to disable esbuild.
90
+ */
91
+ esbuild?: ESBuildOptions | false;
92
+ /**
93
+ * Specify additional picomatch patterns to be treated as static assets.
94
+ */
95
+ assetsInclude?: string | RegExp | (string | RegExp)[];
96
+ /**
97
+ * Server specific options, e.g. host, port, https...
98
+ */
99
+ server?: ServerOptions;
100
+ /**
101
+ * Build specific options
102
+ */
103
+ build?: BuildOptions;
104
+ /**
105
+ * Preview specific options, e.g. host, port, https...
106
+ */
107
+ preview?: PreviewOptions;
108
+ /**
109
+ * Dep optimization options
110
+ */
111
+ optimizeDeps?: DepOptimizationOptions;
112
+ /**
113
+ * SSR specific options
114
+ */
115
+ ssr?: SSROptions;
116
+ /**
117
+ * Experimental features
118
+ *
119
+ * Features under this field are addressed to be changed that might NOT follow semver.
120
+ * Please be careful and always pin Vite's version when using them.
121
+ * @experimental
122
+ */
123
+ experimental?: ExperimentalOptions;
124
+ /**
125
+ * Log level.
126
+ * Default: 'info'
127
+ */
128
+ logLevel?: LogLevel;
129
+ /**
130
+ * Custom logger.
131
+ */
132
+ customLogger?: Logger;
133
+ /**
134
+ * Default: true
135
+ */
136
+ clearScreen?: boolean;
137
+ /**
138
+ * Environment files directory. Can be an absolute path, or a path relative from
139
+ * the location of the config file itself.
140
+ * @default root
141
+ */
142
+ envDir?: string;
143
+ /**
144
+ * Env variables starts with `envPrefix` will be exposed to your client source code via import.meta.env.
145
+ * @default 'VITE_'
146
+ */
147
+ envPrefix?: string | string[];
148
+ /**
149
+ * Worker bundle options
150
+ */
151
+ worker?: {
152
+ /**
153
+ * Output format for worker bundle
154
+ * @default 'iife'
155
+ */
156
+ format?: 'es' | 'iife';
157
+ /**
158
+ * Vite plugins that apply to worker bundle
159
+ */
160
+ plugins?: PluginOption[];
161
+ /**
162
+ * Rollup options to build worker bundle
163
+ */
164
+ rollupOptions?: Omit<RollupOptions, 'plugins' | 'input' | 'onwarn' | 'preserveEntrySignatures'>;
165
+ };
166
+ /**
167
+ * Whether your application is a Single Page Application (SPA). Set to `false`
168
+ * for other kinds of apps like MPAs.
169
+ * @default true
170
+ */
171
+ spa?: boolean;
172
+ }
173
+ export interface ExperimentalOptions {
174
+ /**
175
+ * Append fake `&lang.(ext)` when queries are specified, to preseve the file extension for following plugins to process.
176
+ *
177
+ * @experimental
178
+ * @default false
179
+ */
180
+ importGlobRestoreExtension?: boolean;
181
+ }
182
+ export declare type SSRTarget = 'node' | 'webworker';
183
+ export interface SSROptions {
184
+ external?: string[];
185
+ noExternal?: string | RegExp | (string | RegExp)[] | true;
186
+ /**
187
+ * Define the target for the ssr build. The browser field in package.json
188
+ * is ignored for node but used if webworker is the target
189
+ * Default: 'node'
190
+ */
191
+ target?: SSRTarget;
192
+ }
193
+ export interface ResolveWorkerOptions {
194
+ format: 'es' | 'iife';
195
+ plugins: Plugin[];
196
+ rollupOptions: RollupOptions;
197
+ }
198
+ export interface InlineConfig extends UserConfig {
199
+ configFile?: string | false;
200
+ envFile?: false;
201
+ }
202
+ export declare type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | 'assetsInclude' | 'optimizeDeps' | 'worker'> & {
203
+ configFile: string | undefined;
204
+ configFileDependencies: string[];
205
+ inlineConfig: InlineConfig;
206
+ root: string;
207
+ base: string;
208
+ publicDir: string;
209
+ cacheDir: string;
210
+ command: 'build' | 'serve';
211
+ mode: string;
212
+ isWorker: boolean;
213
+ /** @internal */
214
+ mainConfig: ResolvedConfig | null;
215
+ isProduction: boolean;
216
+ env: Record<string, any>;
217
+ resolve: ResolveOptions & {
218
+ alias: Alias[];
219
+ };
220
+ plugins: readonly Plugin[];
221
+ server: ResolvedServerOptions;
222
+ build: ResolvedBuildOptions;
223
+ preview: ResolvedPreviewOptions;
224
+ assetsInclude: (file: string) => boolean;
225
+ logger: Logger;
226
+ createResolver: (options?: Partial<InternalResolveOptions>) => ResolveFn;
227
+ optimizeDeps: DepOptimizationOptions;
228
+ /** @internal */
229
+ packageCache: PackageCache;
230
+ worker: ResolveWorkerOptions;
231
+ spa: boolean;
232
+ }>;
233
+ export declare type ResolveFn = (id: string, importer?: string, aliasOnly?: boolean, ssr?: boolean) => Promise<string | undefined>;
234
+ export declare function resolveConfig(inlineConfig: InlineConfig, command: 'build' | 'serve', defaultMode?: string): Promise<ResolvedConfig>;
235
+ export declare function sortUserPlugins(plugins: (Plugin | Plugin[])[] | undefined): [Plugin[], Plugin[], Plugin[]];
236
+ export declare function loadConfigFromFile(configEnv: ConfigEnv, configFile?: string, configRoot?: string, logLevel?: LogLevel): Promise<{
237
+ path: string;
238
+ config: UserConfig;
239
+ dependencies: string[];
240
+ } | null>;
@@ -0,0 +1,35 @@
1
+ export declare const VERSION: string;
2
+ export declare const DEFAULT_MAIN_FIELDS: string[];
3
+ export declare const DEFAULT_EXTENSIONS: string[];
4
+ export declare const JS_TYPES_RE: RegExp;
5
+ export declare const OPTIMIZABLE_ENTRY_RE: RegExp;
6
+ export declare const SPECIAL_QUERY_RE: RegExp;
7
+ /**
8
+ * Prefix for resolved fs paths, since windows paths may not be valid as URLs.
9
+ */
10
+ export declare const FS_PREFIX = "/@fs/";
11
+ /**
12
+ * Prefix for resolved Ids that are not valid browser import specifiers
13
+ */
14
+ export declare const VALID_ID_PREFIX = "/@id/";
15
+ /**
16
+ * Plugins that use 'virtual modules' (e.g. for helper functions), prefix the
17
+ * module ID with `\0`, a convention from the rollup ecosystem.
18
+ * This prevents other plugins from trying to process the id (like node resolution),
19
+ * and core features like sourcemaps can use this info to differentiate between
20
+ * virtual modules and regular files.
21
+ * `\0` is not a permitted char in import URLs so we have to replace them during
22
+ * import analysis. The id will be decoded back before entering the plugins pipeline.
23
+ * These encoded virtual ids are also prefixed by the VALID_ID_PREFIX, so virtual
24
+ * modules in the browser end up encoded as `/@id/__x00__{id}`
25
+ */
26
+ export declare const NULL_BYTE_PLACEHOLDER = "__x00__";
27
+ export declare const CLIENT_PUBLIC_PATH = "/@vite/client";
28
+ export declare const ENV_PUBLIC_PATH = "/@vite/env";
29
+ export declare const VITE_PACKAGE_DIR: string;
30
+ export declare const CLIENT_ENTRY: string;
31
+ export declare const ENV_ENTRY: string;
32
+ export declare const CLIENT_DIR: string;
33
+ export declare const KNOWN_ASSET_TYPES: string[];
34
+ export declare const DEFAULT_ASSETS_RE: RegExp;
35
+ export declare const DEP_VERSION_RE: RegExp;