vite 3.0.0-alpha.5 → 3.0.0-alpha.6

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 (80) hide show
  1. package/dist/node/chunks/{dep-0232e200.js → dep-52974b5a.js} +42 -11
  2. package/dist/node/chunks/{dep-21067347.js → dep-8bed6f50.js} +1 -1
  3. package/dist/node/chunks/{dep-cd161504.js → dep-a4f17494.js} +1 -1
  4. package/dist/node/chunks/{dep-13a14c32.js → dep-b4474709.js} +1 -1
  5. package/dist/node/cli.js +5 -5
  6. package/dist/node/constants.js +1 -1
  7. package/dist/node/index.d.ts +79 -2
  8. package/dist/node/index.js +1 -1
  9. package/package.json +3 -2
  10. package/types/es-module-lexer.d.ts +90 -0
  11. package/dist/node/build.d.ts +0 -178
  12. package/dist/node/certificate.d.ts +0 -2
  13. package/dist/node/cli.d.ts +0 -1
  14. package/dist/node/config.d.ts +0 -246
  15. package/dist/node/constants.d.ts +0 -35
  16. package/dist/node/env.d.ts +0 -3
  17. package/dist/node/http.d.ts +0 -88
  18. package/dist/node/logger.d.ts +0 -31
  19. package/dist/node/optimizer/esbuildDepPlugin.d.ts +0 -4
  20. package/dist/node/optimizer/index.d.ts +0 -181
  21. package/dist/node/optimizer/optimizer.d.ts +0 -4
  22. package/dist/node/optimizer/scan.d.ts +0 -8
  23. package/dist/node/packages.d.ts +0 -27
  24. package/dist/node/plugin.d.ts +0 -130
  25. package/dist/node/plugins/asset.d.ts +0 -68
  26. package/dist/node/plugins/assetImportMetaUrl.d.ts +0 -13
  27. package/dist/node/plugins/clientInjections.d.ts +0 -7
  28. package/dist/node/plugins/css.d.ts +0 -86
  29. package/dist/node/plugins/dataUri.d.ts +0 -5
  30. package/dist/node/plugins/define.d.ts +0 -3
  31. package/dist/node/plugins/dynamicImportVars.d.ts +0 -9
  32. package/dist/node/plugins/ensureWatch.d.ts +0 -5
  33. package/dist/node/plugins/esbuild.d.ts +0 -15
  34. package/dist/node/plugins/html.d.ts +0 -120
  35. package/dist/node/plugins/importAnalysis.d.ts +0 -47
  36. package/dist/node/plugins/importAnalysisBuild.d.ts +0 -16
  37. package/dist/node/plugins/importMetaGlob.d.ts +0 -34
  38. package/dist/node/plugins/index.d.ts +0 -3
  39. package/dist/node/plugins/json.d.ts +0 -23
  40. package/dist/node/plugins/loadFallback.d.ts +0 -5
  41. package/dist/node/plugins/manifest.d.ts +0 -14
  42. package/dist/node/plugins/metadata.d.ts +0 -9
  43. package/dist/node/plugins/modulePreloadPolyfill.d.ts +0 -4
  44. package/dist/node/plugins/optimizedDeps.d.ts +0 -7
  45. package/dist/node/plugins/preAlias.d.ts +0 -6
  46. package/dist/node/plugins/reporter.d.ts +0 -3
  47. package/dist/node/plugins/resolve.d.ts +0 -41
  48. package/dist/node/plugins/splitVendorChunk.d.ts +0 -12
  49. package/dist/node/plugins/ssrRequireHook.d.ts +0 -12
  50. package/dist/node/plugins/terser.d.ts +0 -3
  51. package/dist/node/plugins/wasm.d.ts +0 -4
  52. package/dist/node/plugins/worker.d.ts +0 -9
  53. package/dist/node/plugins/workerImportMetaUrl.d.ts +0 -3
  54. package/dist/node/preview.d.ts +0 -33
  55. package/dist/node/publicUtils.d.ts +0 -11
  56. package/dist/node/server/hmr.d.ts +0 -39
  57. package/dist/node/server/index.d.ts +0 -189
  58. package/dist/node/server/middlewares/base.d.ts +0 -3
  59. package/dist/node/server/middlewares/compression.d.ts +0 -1
  60. package/dist/node/server/middlewares/error.d.ts +0 -8
  61. package/dist/node/server/middlewares/indexHtml.d.ts +0 -4
  62. package/dist/node/server/middlewares/proxy.d.ts +0 -20
  63. package/dist/node/server/middlewares/spaFallback.d.ts +0 -2
  64. package/dist/node/server/middlewares/static.d.ts +0 -6
  65. package/dist/node/server/middlewares/time.d.ts +0 -2
  66. package/dist/node/server/middlewares/transform.d.ts +0 -3
  67. package/dist/node/server/moduleGraph.d.ts +0 -55
  68. package/dist/node/server/openBrowser.d.ts +0 -15
  69. package/dist/node/server/pluginContainer.d.ts +0 -41
  70. package/dist/node/server/searchRoot.d.ts +0 -8
  71. package/dist/node/server/send.d.ts +0 -10
  72. package/dist/node/server/sourcemap.d.ts +0 -11
  73. package/dist/node/server/transformRequest.d.ts +0 -14
  74. package/dist/node/server/ws.d.ts +0 -55
  75. package/dist/node/ssr/ssrExternal.d.ts +0 -11
  76. package/dist/node/ssr/ssrManifestPlugin.d.ts +0 -3
  77. package/dist/node/ssr/ssrModuleLoader.d.ts +0 -7
  78. package/dist/node/ssr/ssrStacktrace.d.ts +0 -3
  79. package/dist/node/ssr/ssrTransform.d.ts +0 -14
  80. package/dist/node/utils.d.ts +0 -144
