vite 3.0.0-alpha.4 → 3.0.0-alpha.7

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 (81) hide show
  1. package/dist/node/chunks/{dep-28f8c91c.js → dep-16fa9be9.js} +1 -1
  2. package/dist/node/chunks/{dep-24157481.js → dep-17430d09.js} +0 -0
  3. package/dist/node/chunks/{dep-ce833324.js → dep-395deadd.js} +1 -1
  4. package/dist/node/chunks/{dep-35b61ee3.js → dep-3a62832d.js} +100 -47
  5. package/dist/node/chunks/{dep-aea1d487.js → dep-e214e00e.js} +33673 -33367
  6. package/dist/node/cli.js +7 -5
  7. package/dist/node/constants.js +1 -1
  8. package/dist/node/index.d.ts +36 -17
  9. package/dist/node/index.js +1 -1
  10. package/dist/node-cjs/publicUtils.cjs +0 -11
  11. package/package.json +10 -9
  12. package/dist/node/build.d.ts +0 -178
  13. package/dist/node/certificate.d.ts +0 -2
  14. package/dist/node/cli.d.ts +0 -1
  15. package/dist/node/config.d.ts +0 -240
  16. package/dist/node/constants.d.ts +0 -35
  17. package/dist/node/env.d.ts +0 -3
  18. package/dist/node/http.d.ts +0 -88
  19. package/dist/node/logger.d.ts +0 -31
  20. package/dist/node/optimizer/esbuildDepPlugin.d.ts +0 -4
  21. package/dist/node/optimizer/index.d.ts +0 -167
  22. package/dist/node/optimizer/registerMissing.d.ts +0 -3
  23. package/dist/node/optimizer/scan.d.ts +0 -8
  24. package/dist/node/packages.d.ts +0 -27
  25. package/dist/node/plugin.d.ts +0 -129
  26. package/dist/node/plugins/asset.d.ts +0 -68
  27. package/dist/node/plugins/assetImportMetaUrl.d.ts +0 -13
  28. package/dist/node/plugins/clientInjections.d.ts +0 -7
  29. package/dist/node/plugins/css.d.ts +0 -86
  30. package/dist/node/plugins/dataUri.d.ts +0 -5
  31. package/dist/node/plugins/define.d.ts +0 -3
  32. package/dist/node/plugins/dynamicImportVars.d.ts +0 -9
  33. package/dist/node/plugins/ensureWatch.d.ts +0 -5
  34. package/dist/node/plugins/esbuild.d.ts +0 -15
  35. package/dist/node/plugins/html.d.ts +0 -120
  36. package/dist/node/plugins/importAnalysis.d.ts +0 -47
  37. package/dist/node/plugins/importAnalysisBuild.d.ts +0 -16
  38. package/dist/node/plugins/importMetaGlob.d.ts +0 -34
  39. package/dist/node/plugins/index.d.ts +0 -3
  40. package/dist/node/plugins/json.d.ts +0 -23
  41. package/dist/node/plugins/loadFallback.d.ts +0 -5
  42. package/dist/node/plugins/manifest.d.ts +0 -14
  43. package/dist/node/plugins/metadata.d.ts +0 -9
  44. package/dist/node/plugins/modulePreloadPolyfill.d.ts +0 -4
  45. package/dist/node/plugins/optimizedDeps.d.ts +0 -4
  46. package/dist/node/plugins/preAlias.d.ts +0 -5
  47. package/dist/node/plugins/reporter.d.ts +0 -3
  48. package/dist/node/plugins/resolve.d.ts +0 -39
  49. package/dist/node/plugins/splitVendorChunk.d.ts +0 -12
  50. package/dist/node/plugins/ssrRequireHook.d.ts +0 -12
  51. package/dist/node/plugins/terser.d.ts +0 -3
  52. package/dist/node/plugins/wasm.d.ts +0 -4
  53. package/dist/node/plugins/worker.d.ts +0 -9
  54. package/dist/node/plugins/workerImportMetaUrl.d.ts +0 -3
  55. package/dist/node/preview.d.ts +0 -33
  56. package/dist/node/publicUtils.d.ts +0 -11
  57. package/dist/node/server/hmr.d.ts +0 -39
  58. package/dist/node/server/index.d.ts +0 -198
  59. package/dist/node/server/middlewares/base.d.ts +0 -3
  60. package/dist/node/server/middlewares/compression.d.ts +0 -1
  61. package/dist/node/server/middlewares/error.d.ts +0 -8
  62. package/dist/node/server/middlewares/indexHtml.d.ts +0 -4
  63. package/dist/node/server/middlewares/proxy.d.ts +0 -20
  64. package/dist/node/server/middlewares/spaFallback.d.ts +0 -2
  65. package/dist/node/server/middlewares/static.d.ts +0 -6
  66. package/dist/node/server/middlewares/time.d.ts +0 -2
  67. package/dist/node/server/middlewares/transform.d.ts +0 -3
  68. package/dist/node/server/moduleGraph.d.ts +0 -55
  69. package/dist/node/server/openBrowser.d.ts +0 -15
  70. package/dist/node/server/pluginContainer.d.ts +0 -41
  71. package/dist/node/server/searchRoot.d.ts +0 -8
  72. package/dist/node/server/send.d.ts +0 -10
  73. package/dist/node/server/sourcemap.d.ts +0 -11
  74. package/dist/node/server/transformRequest.d.ts +0 -14
  75. package/dist/node/server/ws.d.ts +0 -55
  76. package/dist/node/ssr/ssrExternal.d.ts +0 -11
  77. package/dist/node/ssr/ssrManifestPlugin.d.ts +0 -3
  78. package/dist/node/ssr/ssrModuleLoader.d.ts +0 -7
  79. package/dist/node/ssr/ssrStacktrace.d.ts +0 -3
  80. package/dist/node/ssr/ssrTransform.d.ts +0 -14
  81. package/dist/node/utils.d.ts +0 -144
