vite 3.0.0-alpha.1 → 3.0.0-alpha.4

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-8db43f98.js → dep-28f8c91c.js} +27 -29
  10. package/dist/node/chunks/{dep-99df5764.js → dep-35b61ee3.js} +12 -6
  11. package/dist/node/chunks/{dep-5cb039d6.js → dep-aea1d487.js} +1608 -1701
  12. package/dist/node/chunks/{dep-88b8fd2c.js → dep-ce833324.js} +40 -37
  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 +28 -3
  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 +167 -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 +24 -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,35 +1,38 @@
1
- 'use strict';
2
-
3
- var index = require('./dep-5cb039d6.js');
4
- var require$$1 = require('crypto');
5
- require('fs');
6
- require('path');
7
- require('url');
8
- require('perf_hooks');
9
- require('tty');
10
- require('os');
11
- require('esbuild');
12
- require('events');
13
- require('assert');
14
- require('resolve');
15
- require('util');
16
- require('net');
17
- require('http');
18
- require('stream');
19
- require('child_process');
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');
28
-
29
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
30
-
31
- var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);
32
-
1
+ import { v as commonjsGlobal } from './dep-aea1d487.js';
2
+ import require$$1 from 'crypto';
3
+ import 'fs';
4
+ import 'path';
5
+ import 'url';
6
+ import 'perf_hooks';
7
+ import 'module';
8
+ import 'tty';
9
+ import 'esbuild';
10
+ import 'events';
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 '../constants.js';
20
+ import 'buffer';
21
+ import 'querystring';
22
+ import 'zlib';
23
+ import 'https';
24
+ import 'tls';
25
+ import 'worker_threads';
26
+ import 'readline';
27
+
28
+ import { fileURLToPath as __cjs_fileURLToPath } from 'url';
29
+ import { dirname as __cjs_dirname } from 'path';
30
+ import { createRequire as __cjs_createRequire } from 'module';
31
+
32
+ const __filename = __cjs_fileURLToPath(import.meta.url);
33
+ const __dirname = __cjs_dirname(__filename);
34
+ const require = __cjs_createRequire(import.meta.url);
35
+ const __require = require;
33
36
  /**
34
37
  * Node.js module for Forge.
35
38
  *
@@ -353,7 +356,7 @@ util$1.isNodejs =
353
356
  // is not available.
354
357
  util$1.globalScope = (function() {
355
358
  if(util$1.isNodejs) {
356
- return index.commonjsGlobal;
359
+ return commonjsGlobal;
357
360
  }
358
361
 
359
362
  return typeof self === 'undefined' ? window : self;
@@ -7506,7 +7509,7 @@ var pkcs5 = forge$i.pkcs5 = forge$i.pkcs5 || {};
7506
7509
 
7507
7510
  var crypto;
7508
7511
  if(forge$i.util.isNodejs && !forge$i.options.usePureJavaScript) {
7509
- crypto = require$$1__default;
7512
+ crypto = require$$1;
7510
7513
  }
7511
7514
 
7512
7515
  /**
@@ -8286,7 +8289,7 @@ var forge$f = forge$s;
8286
8289
  var _crypto$1 = null;
8287
8290
  if(forge$f.util.isNodejs && !forge$f.options.usePureJavaScript &&
8288
8291
  !process.versions['node-webkit']) {
8289
- _crypto$1 = require$$1__default;
8292
+ _crypto$1 = require$$1;
8290
8293
  }
8291
8294
 
8292
8295
  /* PRNG API */
@@ -11508,7 +11511,7 @@ if(typeof BigInteger === 'undefined') {
11508
11511
  var BigInteger = forge$8.jsbn.BigInteger;
11509
11512
  }
11510
11513
 
11511
- var _crypto = forge$8.util.isNodejs ? require$$1__default : null;
11514
+ var _crypto = forge$8.util.isNodejs ? require$$1 : null;
11512
11515
 
11513
11516
  // shortcut for asn.1 API
11514
11517
  var asn1$5 = forge$8.asn1;
@@ -19597,4 +19600,4 @@ function createCertificate() {
19597
19600
  return privateKeyPem + certPem;
19598
19601
  }
19599
19602
 