@@ -1,246 +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
- * Force dep pre-optimization regardless of whether deps have changed.
110
- * @experimental
111
- */
112
- force?: boolean;
113
- /**
114
- * Dep optimization options
115
- */
116
- optimizeDeps?: DepOptimizationOptions;
117
- /**
118
- * SSR specific options
119
- */
120
- ssr?: SSROptions;
121
- /**
122
- * Experimental features
123
- *
124
- * Features under this field are addressed to be changed that might NOT follow semver.
125
- * Please be careful and always pin Vite's version when using them.
126
- * @experimental
127
- */
128
- experimental?: ExperimentalOptions;
129
- /**
130
- * Log level.
131
- * Default: 'info'
132
- */
133
- logLevel?: LogLevel;
134
- /**
135
- * Custom logger.
136
- */
137
- customLogger?: Logger;
138
- /**
139
- * Default: true
140
- */
141
- clearScreen?: boolean;
142
- /**
143
- * Environment files directory. Can be an absolute path, or a path relative from
144
- * the location of the config file itself.
145
- * @default root
146
- */
147
- envDir?: string;
148
- /**
149
- * Env variables starts with `envPrefix` will be exposed to your client source code via import.meta.env.
150
- * @default 'VITE_'
151
- */
152
- envPrefix?: string | string[];
153
- /**
154
- * Worker bundle options
155
- */
156
- worker?: {
157
- /**
158
- * Output format for worker bundle
159
- * @default 'iife'
160
- */
161
- format?: 'es' | 'iife';
162
- /**
163
- * Vite plugins that apply to worker bundle
164
- */
165
- plugins?: PluginOption[];
166
- /**
167
- * Rollup options to build worker bundle
168
- */
169
- rollupOptions?: Omit<RollupOptions, 'plugins' | 'input' | 'onwarn' | 'preserveEntrySignatures'>;
170
- };
171
- /**
172
- * Whether your application is a Single Page Application (SPA). Set to `false`
173
- * for other kinds of apps like MPAs.
174
- * @default true
175
- */
176
- spa?: boolean;
177
- }
178
- export interface ExperimentalOptions {
179
- /**
180
- * Append fake `&lang.(ext)` when queries are specified, to preseve the file extension for following plugins to process.
181
- *
182
- * @experimental
183
- * @default false
184
- */
185
- importGlobRestoreExtension?: boolean;
186
- }
187
- export declare type SSRTarget = 'node' | 'webworker';
188
- export interface SSROptions {
189
- external?: string[];
190
- noExternal?: string | RegExp | (string | RegExp)[] | true;
191
- /**
192
- * Define the target for the ssr build. The browser field in package.json
193
- * is ignored for node but used if webworker is the target
194
- * Default: 'node'
195
- */
196
- target?: SSRTarget;
197
- }
198
- export interface ResolveWorkerOptions {
199
- format: 'es' | 'iife';
200
- plugins: Plugin[];
201
- rollupOptions: RollupOptions;
202
- }
203
- export interface InlineConfig extends UserConfig {
204
- configFile?: string | false;
205
- envFile?: false;
206
- }
207
- export declare type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | 'assetsInclude' | 'optimizeDeps' | 'worker'> & {
208
- configFile: string | undefined;
209
- configFileDependencies: string[];
210
- inlineConfig: InlineConfig;
211
- root: string;
212
- base: string;
213
- publicDir: string;
214
- cacheDir: string;
215
- command: 'build' | 'serve';
216
- mode: string;
217
- isWorker: boolean;
218
- /** @internal */
219
- mainConfig: ResolvedConfig | null;
220
- isProduction: boolean;
221
- env: Record<string, any>;
222
- resolve: ResolveOptions & {
223
- alias: Alias[];
224
- };
225
- plugins: readonly Plugin[];
226
- server: ResolvedServerOptions;
227
- build: ResolvedBuildOptions;
228
- preview: ResolvedPreviewOptions;
229
- assetsInclude: (file: string) => boolean;
230
- logger: Logger;
231
- createResolver: (options?: Partial<InternalResolveOptions>) => ResolveFn;
232
- optimizeDeps: DepOptimizationOptions;
233
- /** @internal */
234
- packageCache: PackageCache;
235
- worker: ResolveWorkerOptions;
236
- spa: boolean;
237
- }>;
238
- export declare type ResolveFn = (id: string, importer?: string, aliasOnly?: boolean, ssr?: boolean) => Promise<string | undefined>;
239
- export declare function resolveConfig(inlineConfig: InlineConfig, command: 'build' | 'serve', defaultMode?: string): Promise<ResolvedConfig>;
240
- export declare function sortUserPlugins(plugins: (Plugin | Plugin[])[] | undefined): [Plugin[], Plugin[], Plugin[]];
241
- export declare function loadConfigFromFile(configEnv: ConfigEnv, configFile?: string, configRoot?: string, logLevel?: LogLevel): Promise<{
242
- path: string;
243
- config: UserConfig;
244
- dependencies: string[];
245
- } | null>;
246
- export declare function isDepsOptimizerEnabled(config: ResolvedConfig): boolean;
@@ -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,181 +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 { initDepsOptimizer, getDepsOptimizer } from './optimizer';
5
- export declare const debuggerViteDeps: (...args: any[]) => any;
6
- export declare type ExportsData = ReturnType<typeof parse> & {
7
- hasReExports?: true;
8
- jsxLoader?: true;
9
- };
10
- export interface DepsOptimizer {
11
- metadata: DepOptimizationMetadata;
12
- scanProcessing?: Promise<void>;
13
- registerMissingImport: (id: string, resolved: string) => OptimizedDepInfo;
14
- run: () => void;
15
- isOptimizedDepFile: (id: string) => boolean;
16
- isOptimizedDepUrl: (url: string) => boolean;
17
- getOptimizedDepId: (depInfo: OptimizedDepInfo) => string;
18
- options: DepOptimizationOptions;
19
- }
20
- export interface DepOptimizationOptions {
21
- /**
22
- * By default, Vite will crawl your `index.html` to detect dependencies that
23
- * need to be pre-bundled. If `build.rollupOptions.input` is specified, Vite
24
- * will crawl those entry points instead.
25
- *
26
- * If neither of these fit your needs, you can specify custom entries using
27
- * this option - the value should be a fast-glob pattern or array of patterns
28
- * (https://github.com/mrmlnc/fast-glob#basic-syntax) that are relative from
29
- * vite project root. This will overwrite default entries inference.
30
- */
31
- entries?: string | string[];
32
- /**
33
- * Force optimize listed dependencies (must be resolvable import paths,
34
- * cannot be globs).
35
- */
36
- include?: string[];
37
- /**
38
- * Do not optimize these dependencies (must be resolvable import paths,
39
- * cannot be globs).
40
- */
41
- exclude?: string[];
42
- /**
43
- * Force ESM interop when importing for these dependencies. Some legacy
44
- * packages advertise themselves as ESM but use `require` internally
45
- * @experimental
46
- */
47
- needsInterop?: string[];
48
- /**
49
- * Options to pass to esbuild during the dep scanning and optimization
50
- *
51
- * Certain options are omitted since changing them would not be compatible
52
- * with Vite's dep optimization.
53
- *
54
- * - `external` is also omitted, use Vite's `optimizeDeps.exclude` option
55
- * - `plugins` are merged with Vite's dep plugin
56
- *
57
- * https://esbuild.github.io/api
58
- */
59
- esbuildOptions?: Omit<EsbuildBuildOptions, 'bundle' | 'entryPoints' | 'external' | 'write' | 'watch' | 'outdir' | 'outfile' | 'outbase' | 'outExtension' | 'metafile'>;
60
- /**
61
- * List of file extensions that can be optimized. A corresponding esbuild
62
- * plugin must exist to handle the specific extension.
63
- *
64
- * By default, Vite can optimize `.mjs`, `.js`, and `.ts` files. This option
65
- * allows specifying additional extensions.
66
- *
67
- * @experimental
68
- */
69
- extensions?: string[];
70
- /**
71
- * Disables dependencies optimizations, true disables the optimizer during
72
- * build and dev. Pass 'build' or 'dev' to only disable the optimizer in
73
- * one of the modes. Deps optimization is enabled by default in both
74
- * @default false
75
- * @experimental
76
- */
77
- disabled?: boolean | 'build' | 'dev';
78
- }
79
- export interface DepOptimizationResult {
80
- metadata: DepOptimizationMetadata;
81
- /**
82
- * When doing a re-run, if there are newly discovered dependendencies
83
- * the page reload will be delayed until the next rerun so we need
84
- * to be able to discard the result
85
- */
86
- commit: () => Promise<void>;
87
- cancel: () => void;
88
- }
89
- export interface DepOptimizationProcessing {
90
- promise: Promise<void>;
91
- resolve: () => void;
92
- }
93
- export interface OptimizedDepInfo {
94
- id: string;
95
- file: string;
96
- src?: string;
97
- needsInterop?: boolean;
98
- browserHash?: string;
99
- fileHash?: string;
100
- /**
101
- * During optimization, ids can still be resolved to their final location
102
- * but the bundles may not yet be saved to disk
103
- */
104
- processing?: Promise<void>;
105
- /**
106
- * ExportData cache, discovered deps will parse the src entry to get exports
107
- * data used both to define if interop is needed and when pre-bundling
108
- */
109
- exportsData?: Promise<ExportsData>;
110
- }
111
- export interface DepOptimizationMetadata {
112
- /**
113
- * The main hash is determined by user config and dependency lockfiles.
114
- * This is checked on server startup to avoid unnecessary re-bundles.
115
- */
116
- hash: string;
117
- /**
118
- * The browser hash is determined by the main hash plus additional dependencies
119
- * discovered at runtime. This is used to invalidate browser requests to
120
- * optimized deps.
121
- */
122
- browserHash: string;
123
- /**
124
- * Metadata for each already optimized dependency
125
- */
126
- optimized: Record<string, OptimizedDepInfo>;
127
- /**
128
- * Metadata for non-entry optimized chunks and dynamic imports
129
- */
130
- chunks: Record<string, OptimizedDepInfo>;
131
- /**
132
- * Metadata for each newly discovered dependency after processing
133
- */
134
- discovered: Record<string, OptimizedDepInfo>;
135
- /**
136
- * OptimizedDepInfo list
137
- */
138
- depInfoList: OptimizedDepInfo[];
139
- }
140
- /**
141
- * Used by Vite CLI when running `vite optimize`
142
- */
143
- export declare function optimizeDeps(config: ResolvedConfig, force?: boolean | undefined, asCommand?: boolean): Promise<DepOptimizationMetadata>;
144
- export declare function initDepsOptimizerMetadata(config: ResolvedConfig, timestamp?: string): DepOptimizationMetadata;
145
- export declare function addOptimizedDepInfo(metadata: DepOptimizationMetadata, type: 'optimized' | 'discovered' | 'chunks', depInfo: OptimizedDepInfo): OptimizedDepInfo;
146
- /**
147
- * Creates the initial dep optimization metadata, loading it from the deps cache
148
- * if it exists and pre-bundling isn't forced
149
- */
150
- export declare function loadCachedDepOptimizationMetadata(config: ResolvedConfig, force?: boolean | undefined, asCommand?: boolean): DepOptimizationMetadata | undefined;
151
- /**
152
- * Initial optimizeDeps at server start. Perform a fast scan using esbuild to
153
- * find deps to pre-bundle and include user hard-coded dependencies
154
- */
155
- export declare function discoverProjectDependencies(config: ResolvedConfig, timestamp?: string): Promise<Record<string, OptimizedDepInfo>>;
156
- /**
157
- * Create the initial discovered deps list. At build time we only
158
- * have the manually included deps. During dev, a scan phase is
159
- * performed and knownDeps is the list of discovered deps
160
- */
161
- export declare function initialProjectDependencies(config: ResolvedConfig, timestamp?: string, knownDeps?: Record<string, string>): Promise<Record<string, OptimizedDepInfo>>;
162
- export declare function depsLogString(qualifiedIds: string[]): string;
163
- /**
164
- * Internally, Vite uses this function to prepare a optimizeDeps run. When Vite starts, we can get
165
- * the metadata and start the server without waiting for the optimizeDeps processing to be completed
166
- */
167
- export declare function runOptimizeDeps(resolvedConfig: ResolvedConfig, depsInfo: Record<string, OptimizedDepInfo>): Promise<DepOptimizationResult>;
168
- export declare function findKnownImports(config: ResolvedConfig): Promise<string[]>;
169
- export declare function newDepOptimizationProcessing(): DepOptimizationProcessing;
170
- export declare function depsFromOptimizedDepInfo(depsInfo: Record<string, OptimizedDepInfo>): {
171
- [k: string]: string;
172
- };
173
- export declare function getOptimizedDepPath(id: string, config: ResolvedConfig): string;
174
- export declare function getDepsCacheDir(config: ResolvedConfig): string;
175
- export declare function isOptimizedDepFile(id: string, config: ResolvedConfig): boolean;
176
- export declare function createIsOptimizedDepUrl(config: ResolvedConfig): (url: string) => boolean;
177
- export declare function extractExportsData(filePath: string, config: ResolvedConfig): Promise<ExportsData>;
178
- export declare function getDepHash(config: ResolvedConfig): string;
179
- export declare function optimizedDepInfoFromId(metadata: DepOptimizationMetadata, id: string): OptimizedDepInfo | undefined;
180
- export declare function optimizedDepInfoFromFile(metadata: DepOptimizationMetadata, file: string): OptimizedDepInfo | undefined;
181
- export declare function optimizedDepNeedsInterop(metadata: DepOptimizationMetadata, file: string, config: ResolvedConfig): Promise<boolean | undefined>;
@@ -1,4 +0,0 @@
1
- import type { ResolvedConfig, ViteDevServer } from '..';
2
- import type { DepsOptimizer } from '.';
3
- export declare function getDepsOptimizer(config: ResolvedConfig): DepsOptimizer | undefined;
4
- export declare function initDepsOptimizer(config: ResolvedConfig, server?: ViteDevServer): Promise<DepsOptimizer>;
@@ -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;