@@ -1,240 +0,0 @@
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>;
@@ -1,35 +0,0 @@
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;
@@ -1,3 +0,0 @@
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[];
@@ -1,88 +0,0 @@
1
- /// <reference types="node" />
2
- import type { Server as HttpServer, OutgoingHttpHeaders as HttpServerHeaders } from 'http';
3
- import type { ServerOptions as HttpsServerOptions } from 'https';
4
- import type { Connect } from 'types/connect';
5
- import type { ProxyOptions } from './server/middlewares/proxy';
6
- import type { Logger } from './logger';
7
- export interface CommonServerOptions {
8
- /**
9
- * Specify server port. Note if the port is already being used, Vite will
10
- * automatically try the next available port so this may not be the actual
11
- * port the server ends up listening on.
12
- */
13
- port?: number;
14
- /**
15
- * If enabled, vite will exit if specified port is already in use
16
- */
17
- strictPort?: boolean;
18
- /**
19
- * Specify which IP addresses the server should listen on.
20
- * Set to 0.0.0.0 to listen on all addresses, including LAN and public addresses.
21
- */
22
- host?: string | boolean;
23
- /**
24
- * Enable TLS + HTTP/2.
25
- * Note: this downgrades to TLS only when the proxy option is also used.
26
- */
27
- https?: boolean | HttpsServerOptions;
28
- /**
29
- * Open browser window on startup
30
- */
31
- open?: boolean | string;
32
- /**
33
- * Configure custom proxy rules for the dev server. Expects an object
34
- * of `{ key: options }` pairs.
35
- * Uses [`http-proxy`](https://github.com/http-party/node-http-proxy).
36
- * Full options [here](https://github.com/http-party/node-http-proxy#options).
37
- *
38
- * Example `vite.config.js`:
39
- * ``` js
40
- * module.exports = {
41
- * proxy: {
42
- * // string shorthand
43
- * '/foo': 'http://localhost:4567/foo',
44
- * // with options
45
- * '/api': {
46
- * target: 'http://jsonplaceholder.typicode.com',
47
- * changeOrigin: true,
48
- * rewrite: path => path.replace(/^\/api/, '')
49
- * }
50
- * }
51
- * }
52
- * ```
53
- */
54
- proxy?: Record<string, string | ProxyOptions>;
55
- /**
56
- * Configure CORS for the dev server.
57
- * Uses https://github.com/expressjs/cors.
58
- * Set to `true` to allow all methods from any origin, or configure separately
59
- * using an object.
60
- */
61
- cors?: CorsOptions | boolean;
62
- /**
63
- * Specify server response headers.
64
- */
65
- headers?: HttpServerHeaders;
66
- }
67
- /**
68
- * https://github.com/expressjs/cors#configuration-options
69
- */
70
- export interface CorsOptions {
71
- origin?: CorsOrigin | ((origin: string, cb: (err: Error, origins: CorsOrigin) => void) => void);
72
- methods?: string | string[];
73
- allowedHeaders?: string | string[];
74
- exposedHeaders?: string | string[];
75
- credentials?: boolean;
76
- maxAge?: number;
77
- preflightContinue?: boolean;
78
- optionsSuccessStatus?: number;
79
- }
80
- export declare type CorsOrigin = boolean | string | RegExp | (string | RegExp)[];
81
- export declare function resolveHttpServer({ proxy }: CommonServerOptions, app: Connect.Server, httpsOptions?: HttpsServerOptions): Promise<HttpServer>;
82
- export declare function resolveHttpsConfig(https: boolean | HttpsServerOptions | undefined, cacheDir: string): Promise<HttpsServerOptions | undefined>;
83
- export declare function httpServerStart(httpServer: HttpServer, serverOptions: {
84
- port: number;
85
- strictPort: boolean | undefined;
86
- host: string | undefined;
87
- logger: Logger;
88
- }): Promise<number>;
@@ -1,31 +0,0 @@
1
- /// <reference types="node" />
2
- import type { Server } from 'net';
3
- import type { RollupError } from 'rollup';
4
- import type { CommonServerOptions } from './http';
5
- import type { ResolvedConfig } from '.';
6
- export declare type LogType = 'error' | 'warn' | 'info';
7
- export declare type LogLevel = LogType | 'silent';
8
- export interface Logger {
9
- info(msg: string, options?: LogOptions): void;
10
- warn(msg: string, options?: LogOptions): void;
11
- warnOnce(msg: string, options?: LogOptions): void;
12
- error(msg: string, options?: LogErrorOptions): void;
13
- clearScreen(type: LogType): void;
14
- hasErrorLogged(error: Error | RollupError): boolean;
15
- hasWarned: boolean;
16
- }
17
- export interface LogOptions {
18
- clear?: boolean;
19
- timestamp?: boolean;
20
- }
21
- export interface LogErrorOptions extends LogOptions {
22
- error?: Error | RollupError | null;
23
- }
24
- export declare const LogLevels: Record<LogLevel, number>;
25
- export interface LoggerOptions {
26
- prefix?: string;
27
- allowClearScreen?: boolean;
28
- customLogger?: Logger;
29
- }
30
- export declare function createLogger(level?: LogLevel, options?: LoggerOptions): Logger;
31
- export declare function printCommonServerUrls(server: Server, options: CommonServerOptions, config: ResolvedConfig): void;
@@ -1,4 +0,0 @@
1
- import type { Plugin } from 'esbuild';
2
- import type { ResolvedConfig } from '..';
3
- import type { ExportsData } from '.';
4
- export declare function esbuildDepPlugin(qualified: Record<string, string>, exportsData: Record<string, ExportsData>, config: ResolvedConfig): Plugin;
@@ -1,167 +0,0 @@
1
- import type { BuildOptions as EsbuildBuildOptions } from 'esbuild';
2
- import { parse } from 'es-module-lexer';
3
- import type { ResolvedConfig } from '../config';
4
- export declare const debuggerViteDeps: (...args: any[]) => any;
5
- export declare type ExportsData = ReturnType<typeof parse> & {
6
- hasReExports?: true;
7
- jsxLoader?: true;
8
- };
9
- export interface OptimizedDeps {
10
- metadata: DepOptimizationMetadata;
11
- scanProcessing?: Promise<void>;
12
- registerMissingImport: (id: string, resolved: string) => OptimizedDepInfo;
13
- }
14
- export interface DepOptimizationOptions {
15
- /**
16
- * By default, Vite will crawl your `index.html` to detect dependencies that
17
- * need to be pre-bundled. If `build.rollupOptions.input` is specified, Vite
18
- * will crawl those entry points instead.
19
- *
20
- * If neither of these fit your needs, you can specify custom entries using
21
- * this option - the value should be a fast-glob pattern or array of patterns
22
- * (https://github.com/mrmlnc/fast-glob#basic-syntax) that are relative from
23
- * vite project root. This will overwrite default entries inference.
24
- */
25
- entries?: string | string[];
26
- /**
27
- * Force optimize listed dependencies (must be resolvable import paths,
28
- * cannot be globs).
29
- */
30
- include?: string[];
31
- /**
32
- * Do not optimize these dependencies (must be resolvable import paths,
33
- * cannot be globs).
34
- */
35
- exclude?: string[];
36
- /**
37
- * Force ESM interop when importing for these dependencies. Some legacy
38
- * packages advertise themselves as ESM but use `require` internally
39
- * @experimental
40
- */
41
- needsInterop?: string[];
42
- /**
43
- * Options to pass to esbuild during the dep scanning and optimization
44
- *
45
- * Certain options are omitted since changing them would not be compatible
46
- * with Vite's dep optimization.
47
- *
48
- * - `external` is also omitted, use Vite's `optimizeDeps.exclude` option
49
- * - `plugins` are merged with Vite's dep plugin
50
- *
51
- * https://esbuild.github.io/api
52
- */
53
- esbuildOptions?: Omit<EsbuildBuildOptions, 'bundle' | 'entryPoints' | 'external' | 'write' | 'watch' | 'outdir' | 'outfile' | 'outbase' | 'outExtension' | 'metafile'>;
54
- /**
55
- * List of file extensions that can be optimized. A corresponding esbuild
56
- * plugin must exist to handle the specific extension.
57
- *
58
- * By default, Vite can optimize `.mjs`, `.js`, and `.ts` files. This option
59
- * allows specifying additional extensions.
60
- *
61
- * @experimental
62
- */
63
- extensions?: string[];
64
- /**
65
- * Disables dependencies optimizations
66
- * @default false
67
- * @experimental
68
- */
69
- disabled?: boolean;
70
- }
71
- export interface DepOptimizationResult {
72
- metadata: DepOptimizationMetadata;
73
- /**
74
- * When doing a re-run, if there are newly discovered dependendencies
75
- * the page reload will be delayed until the next rerun so we need
76
- * to be able to discard the result
77
- */
78
- commit: () => Promise<void>;
79
- cancel: () => void;
80
- }
81
- export interface DepOptimizationProcessing {
82
- promise: Promise<void>;
83
- resolve: () => void;
84
- }
85
- export interface OptimizedDepInfo {
86
- id: string;
87
- file: string;
88
- src?: string;
89
- needsInterop?: boolean;
90
- browserHash?: string;
91
- fileHash?: string;
92
- /**
93
- * During optimization, ids can still be resolved to their final location
94
- * but the bundles may not yet be saved to disk
95
- */
96
- processing?: Promise<void>;
97
- /**
98
- * ExportData cache, discovered deps will parse the src entry to get exports
99
- * data used both to define if interop is needed and when pre-bundling
100
- */
101
- exportsData?: Promise<ExportsData>;
102
- }
103
- export interface DepOptimizationMetadata {
104
- /**
105
- * The main hash is determined by user config and dependency lockfiles.
106
- * This is checked on server startup to avoid unnecessary re-bundles.
107
- */
108
- hash: string;
109
- /**
110
- * The browser hash is determined by the main hash plus additional dependencies
111
- * discovered at runtime. This is used to invalidate browser requests to
112
- * optimized deps.
113
- */
114
- browserHash: string;
115
- /**
116
- * Metadata for each already optimized dependency
117
- */
118
- optimized: Record<string, OptimizedDepInfo>;
119
- /**
120
- * Metadata for non-entry optimized chunks and dynamic imports
121
- */
122
- chunks: Record<string, OptimizedDepInfo>;
123
- /**
124
- * Metadata for each newly discovered dependency after processing
125
- */
126
- discovered: Record<string, OptimizedDepInfo>;
127
- /**
128
- * OptimizedDepInfo list
129
- */
130
- depInfoList: OptimizedDepInfo[];
131
- }
132
- /**
133
- * Used by Vite CLI when running `vite optimize`
134
- */
135
- export declare function optimizeDeps(config: ResolvedConfig, force?: boolean | undefined, asCommand?: boolean): Promise<DepOptimizationMetadata>;
136
- export declare function createOptimizedDepsMetadata(config: ResolvedConfig, timestamp?: string): DepOptimizationMetadata;
137
- export declare function addOptimizedDepInfo(metadata: DepOptimizationMetadata, type: 'optimized' | 'discovered' | 'chunks', depInfo: OptimizedDepInfo): OptimizedDepInfo;
138
- /**
139
- * Creates the initial dep optimization metadata, loading it from the deps cache
140
- * if it exists and pre-bundling isn't forced
141
- */
142
- export declare function loadCachedDepOptimizationMetadata(config: ResolvedConfig, force?: boolean | undefined, asCommand?: boolean): DepOptimizationMetadata | undefined;
143
- /**
144
- * Initial optimizeDeps at server start. Perform a fast scan using esbuild to
145
- * find deps to pre-bundle and include user hard-coded dependencies
146
- */
147
- export declare function discoverProjectDependencies(config: ResolvedConfig, timestamp?: string): Promise<Record<string, OptimizedDepInfo>>;
148
- export declare function depsLogString(qualifiedIds: string[]): string;
149
- /**
150
- * Internally, Vite uses this function to prepare a optimizeDeps run. When Vite starts, we can get
151
- * the metadata and start the server without waiting for the optimizeDeps processing to be completed
152
- */
153
- export declare function runOptimizeDeps(config: ResolvedConfig, depsInfo: Record<string, OptimizedDepInfo>): Promise<DepOptimizationResult>;
154
- export declare function findKnownImports(config: ResolvedConfig): Promise<string[]>;
155
- export declare function newDepOptimizationProcessing(): DepOptimizationProcessing;
156
- export declare function depsFromOptimizedDepInfo(depsInfo: Record<string, OptimizedDepInfo>): {
157
- [k: string]: string;
158
- };
159
- export declare function getOptimizedDepPath(id: string, config: ResolvedConfig): string;
160
- export declare function getDepsCacheDir(config: ResolvedConfig): string;
161
- export declare function isOptimizedDepFile(id: string, config: ResolvedConfig): boolean;
162
- export declare function createIsOptimizedDepUrl(config: ResolvedConfig): (url: string) => boolean;
163
- export declare function extractExportsData(filePath: string, config: ResolvedConfig): Promise<ExportsData>;
164
- export declare function getDepHash(config: ResolvedConfig): string;
165
- export declare function optimizedDepInfoFromId(metadata: DepOptimizationMetadata, id: string): OptimizedDepInfo | undefined;
166
- export declare function optimizedDepInfoFromFile(metadata: DepOptimizationMetadata, file: string): OptimizedDepInfo | undefined;
167
- export declare function optimizedDepNeedsInterop(metadata: DepOptimizationMetadata, file: string, config: ResolvedConfig): Promise<boolean | undefined>;
@@ -1,3 +0,0 @@
1
- import type { ViteDevServer } from '..';
2
- import type { OptimizedDeps } from '.';
3
- export declare function createOptimizedDeps(server: ViteDevServer): OptimizedDeps;
@@ -1,8 +0,0 @@
1
- import type { ResolvedConfig } from '..';
2
- export declare const importsRE: RegExp;
3
- export declare function scanImports(config: ResolvedConfig): Promise<{
4
- deps: Record<string, string>;
5
- missing: Record<string, string>;
6
- }>;
7
- export declare const scriptRE: RegExp;
8
- export declare const commentRE: RegExp;
@@ -1,27 +0,0 @@
1
- import type { ResolvedConfig } from './config';
2
- import type { Plugin } from './plugin';
3
- /** Cache for package.json resolution and package.json contents */
4
- export declare type PackageCache = Map<string, PackageData>;
5
- export interface PackageData {
6
- dir: string;
7
- hasSideEffects: (id: string) => boolean | 'no-treeshake';
8
- webResolvedImports: Record<string, string | undefined>;
9
- nodeResolvedImports: Record<string, string | undefined>;
10
- setResolvedCache: (key: string, entry: string, targetWeb: boolean) => void;
11
- getResolvedCache: (key: string, targetWeb: boolean) => string | undefined;
12
- data: {
13
- [field: string]: any;
14
- name: string;
15
- type: string;
16
- version: string;
17
- main: string;
18
- module: string;
19
- browser: string | Record<string, string | false>;
20
- exports: string | Record<string, any> | string[];
21
- dependencies: Record<string, string>;
22
- };
23
- }
24
- export declare function invalidatePackageData(packageCache: PackageCache, pkgPath: string): void;
25
- export declare function resolvePackageData(id: string, basedir: string, preserveSymlinks?: boolean, packageCache?: PackageCache): PackageData | null;
26
- export declare function loadPackageData(pkgPath: string, preserveSymlinks?: boolean, packageCache?: PackageCache): PackageData;
27
- export declare function watchPackageDataPlugin(config: ResolvedConfig): Plugin;