vite 3.0.0-alpha.3 → 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 (82) hide show
  1. package/dist/node/chunks/{dep-24157481.js → dep-17430d09.js} +0 -0
  2. package/dist/node/chunks/{dep-6f5ac69c.js → dep-52974b5a.js} +33902 -33579
  3. package/dist/node/chunks/{dep-b1fc04c1.js → dep-8bed6f50.js} +1 -1
  4. package/dist/node/chunks/{dep-5eede05c.js → dep-a4f17494.js} +1 -1
  5. package/dist/node/chunks/{dep-da8244f4.js → dep-b4474709.js} +100 -47
  6. package/dist/node/cli.js +7 -5
  7. package/dist/node/constants.js +1 -1
  8. package/dist/node/index.d.ts +117 -13
  9. package/dist/node/index.js +1 -1
  10. package/dist/node-cjs/publicUtils.cjs +0 -11
  11. package/package.json +11 -9
  12. package/types/es-module-lexer.d.ts +90 -0
  13. package/dist/node/build.d.ts +0 -178
  14. package/dist/node/certificate.d.ts +0 -2
  15. package/dist/node/cli.d.ts +0 -1
  16. package/dist/node/config.d.ts +0 -240
  17. package/dist/node/constants.d.ts +0 -35
  18. package/dist/node/env.d.ts +0 -3
  19. package/dist/node/http.d.ts +0 -88
  20. package/dist/node/logger.d.ts +0 -31
  21. package/dist/node/optimizer/esbuildDepPlugin.d.ts +0 -4
  22. package/dist/node/optimizer/index.d.ts +0 -154
  23. package/dist/node/optimizer/registerMissing.d.ts +0 -3
  24. package/dist/node/optimizer/scan.d.ts +0 -8
  25. package/dist/node/packages.d.ts +0 -27
  26. package/dist/node/plugin.d.ts +0 -129
  27. package/dist/node/plugins/asset.d.ts +0 -68
  28. package/dist/node/plugins/assetImportMetaUrl.d.ts +0 -13
  29. package/dist/node/plugins/clientInjections.d.ts +0 -7
  30. package/dist/node/plugins/css.d.ts +0 -86
  31. package/dist/node/plugins/dataUri.d.ts +0 -5
  32. package/dist/node/plugins/define.d.ts +0 -3
  33. package/dist/node/plugins/dynamicImportVars.d.ts +0 -9
  34. package/dist/node/plugins/ensureWatch.d.ts +0 -5
  35. package/dist/node/plugins/esbuild.d.ts +0 -15
  36. package/dist/node/plugins/html.d.ts +0 -120
  37. package/dist/node/plugins/importAnalysis.d.ts +0 -47
  38. package/dist/node/plugins/importAnalysisBuild.d.ts +0 -16
  39. package/dist/node/plugins/importMetaGlob.d.ts +0 -34
  40. package/dist/node/plugins/index.d.ts +0 -3
  41. package/dist/node/plugins/json.d.ts +0 -23
  42. package/dist/node/plugins/loadFallback.d.ts +0 -5
  43. package/dist/node/plugins/manifest.d.ts +0 -14
  44. package/dist/node/plugins/metadata.d.ts +0 -9
  45. package/dist/node/plugins/modulePreloadPolyfill.d.ts +0 -4
  46. package/dist/node/plugins/optimizedDeps.d.ts +0 -4
  47. package/dist/node/plugins/preAlias.d.ts +0 -5
  48. package/dist/node/plugins/reporter.d.ts +0 -3
  49. package/dist/node/plugins/resolve.d.ts +0 -39
  50. package/dist/node/plugins/splitVendorChunk.d.ts +0 -12
  51. package/dist/node/plugins/ssrRequireHook.d.ts +0 -12
  52. package/dist/node/plugins/terser.d.ts +0 -3
  53. package/dist/node/plugins/wasm.d.ts +0 -4
  54. package/dist/node/plugins/worker.d.ts +0 -9
  55. package/dist/node/plugins/workerImportMetaUrl.d.ts +0 -3
  56. package/dist/node/preview.d.ts +0 -33
  57. package/dist/node/publicUtils.d.ts +0 -11
  58. package/dist/node/server/hmr.d.ts +0 -39
  59. package/dist/node/server/index.d.ts +0 -198
  60. package/dist/node/server/middlewares/base.d.ts +0 -3
  61. package/dist/node/server/middlewares/compression.d.ts +0 -1
  62. package/dist/node/server/middlewares/error.d.ts +0 -8
  63. package/dist/node/server/middlewares/indexHtml.d.ts +0 -4
  64. package/dist/node/server/middlewares/proxy.d.ts +0 -20
  65. package/dist/node/server/middlewares/spaFallback.d.ts +0 -2
  66. package/dist/node/server/middlewares/static.d.ts +0 -6
  67. package/dist/node/server/middlewares/time.d.ts +0 -2
  68. package/dist/node/server/middlewares/transform.d.ts +0 -3
  69. package/dist/node/server/moduleGraph.d.ts +0 -55
  70. package/dist/node/server/openBrowser.d.ts +0 -15
  71. package/dist/node/server/pluginContainer.d.ts +0 -41
  72. package/dist/node/server/searchRoot.d.ts +0 -8
  73. package/dist/node/server/send.d.ts +0 -10
  74. package/dist/node/server/sourcemap.d.ts +0 -11
  75. package/dist/node/server/transformRequest.d.ts +0 -14
  76. package/dist/node/server/ws.d.ts +0 -55
  77. package/dist/node/ssr/ssrExternal.d.ts +0 -11
  78. package/dist/node/ssr/ssrManifestPlugin.d.ts +0 -3
  79. package/dist/node/ssr/ssrModuleLoader.d.ts +0 -7
  80. package/dist/node/ssr/ssrStacktrace.d.ts +0 -3
  81. package/dist/node/ssr/ssrTransform.d.ts +0 -14
  82. package/dist/node/utils.d.ts +0 -144