19600
- exports.createCertificate = createCertificate;
19603
+ export { createCertificate };
@@ -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-5cb039d6.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-aea1d487.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-5cb039d6.js'); }).then(function (n) { return n.index$1; });
685
+ const { createServer } = await import('./chunks/dep-aea1d487.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-5cb039d6.js'); }).then(function (n) { return n.build$1; });
730
+ const { build } = await import('./chunks/dep-aea1d487.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-5cb039d6.js'); }).then(function (n) { return n.index; });
753
+ const { optimizeDeps } = await import('./chunks/dep-aea1d487.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-5cb039d6.js'); }).then(function (n) { return n.preview$1; });
776
+ const { preview } = await import('./chunks/dep-aea1d487.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;
@@ -0,0 +1,82 @@
1
+ import path, { resolve } from 'path';
2
+ import { fileURLToPath } from 'url';
3
+
4
+ var version = "3.0.0-alpha.4";
5
+
6
+ const VERSION = version;
7
+ const DEFAULT_MAIN_FIELDS = [
8
+ 'module',
9
+ 'jsnext:main',
10
+ 'jsnext'
11
+ ];
12
+ const DEFAULT_EXTENSIONS = [
13
+ '.mjs',
14
+ '.js',
15
+ '.ts',
16
+ '.jsx',
17
+ '.tsx',
18
+ '.json'
19
+ ];
20
+ const JS_TYPES_RE = /\.(?:j|t)sx?$|\.mjs$/;
21
+ const OPTIMIZABLE_ENTRY_RE = /\.(?:m?js|ts)$/;
22
+ const SPECIAL_QUERY_RE = /[\?&](?:worker|sharedworker|raw|url)\b/;
23
+ /**
24
+ * Prefix for resolved fs paths, since windows paths may not be valid as URLs.
25
+ */
26
+ const FS_PREFIX = `/@fs/`;
27
+ /**
28
+ * Prefix for resolved Ids that are not valid browser import specifiers
29
+ */
30
+ const VALID_ID_PREFIX = `/@id/`;
31
+ /**
32
+ * Plugins that use 'virtual modules' (e.g. for helper functions), prefix the
33
+ * module ID with `\0`, a convention from the rollup ecosystem.
34
+ * This prevents other plugins from trying to process the id (like node resolution),
35
+ * and core features like sourcemaps can use this info to differentiate between
36
+ * virtual modules and regular files.
37
+ * `\0` is not a permitted char in import URLs so we have to replace them during
38
+ * import analysis. The id will be decoded back before entering the plugins pipeline.
39
+ * These encoded virtual ids are also prefixed by the VALID_ID_PREFIX, so virtual
40
+ * modules in the browser end up encoded as `/@id/__x00__{id}`
41
+ */
42
+ const NULL_BYTE_PLACEHOLDER = `__x00__`;
43
+ const CLIENT_PUBLIC_PATH = `/@vite/client`;
44
+ const ENV_PUBLIC_PATH = `/@vite/env`;
45
+ const VITE_PACKAGE_DIR = resolve(fileURLToPath(import.meta.url), '../../..');
46
+ const CLIENT_ENTRY = resolve(VITE_PACKAGE_DIR, 'dist/client/client.mjs');
47
+ const ENV_ENTRY = resolve(VITE_PACKAGE_DIR, 'dist/client/env.mjs');
48
+ const CLIENT_DIR = path.dirname(CLIENT_ENTRY);
49
+ // ** READ THIS ** before editing `KNOWN_ASSET_TYPES`.
50
+ // If you add an asset to `KNOWN_ASSET_TYPES`, make sure to also add it
51
+ // to the TypeScript declaration file `packages/vite/client.d.ts`.
52
+ const KNOWN_ASSET_TYPES = [
53
+ // images
54
+ 'png',
55
+ 'jpe?g',
56
+ 'gif',
57
+ 'svg',
58
+ 'ico',
59
+ 'webp',
60
+ 'avif',
61
+ // media
62
+ 'mp4',
63
+ 'webm',
64
+ 'ogg',
65
+ 'mp3',
66
+ 'wav',
67
+ 'flac',
68
+ 'aac',
69
+ // fonts
70
+ 'woff2?',
71
+ 'eot',
72
+ 'ttf',
73
+ 'otf',
74
+ // other
75
+ 'webmanifest',
76
+ 'pdf',
77
+ 'txt'
78
+ ];
79
+ const DEFAULT_ASSETS_RE = new RegExp(`\\.(` + KNOWN_ASSET_TYPES.join('|') + `)(\\?.*)?$`);
80
+ const DEP_VERSION_RE = /[\?&](v=[\w\.-]+)\b/;
81
+
82
+ export { CLIENT_DIR, CLIENT_ENTRY, CLIENT_PUBLIC_PATH, DEFAULT_ASSETS_RE, DEFAULT_EXTENSIONS, DEFAULT_MAIN_FIELDS, DEP_VERSION_RE, ENV_ENTRY, ENV_PUBLIC_PATH, FS_PREFIX, JS_TYPES_RE, KNOWN_ASSET_TYPES, NULL_BYTE_PLACEHOLDER, OPTIMIZABLE_ENTRY_RE, SPECIAL_QUERY_RE, VALID_ID_PREFIX, VERSION, VITE_PACKAGE_DIR };
@@ -0,0 +1,3 @@
1
+ import type { UserConfig } from './config';
2
+ export declare function loadEnv(mode: string, envDir: string, prefixes?: string | string[]): Record<string, string>;
3
+ export declare function resolveEnvPrefix({ envPrefix }: UserConfig): string[];