@@ -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,154 +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
- };
8
- export interface OptimizedDeps {
9
- metadata: DepOptimizationMetadata;
10
- scanProcessing?: Promise<void>;
11
- registerMissingImport: (id: string, resolved: string) => OptimizedDepInfo;
12
- }
13
- export interface DepOptimizationOptions {
14
- /**
15
- * By default, Vite will crawl your `index.html` to detect dependencies that
16
- * need to be pre-bundled. If `build.rollupOptions.input` is specified, Vite
17
- * will crawl those entry points instead.
18
- *
19
- * If neither of these fit your needs, you can specify custom entries using
20
- * this option - the value should be a fast-glob pattern or array of patterns
21
- * (https://github.com/mrmlnc/fast-glob#basic-syntax) that are relative from
22
- * vite project root. This will overwrite default entries inference.
23
- */
24
- entries?: string | string[];
25
- /**
26
- * Force optimize listed dependencies (must be resolvable import paths,
27
- * cannot be globs).
28
- */
29
- include?: string[];
30
- /**
31
- * Do not optimize these dependencies (must be resolvable import paths,
32
- * cannot be globs).
33
- */
34
- exclude?: string[];
35
- /**
36
- * Options to pass to esbuild during the dep scanning and optimization
37
- *
38
- * Certain options are omitted since changing them would not be compatible
39
- * with Vite's dep optimization.
40
- *
41
- * - `external` is also omitted, use Vite's `optimizeDeps.exclude` option
42
- * - `plugins` are merged with Vite's dep plugin
43
- *
44
- * https://esbuild.github.io/api
45
- */
46
- esbuildOptions?: Omit<EsbuildBuildOptions, 'bundle' | 'entryPoints' | 'external' | 'write' | 'watch' | 'outdir' | 'outfile' | 'outbase' | 'outExtension' | 'metafile'>;
47
- /**
48
- * List of file extensions that can be optimized. A corresponding esbuild
49
- * plugin must exist to handle the specific extension.
50
- *
51
- * By default, Vite can optimize `.mjs`, `.js`, and `.ts` files. This option
52
- * allows specifying additional extensions.
53
- *
54
- * @experimental
55
- */
56
- extensions?: string[];
57
- /**
58
- * Disables dependencies optimizations
59
- * @default false
60
- * @experimental
61
- */
62
- disabled?: boolean;
63
- }
64
- export interface DepOptimizationResult {
65
- metadata: DepOptimizationMetadata;
66
- /**
67
- * When doing a re-run, if there are newly discovered dependendencies
68
- * the page reload will be delayed until the next rerun so we need
69
- * to be able to discard the result
70
- */
71
- commit: () => Promise<void>;
72
- cancel: () => void;
73
- }
74
- export interface DepOptimizationProcessing {
75
- promise: Promise<void>;
76
- resolve: () => void;
77
- }
78
- export interface OptimizedDepInfo {
79
- id: string;
80
- file: string;
81
- src?: string;
82
- needsInterop?: boolean;
83
- browserHash?: string;
84
- fileHash?: string;
85
- /**
86
- * During optimization, ids can still be resolved to their final location
87
- * but the bundles may not yet be saved to disk
88
- */
89
- processing?: Promise<void>;
90
- }
91
- export interface DepOptimizationMetadata {
92
- /**
93
- * The main hash is determined by user config and dependency lockfiles.
94
- * This is checked on server startup to avoid unnecessary re-bundles.
95
- */
96
- hash: string;
97
- /**
98
- * The browser hash is determined by the main hash plus additional dependencies
99
- * discovered at runtime. This is used to invalidate browser requests to
100
- * optimized deps.
101
- */
102
- browserHash: string;
103
- /**
104
- * Metadata for each already optimized dependency
105
- */
106
- optimized: Record<string, OptimizedDepInfo>;
107
- /**
108
- * Metadata for non-entry optimized chunks and dynamic imports
109
- */
110
- chunks: Record<string, OptimizedDepInfo>;
111
- /**
112
- * Metadata for each newly discovered dependency after processing
113
- */
114
- discovered: Record<string, OptimizedDepInfo>;
115
- /**
116
- * OptimizedDepInfo list
117
- */
118
- depInfoList: OptimizedDepInfo[];
119
- }
120
- /**
121
- * Used by Vite CLI when running `vite optimize`
122
- */
123
- export declare function optimizeDeps(config: ResolvedConfig, force?: boolean | undefined, asCommand?: boolean): Promise<DepOptimizationMetadata>;
124
- export declare function createOptimizedDepsMetadata(config: ResolvedConfig, timestamp?: string): DepOptimizationMetadata;
125
- export declare function addOptimizedDepInfo(metadata: DepOptimizationMetadata, type: 'optimized' | 'discovered' | 'chunks', depInfo: OptimizedDepInfo): OptimizedDepInfo;
126
- /**
127
- * Creates the initial dep optimization metadata, loading it from the deps cache
128
- * if it exists and pre-bundling isn't forced
129
- */
130
- export declare function loadCachedDepOptimizationMetadata(config: ResolvedConfig, force?: boolean | undefined, asCommand?: boolean): DepOptimizationMetadata | undefined;
131
- /**
132
- * Initial optimizeDeps at server start. Perform a fast scan using esbuild to
133
- * find deps to pre-bundle and include user hard-coded dependencies
134
- */
135
- export declare function discoverProjectDependencies(config: ResolvedConfig, timestamp?: string): Promise<Record<string, OptimizedDepInfo>>;
136
- export declare function depsLogString(qualifiedIds: string[]): string;
137
- /**
138
- * Internally, Vite uses this function to prepare a optimizeDeps run. When Vite starts, we can get
139
- * the metadata and start the server without waiting for the optimizeDeps processing to be completed
140
- */
141
- export declare function runOptimizeDeps(config: ResolvedConfig, depsInfo: Record<string, OptimizedDepInfo>): Promise<DepOptimizationResult>;
142
- export declare function findKnownImports(config: ResolvedConfig): Promise<string[]>;
143
- export declare function newDepOptimizationProcessing(): DepOptimizationProcessing;
144
- export declare function depsFromOptimizedDepInfo(depsInfo: Record<string, OptimizedDepInfo>): {
145
- [k: string]: string;
146
- };
147
- export declare function getOptimizedDepPath(id: string, config: ResolvedConfig): string;
148
- export declare function getDepsCacheDir(config: ResolvedConfig): string;
149
- export declare function isOptimizedDepFile(id: string, config: ResolvedConfig): boolean;
150
- export declare function createIsOptimizedDepUrl(config: ResolvedConfig): (url: string) => boolean;
151
- export declare function getDepHash(config: ResolvedConfig): string;
152
- export declare function optimizedDepInfoFromId(metadata: DepOptimizationMetadata, id: string): OptimizedDepInfo | undefined;
153
- export declare function optimizedDepInfoFromFile(metadata: DepOptimizationMetadata, file: string): OptimizedDepInfo | undefined;
154
- export declare function optimizedDepNeedsInterop(metadata: DepOptimizationMetadata, file: string): 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;
@@ -1,129 +0,0 @@
1
- import type { CustomPluginOptions, LoadResult, PluginContext, ResolveIdResult, Plugin as RollupPlugin, TransformPluginContext, TransformResult } from 'rollup';
2
- import type { UserConfig } from './config';
3
- import type { ServerHook } from './server';
4
- import type { IndexHtmlTransform } from './plugins/html';
5
- import type { ModuleNode } from './server/moduleGraph';
6
- import type { HmrContext } from './server/hmr';
7
- import type { PreviewServerHook } from './preview';
8
- import type { ConfigEnv, ResolvedConfig } from './';
9
- /**
10
- * Vite plugins extends the Rollup plugin interface with a few extra
11
- * vite-specific options. A valid vite plugin is also a valid Rollup plugin.
12
- * On the contrary, a Rollup plugin may or may NOT be a valid vite universal
13
- * plugin, since some Rollup features do not make sense in an unbundled
14
- * dev server context. That said, as long as a rollup plugin doesn't have strong
15
- * coupling between its bundle phase and output phase hooks then it should
16
- * just work (that means, most of them).
17
- *
18
- * By default, the plugins are run during both serve and build. When a plugin
19
- * is applied during serve, it will only run **non output plugin hooks** (see
20
- * rollup type definition of {@link rollup#PluginHooks}). You can think of the
21
- * dev server as only running `const bundle = rollup.rollup()` but never calling
22
- * `bundle.generate()`.
23
- *
24
- * A plugin that expects to have different behavior depending on serve/build can
25
- * export a factory function that receives the command being run via options.
26
- *
27
- * If a plugin should be applied only for server or build, a function format
28
- * config file can be used to conditional determine the plugins to use.
29
- */
30
- export interface Plugin extends RollupPlugin {
31
- /**
32
- * Enforce plugin invocation tier similar to webpack loaders.
33
- *
34
- * Plugin invocation order:
35
- * - alias resolution
36
- * - `enforce: 'pre'` plugins
37
- * - vite core plugins
38
- * - normal plugins
39
- * - vite build plugins
40
- * - `enforce: 'post'` plugins
41
- * - vite build post plugins
42
- */
43
- enforce?: 'pre' | 'post';
44
- /**
45
- * Apply the plugin only for serve or build, or on certain conditions.
46
- */
47
- apply?: 'serve' | 'build' | ((config: UserConfig, env: ConfigEnv) => boolean);
48
- /**
49
- * Modify vite config before it's resolved. The hook can either mutate the
50
- * passed-in config directly, or return a partial config object that will be
51
- * deeply merged into existing config.
52
- *
53
- * Note: User plugins are resolved before running this hook so injecting other
54
- * plugins inside the `config` hook will have no effect.
55
- */
56
- config?: (config: UserConfig, env: ConfigEnv) => UserConfig | null | void | Promise<UserConfig | null | void>;
57
- /**
58
- * Use this hook to read and store the final resolved vite config.
59
- */
60
- configResolved?: (config: ResolvedConfig) => void | Promise<void>;
61
- /**
62
- * Configure the vite server. The hook receives the {@link ViteDevServer}
63
- * instance. This can also be used to store a reference to the server
64
- * for use in other hooks.
65
- *
66
- * The hooks will be called before internal middlewares are applied. A hook
67
- * can return a post hook that will be called after internal middlewares
68
- * are applied. Hook can be async functions and will be called in series.
69
- */
70
- configureServer?: ServerHook;
71
- /**
72
- * Configure the preview server. The hook receives the connect server and
73
- * its underlying http server.
74
- *
75
- * The hooks are called before other middlewares are applied. A hook can
76
- * return a post hook that will be called after other middlewares are
77
- * applied. Hooks can be async functions and will be called in series.
78
- */
79
- configurePreviewServer?: PreviewServerHook;
80
- /**
81
- * Transform index.html.
82
- * The hook receives the following arguments:
83
- *
84
- * - html: string
85
- * - ctx?: vite.ServerContext (only present during serve)
86
- * - bundle?: rollup.OutputBundle (only present during build)
87
- *
88
- * It can either return a transformed string, or a list of html tag
89
- * descriptors that will be injected into the <head> or <body>.
90
- *
91
- * By default the transform is applied **after** vite's internal html
92
- * transform. If you need to apply the transform before vite, use an object:
93
- * `{ enforce: 'pre', transform: hook }`
94
- */
95
- transformIndexHtml?: IndexHtmlTransform;
96
- /**
97
- * Perform custom handling of HMR updates.
98
- * The handler receives a context containing changed filename, timestamp, a
99
- * list of modules affected by the file change, and the dev server instance.
100
- *
101
- * - The hook can return a filtered list of modules to narrow down the update.
102
- * e.g. for a Vue SFC, we can narrow down the part to update by comparing
103
- * the descriptors.
104
- *
105
- * - The hook can also return an empty array and then perform custom updates
106
- * by sending a custom hmr payload via server.ws.send().
107
- *
108
- * - If the hook doesn't return a value, the hmr update will be performed as
109
- * normal.
110
- */
111
- handleHotUpdate?(ctx: HmrContext): Array<ModuleNode> | void | Promise<Array<ModuleNode> | void>;
112
- /**
113
- * extend hooks with ssr flag
114
- */
115
- resolveId?(this: PluginContext, source: string, importer: string | undefined, options: {
116
- custom?: CustomPluginOptions;
117
- ssr?: boolean;
118
- /**
119
- * @internal
120
- */
121
- scan?: boolean;
122
- }): Promise<ResolveIdResult> | ResolveIdResult;
123
- load?(this: PluginContext, id: string, options?: {
124
- ssr?: boolean;
125
- }): Promise<LoadResult> | LoadResult;
126
- transform?(this: TransformPluginContext, code: string, id: string, options?: {
127
- ssr?: boolean;
128
- }): Promise<TransformResult> | TransformResult;
129
- }
@@ -1,68 +0,0 @@
1
- /// <reference types="node" />
2
- import type { OutputOptions, PluginContext } from 'rollup';
3
- import type { Plugin } from '../plugin';
4
- import type { ResolvedConfig } from '../config';
5
- export declare const assetUrlRE: RegExp;
6
- /**
7
- * Also supports loading plain strings with import text from './foo.txt?raw'
8
- */
9
- export declare function assetPlugin(config: ResolvedConfig): Plugin;
10
- export declare function checkPublicFile(url: string, { publicDir }: ResolvedConfig): string | undefined;
11
- export declare function fileToUrl(id: string, config: ResolvedConfig, ctx: PluginContext): Promise<string>;
12
- export declare function getAssetFilename(hash: string, config: ResolvedConfig): string | undefined;
13
- /**
14
- * converts the source filepath of the asset to the output filename based on the assetFileNames option. \
15
- * this function imitates the behavior of rollup.js. \
16
- * https://rollupjs.org/guide/en/#outputassetfilenames
17
- *
18
- * @example
19
- * ```ts
20
- * const content = Buffer.from('text');
21
- * const fileName = assetFileNamesToFileName(
22
- * 'assets/[name].[hash][extname]',
23
- * '/path/to/file.txt',
24
- * getHash(content),
25
- * content
26
- * )
27
- * // fileName: 'assets/file.982d9e3e.txt'
28
- * ```
29
- *
30
- * @param assetFileNames filename pattern. e.g. `'assets/[name].[hash][extname]'`
31
- * @param file filepath of the asset
32
- * @param contentHash hash of the asset. used for `'[hash]'` placeholder
33
- * @param content content of the asset. passed to `assetFileNames` if `assetFileNames` is a function
34
- * @returns output filename
35
- */
36
- export declare function assetFileNamesToFileName(assetFileNames: Exclude<OutputOptions['assetFileNames'], undefined>, file: string, contentHash: string, content: string | Buffer): string;
37
- export declare const publicAssetUrlCache: WeakMap<Readonly<Omit<import("../config").UserConfig, "assetsInclude" | "plugins" | "optimizeDeps" | "worker"> & {
38
- configFile: string | undefined;
39
- configFileDependencies: string[];
40
- inlineConfig: import("../config").InlineConfig;
41
- root: string;
42
- base: string;
43
- publicDir: string;
44
- cacheDir: string;
45
- command: "build" | "serve";
46
- mode: string;
47
- isWorker: boolean;
48
- mainConfig: Readonly<Omit<import("../config").UserConfig, "assetsInclude" | "plugins" | "optimizeDeps" | "worker"> & any> | null;
49
- isProduction: boolean;
50
- env: Record<string, any>;
51
- resolve: import("./resolve").ResolveOptions & {
52
- alias: import("types/alias").Alias[];
53
- };
54
- plugins: readonly Plugin[];
55
- server: import("..").ResolvedServerOptions;
56
- build: Required<import("..").BuildOptions>;
57
- preview: import("..").ResolvedPreviewOptions;
58
- assetsInclude: (file: string) => boolean;
59
- logger: import("..").Logger;
60
- createResolver: (options?: Partial<import("./resolve").InternalResolveOptions> | undefined) => import("../config").ResolveFn;
61
- optimizeDeps: import("..").DepOptimizationOptions;
62
- packageCache: import("..").PackageCache;
63
- worker: import("../config").ResolveWorkerOptions;
64
- spa: boolean;
65
- }>, Map<string, string>>;
66
- export declare const publicAssetUrlRE: RegExp;
67
- export declare function publicFileToBuiltUrl(url: string, config: ResolvedConfig): string;
68
- export declare function urlToBuiltUrl(url: string, importer: string, config: ResolvedConfig, pluginContext: PluginContext): Promise<string>;
@@ -1,13 +0,0 @@
1
- import type { Plugin } from '../plugin';
2
- import type { ResolvedConfig } from '../config';
3
- /**
4
- * Convert `new URL('./foo.png', import.meta.url)` to its resolved built URL
5
- *
6
- * Supports template string with dynamic segments:
7
- * ```
8
- * new URL(`./dir/${name}.png`, import.meta.url)
9
- * // transformed to
10
- * import.meta.glob('./dir/**.png', { eager: true, import: 'default' })[`./dir/${name}.png`]
11
- * ```
12
- */
13
- export declare function assetImportMetaUrlPlugin(config: ResolvedConfig): Plugin;
@@ -1,7 +0,0 @@
1
- import type { Plugin } from '../plugin';
2
- import type { ResolvedConfig } from '../config';
3
- /**
4
- * some values used by the client needs to be dynamically injected by the server
5
- * @server-only
6
- */
7
- export declare function clientInjectionsPlugin(config: ResolvedConfig): Plugin;
@@ -1,86 +0,0 @@
1
- import type { ExistingRawSourceMap, RenderedChunk, RollupError } from 'rollup';
2
- import type * as PostCSS from 'postcss';
3
- import type { Alias } from 'types/alias';
4
- import type { ResolveFn } from '../';
5
- import type { ResolvedConfig } from '../config';
6
- import type { Plugin } from '../plugin';
7
- import type { Logger } from '../logger';
8
- export interface CSSOptions {
9
- /**
10
- * https://github.com/css-modules/postcss-modules
11
- */
12
- modules?: CSSModulesOptions | false;
13
- preprocessorOptions?: Record<string, any>;
14
- postcss?: string | (PostCSS.ProcessOptions & {
15
- plugins?: PostCSS.Plugin[];
16
- });
17
- /**
18
- * Enables css sourcemaps during dev
19
- * @default false
20
- * @experimental
21
- */
22
- devSourcemap?: boolean;
23
- }
24
- export interface CSSModulesOptions {
25
- getJSON?: (cssFileName: string, json: Record<string, string>, outputFileName: string) => void;
26
- scopeBehaviour?: 'global' | 'local';
27
- globalModulePaths?: RegExp[];
28
- generateScopedName?: string | ((name: string, filename: string, css: string) => string);
29
- hashPrefix?: string;
30
- /**
31
- * default: null
32
- */
33
- localsConvention?: 'camelCase' | 'camelCaseOnly' | 'dashes' | 'dashesOnly' | null;
34
- }
35
- export declare const isCSSRequest: (request: string) => boolean;
36
- export declare const isDirectCSSRequest: (request: string) => boolean;
37
- export declare const isDirectRequest: (request: string) => boolean;
38
- export declare const removedPureCssFilesCache: WeakMap<Readonly<Omit<import("../config").UserConfig, "assetsInclude" | "plugins" | "optimizeDeps" | "worker"> & {
39
- configFile: string | undefined;
40
- configFileDependencies: string[];
41
- inlineConfig: import("../config").InlineConfig;
42
- root: string;
43
- base: string;
44
- publicDir: string;
45
- cacheDir: string;
46
- command: "build" | "serve";
47
- mode: string;
48
- isWorker: boolean;
49
- mainConfig: Readonly<Omit<import("../config").UserConfig, "assetsInclude" | "plugins" | "optimizeDeps" | "worker"> & any> | null;
50
- isProduction: boolean;
51
- env: Record<string, any>;
52
- resolve: import("./resolve").ResolveOptions & {
53
- alias: Alias[];
54
- };
55
- plugins: readonly Plugin[];
56
- server: import("../server").ResolvedServerOptions;
57
- build: Required<import("../build").BuildOptions>;
58
- preview: import("../preview").ResolvedPreviewOptions;
59
- assetsInclude: (file: string) => boolean;
60
- logger: Logger;
61
- createResolver: (options?: Partial<import("./resolve").InternalResolveOptions> | undefined) => ResolveFn;
62
- optimizeDeps: import("../optimizer").DepOptimizationOptions;
63
- packageCache: import("../packages").PackageCache;
64
- worker: import("../config").ResolveWorkerOptions;
65
- spa: boolean;
66
- }>, Map<string, RenderedChunk>>;
67
- /**
68
- * Plugin applied before user plugins
69
- */
70
- export declare function cssPlugin(config: ResolvedConfig): Plugin;
71
- /**
72
- * Plugin applied after user plugins
73
- */
74
- export declare function cssPostPlugin(config: ResolvedConfig): Plugin;
75
- export declare function formatPostcssSourceMap(rawMap: ExistingRawSourceMap, file: string): Promise<ExistingRawSourceMap>;
76
- export declare const cssUrlRE: RegExp;
77
- export declare const cssDataUriRE: RegExp;
78
- export declare const importCssRE: RegExp;
79
- export declare function hoistAtRules(css: string): Promise<string>;
80
- export interface StylePreprocessorResults {
81
- code: string;
82
- map?: ExistingRawSourceMap | undefined;
83
- additionalMap?: ExistingRawSourceMap | undefined;
84
- errors: RollupError[];
85
- deps: string[];
86
- }
@@ -1,5 +0,0 @@
1
- import type { Plugin } from '../plugin';
2
- /**
3
- * Build only, since importing from a data URI works natively.
4
- */
5
- export declare function dataURIPlugin(): Plugin;
@@ -1,3 +0,0 @@
1
- import type { ResolvedConfig } from '../config';
2
- import type { Plugin } from '../plugin';
3
- export declare function definePlugin(config: ResolvedConfig): Plugin;
@@ -1,9 +0,0 @@
1
- import type { Plugin } from '../plugin';
2
- import type { ResolvedConfig } from '../config';
3
- export declare const dynamicImportHelperId = "/@vite/dynamic-import-helper";
4
- export declare function transformDynamicImport(importSource: string, importer: string, resolve: (url: string, importer?: string) => Promise<string | undefined> | string | undefined): Promise<{
5
- glob: string;
6
- pattern: string;
7
- rawPattern: string;
8
- } | null>;
9
- export declare function dynamicImportVarsPlugin(config: ResolvedConfig): Plugin;
@@ -1,5 +0,0 @@
1
- import type { Plugin } from '../plugin';
2
- /**
3
- * plugin to ensure rollup can watch correctly.
4
- */
5
- export declare function ensureWatchPlugin(): Plugin;