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,39 +0,0 @@
1
- import type { PartialResolvedId } from 'rollup';
2
- import type { Plugin } from '../plugin';
3
- import type { SSROptions, ViteDevServer } from '..';
4
- import type { PackageCache, PackageData } from '../packages';
5
- export declare const browserExternalId = "__vite-browser-external";
6
- export interface ResolveOptions {
7
- mainFields?: string[];
8
- conditions?: string[];
9
- extensions?: string[];
10
- dedupe?: string[];
11
- preserveSymlinks?: boolean;
12
- }
13
- export interface InternalResolveOptions extends ResolveOptions {
14
- root: string;
15
- isBuild: boolean;
16
- isProduction: boolean;
17
- ssrConfig?: SSROptions;
18
- packageCache?: PackageCache;
19
- /**
20
- * src code mode also attempts the following:
21
- * - resolving /xxx as URLs
22
- * - resolving bare imports from optimized deps
23
- */
24
- asSrc?: boolean;
25
- tryIndex?: boolean;
26
- tryPrefix?: string;
27
- skipPackageJson?: boolean;
28
- preferRelative?: boolean;
29
- preserveSymlinks?: boolean;
30
- isRequire?: boolean;
31
- isFromTsImporter?: boolean;
32
- tryEsmOnly?: boolean;
33
- scan?: boolean;
34
- }
35
- export declare function resolvePlugin(baseOptions: InternalResolveOptions): Plugin;
36
- export declare const idToPkgMap: Map<string, PackageData>;
37
- export declare function tryNodeResolve(id: string, importer: string | null | undefined, options: InternalResolveOptions, targetWeb: boolean, server?: ViteDevServer, ssr?: boolean): PartialResolvedId | undefined;
38
- export declare function tryOptimizedResolve(id: string, server: ViteDevServer, importer?: string): Promise<string | undefined>;
39
- export declare function resolvePackageEntry(id: string, { dir, data, setResolvedCache, getResolvedCache }: PackageData, targetWeb: boolean, options: InternalResolveOptions): string | undefined;
@@ -1,12 +0,0 @@
1
- import type { GetManualChunk } from 'rollup';
2
- import type { Plugin } from '../plugin';
3
- export declare const isCSSRequest: (request: string) => boolean;
4
- export declare class SplitVendorChunkCache {
5
- cache: Map<string, boolean>;
6
- constructor();
7
- reset(): void;
8
- }
9
- export declare function splitVendorChunk(options?: {
10
- cache?: SplitVendorChunkCache;
11
- }): GetManualChunk;
12
- export declare function splitVendorChunkPlugin(): Plugin;
@@ -1,12 +0,0 @@
1
- /// <reference types="node" />
2
- import type { ResolvedConfig } from '..';
3
- import type { Plugin } from '../plugin';
4
- /**
5
- * This plugin hooks into Node's module resolution algorithm at runtime,
6
- * so that SSR builds can benefit from `resolve.dedupe` like they do
7
- * in development.
8
- */
9
- export declare function ssrRequireHookPlugin(config: ResolvedConfig): Plugin | null;
10
- declare type NodeResolveFilename = (request: string, parent: NodeModule, isMain: boolean, options?: Record<string, any>) => string;
11
- export declare function hookNodeResolve(getResolver: (resolveFilename: NodeResolveFilename) => NodeResolveFilename): () => void;
12
- export {};
@@ -1,3 +0,0 @@
1
- import type { Plugin } from '../plugin';
2
- import type { ResolvedConfig } from '..';
3
- export declare function terserPlugin(config: ResolvedConfig): Plugin;
@@ -1,4 +0,0 @@
1
- import type { ResolvedConfig } from '../config';
2
- import type { Plugin } from '../plugin';
3
- export declare const wasmHelperPlugin: (config: ResolvedConfig) => Plugin;
4
- export declare const wasmFallbackPlugin: () => Plugin;
@@ -1,9 +0,0 @@
1
- import type { OutputChunk } from 'rollup';
2
- import type { ResolvedConfig } from '../config';
3
- import type { Plugin } from '../plugin';
4
- export declare type WorkerType = 'classic' | 'module' | 'ignore';
5
- export declare const WORKER_FILE_ID = "worker_file";
6
- export declare function bundleWorkerEntry(config: ResolvedConfig, id: string, query: Record<string, string> | null): Promise<OutputChunk>;
7
- export declare const workerAssetUrlRE: RegExp;
8
- export declare function workerFileToUrl(config: ResolvedConfig, id: string, query: Record<string, string> | null): Promise<string>;
9
- export declare function webWorkerPlugin(config: ResolvedConfig): Plugin;
@@ -1,3 +0,0 @@
1
- import type { ResolvedConfig } from '../config';
2
- import type { Plugin } from '../plugin';
3
- export declare function workerImportMetaUrlPlugin(config: ResolvedConfig): Plugin;
@@ -1,33 +0,0 @@
1
- /// <reference types="node" />
2
- import type * as http from 'http';
3
- import type { Connect } from 'types/connect';
4
- import type { ResolvedServerOptions } from './server';
5
- import type { CommonServerOptions } from './http';
6
- import type { InlineConfig, ResolvedConfig } from '.';
7
- export interface PreviewOptions extends CommonServerOptions {
8
- }
9
- export interface ResolvedPreviewOptions extends PreviewOptions {
10
- }
11
- export declare function resolvePreviewOptions(preview: PreviewOptions | undefined, server: ResolvedServerOptions): ResolvedPreviewOptions;
12
- export interface PreviewServer {
13
- /**
14
- * The resolved vite config object
15
- */
16
- config: ResolvedConfig;
17
- /**
18
- * native Node http server instance
19
- */
20
- httpServer: http.Server;
21
- /**
22
- * Print server urls
23
- */
24
- printUrls: () => void;
25
- }
26
- export declare type PreviewServerHook = (server: {
27
- middlewares: Connect.Server;
28
- httpServer: http.Server;
29
- }) => (() => void) | void | Promise<(() => void) | void>;
30
- /**
31
- * Starts the Vite server in preview mode, to simulate a production deployment
32
- */
33
- export declare function preview(inlineConfig?: InlineConfig): Promise<PreviewServer>;
@@ -1,11 +0,0 @@
1
- /**
2
- * Exported sync utils should go here.
3
- * This file will be bundled to ESM and CJS and redirected by ../index.cjs
4
- * Please control the side-effects by checking the ./dist/node-cjs/publicUtils.cjs bundle
5
- */
6
- export { splitVendorChunkPlugin, splitVendorChunk } from './plugins/splitVendorChunk';
7
- export { normalizePath, mergeConfig, mergeAlias } from './utils';
8
- export { send } from './server/send';
9
- export { createLogger } from './logger';
10
- export { searchForWorkspaceRoot } from './server/searchRoot';
11
- export { loadEnv, resolveEnvPrefix } from './env';
@@ -1,39 +0,0 @@
1
- /// <reference types="node" />
2
- import type { Server } from 'http';
3
- import type { ViteDevServer } from '..';
4
- import type { ModuleNode } from './moduleGraph';
5
- export declare const debugHmr: (...args: any[]) => any;
6
- export interface HmrOptions {
7
- protocol?: string;
8
- host?: string;
9
- port?: number;
10
- clientPort?: number;
11
- path?: string;
12
- timeout?: number;
13
- overlay?: boolean;
14
- server?: Server;
15
- }
16
- export interface HmrContext {
17
- file: string;
18
- timestamp: number;
19
- modules: Array<ModuleNode>;
20
- read: () => string | Promise<string>;
21
- server: ViteDevServer;
22
- }
23
- export declare function getShortName(file: string, root: string): string;
24
- export declare function handleHMRUpdate(file: string, server: ViteDevServer): Promise<any>;
25
- export declare function updateModules(file: string, modules: ModuleNode[], timestamp: number, { config, ws }: ViteDevServer): void;
26
- export declare function handleFileAddUnlink(file: string, server: ViteDevServer): Promise<void>;
27
- export declare function handlePrunedModules(mods: Set<ModuleNode>, { ws }: ViteDevServer): void;
28
- /**
29
- * Lex import.meta.hot.accept() for accepted deps.
30
- * Since hot.accept() can only accept string literals or array of string
31
- * literals, we don't really need a heavy @babel/parse call on the entire source.
32
- *
33
- * @returns selfAccepts
34
- */
35
- export declare function lexAcceptedHmrDeps(code: string, start: number, urls: Set<{
36
- url: string;
37
- start: number;
38
- end: number;
39
- }>): boolean;
@@ -1,198 +0,0 @@
1
- /// <reference types="node" />
2
- import type * as http from 'http';
3
- import type { FSWatcher, WatchOptions } from 'types/chokidar';
4
- import type { Connect } from 'types/connect';
5
- import type { SourceMap } from 'rollup';
6
- import type { CommonServerOptions } from '../http';
7
- import type { InlineConfig, ResolvedConfig } from '../config';
8
- import type { OptimizedDeps } from '../optimizer';
9
- import type { Logger } from '../logger';
10
- import type { PluginContainer } from './pluginContainer';
11
- import type { WebSocketServer } from './ws';
12
- import { ModuleGraph } from './moduleGraph';
13
- import type { HmrOptions } from './hmr';
14
- import type { TransformOptions, TransformResult } from './transformRequest';
15
- export { searchForWorkspaceRoot } from './searchRoot';
16
- export interface ServerOptions extends CommonServerOptions {
17
- /**
18
- * Force dep pre-optimization regardless of whether deps have changed.
19
- */
20
- force?: boolean;
21
- /**
22
- * Configure HMR-specific options (port, host, path & protocol)
23
- */
24
- hmr?: HmrOptions | boolean;
25
- /**
26
- * chokidar watch options
27
- * https://github.com/paulmillr/chokidar#api
28
- */
29
- watch?: WatchOptions;
30
- /**
31
- * Create Vite dev server to be used as a middleware in an existing server
32
- */
33
- middlewareMode?: boolean | 'html' | 'ssr';
34
- /**
35
- * Prepend this folder to http requests, for use when proxying vite as a subfolder
36
- * Should start and end with the `/` character
37
- */
38
- base?: string;
39
- /**
40
- * Options for files served via '/\@fs/'.
41
- */
42
- fs?: FileSystemServeOptions;
43
- /**
44
- * Origin for the generated asset URLs.
45
- *
46
- * @example `http://127.0.0.1:8080`
47
- */
48
- origin?: string;
49
- /**
50
- * Pre-transform known direct imports
51
- * @default true
52
- */
53
- preTransformRequests?: boolean;
54
- }
55
- export interface ResolvedServerOptions extends ServerOptions {
56
- fs: Required<FileSystemServeOptions>;
57
- }
58
- export interface FileSystemServeOptions {
59
- /**
60
- * Strictly restrict file accessing outside of allowing paths.
61
- *
62
- * Set to `false` to disable the warning
63
- *
64
- * @default true
65
- */
66
- strict?: boolean;
67
- /**
68
- * Restrict accessing files outside the allowed directories.
69
- *
70
- * Accepts absolute path or a path relative to project root.
71
- * Will try to search up for workspace root by default.
72
- */
73
- allow?: string[];
74
- /**
75
- * Restrict accessing files that matches the patterns.
76
- *
77
- * This will have higher priority than `allow`.
78
- * Glob patterns are supported.
79
- *
80
- * @default ['.env', '.env.*', '*.crt', '*.pem']
81
- */
82
- deny?: string[];
83
- }
84
- export declare type ServerHook = (server: ViteDevServer) => (() => void) | void | Promise<(() => void) | void>;
85
- export interface ViteDevServer {
86
- /**
87
- * The resolved vite config object
88
- */
89
- config: ResolvedConfig;
90
- /**
91
- * A connect app instance.
92
- * - Can be used to attach custom middlewares to the dev server.
93
- * - Can also be used as the handler function of a custom http server
94
- * or as a middleware in any connect-style Node.js frameworks
95
- *
96
- * https://github.com/senchalabs/connect#use-middleware
97
- */
98
- middlewares: Connect.Server;
99
- /**
100
- * native Node http server instance
101
- * will be null in middleware mode
102
- */
103
- httpServer: http.Server | null;
104
- /**
105
- * chokidar watcher instance
106
- * https://github.com/paulmillr/chokidar#api
107
- */
108
- watcher: FSWatcher;
109
- /**
110
- * web socket server with `send(payload)` method
111
- */
112
- ws: WebSocketServer;
113
- /**
114
- * Rollup plugin container that can run plugin hooks on a given file
115
- */
116
- pluginContainer: PluginContainer;
117
- /**
118
- * Module graph that tracks the import relationships, url to file mapping
119
- * and hmr state.
120
- */
121
- moduleGraph: ModuleGraph;
122
- /**
123
- * Programmatically resolve, load and transform a URL and get the result
124
- * without going through the http request pipeline.
125
- */
126
- transformRequest(url: string, options?: TransformOptions): Promise<TransformResult | null>;
127
- /**
128
- * Apply vite built-in HTML transforms and any plugin HTML transforms.
129
- */
130
- transformIndexHtml(url: string, html: string, originalUrl?: string): Promise<string>;
131
- /**
132
- * Transform module code into SSR format.
133
- */
134
- ssrTransform(code: string, inMap: SourceMap | null, url: string): Promise<TransformResult | null>;
135
- /**
136
- * Load a given URL as an instantiated module for SSR.
137
- */
138
- ssrLoadModule(url: string, opts?: {
139
- fixStacktrace?: boolean;
140
- }): Promise<Record<string, any>>;
141
- /**
142
- * Returns a fixed version of the given stack
143
- */
144
- ssrRewriteStacktrace(stack: string): string;
145
- /**
146
- * Mutates the given SSR error by rewriting the stacktrace
147
- */
148
- ssrFixStacktrace(e: Error): void;
149
- /**
150
- * Start the server.
151
- */
152
- listen(port?: number, isRestart?: boolean): Promise<ViteDevServer>;
153
- /**
154
- * Stop the server.
155
- */
156
- close(): Promise<void>;
157
- /**
158
- * Print server urls
159
- */
160
- printUrls(): void;
161
- /**
162
- * Restart the server.
163
- *
164
- * @param forceOptimize - force the optimizer to re-bundle, same as --force cli flag
165
- */
166
- restart(forceOptimize?: boolean): Promise<void>;
167
- /**
168
- * @internal
169
- */
170
- _optimizedDeps: OptimizedDeps | null;
171
- /**
172
- * @internal
173
- */
174
- _importGlobMap: Map<string, string[][]>;
175
- /**
176
- * Deps that are externalized
177
- * @internal
178
- */
179
- _ssrExternals: string[] | null;
180
- /**
181
- * @internal
182
- */
183
- _restartPromise: Promise<void> | null;
184
- /**
185
- * @internal
186
- */
187
- _forceOptimizeOnRestart: boolean;
188
- /**
189
- * @internal
190
- */
191
- _pendingRequests: Map<string, {
192
- request: Promise<TransformResult | null>;
193
- timestamp: number;
194
- abort: () => void;
195
- }>;
196
- }
197
- export declare function createServer(inlineConfig?: InlineConfig): Promise<ViteDevServer>;
198
- export declare function resolveServerOptions(root: string, raw: ServerOptions | undefined, logger: Logger): ResolvedServerOptions;
@@ -1,3 +0,0 @@
1
- import type { Connect } from 'types/connect';
2
- import type { ViteDevServer } from '..';
3
- export declare function baseMiddleware({ config }: ViteDevServer): Connect.NextHandleFunction;
@@ -1 +0,0 @@
1
- export default function compression(): (req: any, res: any, next?: () => void) => void;
@@ -1,8 +0,0 @@
1
- import type { RollupError } from 'rollup';
2
- import type { Connect } from 'types/connect';
3
- import type { ErrorPayload } from 'types/hmrPayload';
4
- import type { ViteDevServer } from '../..';
5
- export declare function prepareError(err: Error | RollupError): ErrorPayload['err'];
6
- export declare function buildErrorMessage(err: RollupError, args?: string[], includeStack?: boolean): string;
7
- export declare function logError(server: ViteDevServer, err: RollupError): void;
8
- export declare function errorMiddleware(server: ViteDevServer, allowNext?: boolean): Connect.ErrorHandleFunction;
@@ -1,4 +0,0 @@
1
- import type { Connect } from 'types/connect';
2
- import type { ViteDevServer } from '../..';
3
- export declare function createDevHtmlTransformFn(server: ViteDevServer): (url: string, html: string, originalUrl: string) => Promise<string>;
4
- export declare function indexHtmlMiddleware(server: ViteDevServer): Connect.NextHandleFunction;
@@ -1,20 +0,0 @@
1
- /// <reference types="node" />
2
- import type * as http from 'http';
3
- import type { Connect } from 'types/connect';
4
- import type { HttpProxy } from 'types/http-proxy';
5
- import type { CommonServerOptions, ResolvedConfig } from '../..';
6
- export interface ProxyOptions extends HttpProxy.ServerOptions {
7
- /**
8
- * rewrite path
9
- */
10
- rewrite?: (path: string) => string;
11
- /**
12
- * configure the proxy server (e.g. listen to events)
13
- */
14
- configure?: (proxy: HttpProxy.Server, options: ProxyOptions) => void;
15
- /**
16
- * webpack-dev-server style bypass function
17
- */
18
- bypass?: (req: http.IncomingMessage, res: http.ServerResponse, options: ProxyOptions) => void | null | undefined | false | string;
19
- }
20
- export declare function proxyMiddleware(httpServer: http.Server | null, options: NonNullable<CommonServerOptions['proxy']>, config: ResolvedConfig): Connect.NextHandleFunction;
@@ -1,2 +0,0 @@
1
- import type { Connect } from 'types/connect';
2
- export declare function spaFallbackMiddleware(root: string): Connect.NextHandleFunction;
@@ -1,6 +0,0 @@
1
- import type { Connect } from 'types/connect';
2
- import type { ViteDevServer } from '../..';
3
- export declare function servePublicMiddleware(dir: string): Connect.NextHandleFunction;
4
- export declare function serveStaticMiddleware(dir: string, server: ViteDevServer): Connect.NextHandleFunction;
5
- export declare function serveRawFsMiddleware(server: ViteDevServer): Connect.NextHandleFunction;
6
- export declare function isFileServingAllowed(url: string, server: ViteDevServer): boolean;
@@ -1,2 +0,0 @@
1
- import type { Connect } from 'types/connect';
2
- export declare function timeMiddleware(root: string): Connect.NextHandleFunction;
@@ -1,3 +0,0 @@
1
- import type { Connect } from 'types/connect';
2
- import type { ViteDevServer } from '..';
3
- export declare function transformMiddleware(server: ViteDevServer): Connect.NextHandleFunction;
@@ -1,55 +0,0 @@
1
- import type { ModuleInfo, PartialResolvedId } from 'rollup';
2
- import type { TransformResult } from './transformRequest';
3
- export declare class ModuleNode {
4
- /**
5
- * Public served url path, starts with /
6
- */
7
- url: string;
8
- /**
9
- * Resolved file system path + query
10
- */
11
- id: string | null;
12
- file: string | null;
13
- type: 'js' | 'css';
14
- info?: ModuleInfo;
15
- meta?: Record<string, any>;
16
- importers: Set<ModuleNode>;
17
- importedModules: Set<ModuleNode>;
18
- acceptedHmrDeps: Set<ModuleNode>;
19
- isSelfAccepting?: boolean;
20
- transformResult: TransformResult | null;
21
- ssrTransformResult: TransformResult | null;
22
- ssrModule: Record<string, any> | null;
23
- ssrError: Error | null;
24
- lastHMRTimestamp: number;
25
- lastInvalidationTimestamp: number;
26
- constructor(url: string);
27
- }
28
- export declare type ResolvedUrl = [
29
- url: string,
30
- resolvedId: string,
31
- meta: object | null | undefined
32
- ];
33
- export declare class ModuleGraph {
34
- private resolveId;
35
- urlToModuleMap: Map<string, ModuleNode>;
36
- idToModuleMap: Map<string, ModuleNode>;
37
- fileToModulesMap: Map<string, Set<ModuleNode>>;
38
- safeModulesPath: Set<string>;
39
- constructor(resolveId: (url: string, ssr: boolean) => Promise<PartialResolvedId | null>);
40
- getModuleByUrl(rawUrl: string, ssr?: boolean): Promise<ModuleNode | undefined>;
41
- getModuleById(id: string): ModuleNode | undefined;
42
- getModulesByFile(file: string): Set<ModuleNode> | undefined;
43
- onFileChange(file: string): void;
44
- invalidateModule(mod: ModuleNode, seen?: Set<ModuleNode>, timestamp?: number): void;
45
- invalidateAll(): void;
46
- /**
47
- * Update the module graph based on a module's updated imports information
48
- * If there are dependencies that no longer have any importers, they are
49
- * returned as a Set.
50
- */
51
- updateModuleInfo(mod: ModuleNode, importedModules: Set<string | ModuleNode>, acceptedModules: Set<string | ModuleNode>, isSelfAccepting: boolean, ssr?: boolean): Promise<Set<ModuleNode> | undefined>;
52
- ensureEntryFromUrl(rawUrl: string, ssr?: boolean): Promise<ModuleNode>;
53
- createFileOnlyEntry(file: string): ModuleNode;
54
- resolveUrl(url: string, ssr?: boolean): Promise<ResolvedUrl>;
55
- }
@@ -1,15 +0,0 @@
1
- /**
2
- * The following is modified based on source found in
3
- * https://github.com/facebook/create-react-app
4
- *
5
- * MIT Licensed
6
- * Copyright (c) 2015-present, Facebook, Inc.
7
- * https://github.com/facebook/create-react-app/blob/master/LICENSE
8
- *
9
- */
10
- import type { Logger } from '../logger';
11
- /**
12
- * Reads the BROWSER environment variable and decides what to do with it.
13
- * Returns true if it opened a browser or ran a node.js script, otherwise false.
14
- */
15
- export declare function openBrowser(url: string, opt: string | true, logger: Logger): boolean;
@@ -1,41 +0,0 @@
1
- /**
2
- * This file is refactored into TypeScript based on
3
- * https://github.com/preactjs/wmr/blob/main/packages/wmr/src/lib/rollup-plugin-container.js
4
- */
5
- import type { InputOptions, LoadResult, ModuleInfo, OutputOptions, PartialResolvedId, SourceDescription } from 'rollup';
6
- import * as acorn from 'acorn';
7
- import type { FSWatcher } from 'chokidar';
8
- import type { Plugin } from '../plugin';
9
- import type { ResolvedConfig } from '../config';
10
- import type { ModuleGraph } from './moduleGraph';
11
- export interface PluginContainerOptions {
12
- cwd?: string;
13
- output?: OutputOptions;
14
- modules?: Map<string, {
15
- info: ModuleInfo;
16
- }>;
17
- writeFile?: (name: string, source: string | Uint8Array) => void;
18
- }
19
- export interface PluginContainer {
20
- options: InputOptions;
21
- getModuleInfo(id: string): ModuleInfo | null;
22
- buildStart(options: InputOptions): Promise<void>;
23
- resolveId(id: string, importer?: string, options?: {
24
- skip?: Set<Plugin>;
25
- ssr?: boolean;
26
- /**
27
- * @internal
28
- */
29
- scan?: boolean;
30
- }): Promise<PartialResolvedId | null>;
31
- transform(code: string, id: string, options?: {
32
- inMap?: SourceDescription['map'];
33
- ssr?: boolean;
34
- }): Promise<SourceDescription | null>;
35
- load(id: string, options?: {
36
- ssr?: boolean;
37
- }): Promise<LoadResult | null>;
38
- close(): Promise<void>;
39
- }
40
- export declare let parser: typeof acorn.Parser;
41
- export declare function createPluginContainer({ plugins, logger, root, build: { rollupOptions } }: ResolvedConfig, moduleGraph?: ModuleGraph, watcher?: FSWatcher): Promise<PluginContainer>;
@@ -1,8 +0,0 @@
1
- /**
2
- * Search up for the nearest `package.json`
3
- */
4
- export declare function searchForPackageRoot(current: string, root?: string): string;
5
- /**
6
- * Search up for the nearest workspace root
7
- */
8
- export declare function searchForWorkspaceRoot(current: string, root?: string): string;
@@ -1,10 +0,0 @@
1
- /// <reference types="node" />
2
- import type { IncomingMessage, OutgoingHttpHeaders, ServerResponse } from 'http';
3
- import type { SourceMap } from 'rollup';
4
- export interface SendOptions {
5
- etag?: string;
6
- cacheControl?: string;
7
- headers?: OutgoingHttpHeaders;
8
- map?: SourceMap | null;
9
- }
10
- export declare function send(req: IncomingMessage, res: ServerResponse, content: string | Buffer, type: string, options: SendOptions): void;
@@ -1,11 +0,0 @@
1
- import type { SourceMap } from 'rollup';
2
- import type { Logger } from '../logger';
3
- interface SourceMapLike {
4
- sources: string[];
5
- sourcesContent?: (string | null)[];
6
- sourceRoot?: string;
7
- }
8
- export declare function injectSourcesContent(map: SourceMapLike, file: string, logger: Logger): Promise<void>;
9
- export declare function genSourceMapUrl(map: SourceMap | string | undefined): string;
10
- export declare function getCodeWithSourcemap(type: 'js' | 'css', code: string, map: SourceMap | null): string;
11
- export {};
@@ -1,14 +0,0 @@
1
- import type { SourceMap } from 'rollup';
2
- import type { ViteDevServer } from '..';
3
- export interface TransformResult {
4
- code: string;
5
- map: SourceMap | null;
6
- etag?: string;
7
- deps?: string[];
8
- dynamicDeps?: string[];
9
- }
10
- export interface TransformOptions {
11
- ssr?: boolean;
12
- html?: boolean;
13
- }
14
- export declare function transformRequest(url: string, server: ViteDevServer, options?: TransformOptions): Promise<TransformResult | null>;
@@ -1,55 +0,0 @@
1
- /// <reference types="node" />
2
- import type { Server } from 'http';
3
- import type { ServerOptions as HttpsServerOptions } from 'https';
4
- import type { WebSocket as WebSocketTypes } from 'types/ws';
5
- import type { CustomPayload, HMRPayload } from 'types/hmrPayload';
6
- import type { InferCustomEventPayload } from 'types/customEvent';
7
- import type { ResolvedConfig } from '..';
8
- export declare const HMR_HEADER = "vite-hmr";
9
- export declare type WebSocketCustomListener<T> = (data: T, client: WebSocketClient) => void;
10
- export interface WebSocketServer {
11
- /**
12
- * Get all connected clients.
13
- */
14
- clients: Set<WebSocketClient>;
15
- /**
16
- * Boardcast events to all clients
17
- */
18
- send(payload: HMRPayload): void;
19
- /**
20
- * Send custom event
21
- */
22
- send<T extends string>(event: T, payload?: InferCustomEventPayload<T>): void;
23
- /**
24
- * Disconnect all clients and terminate the server.
25
- */
26
- close(): Promise<void>;
27
- /**
28
- * Handle custom event emitted by `import.meta.hot.send`
29
- */
30
- on: WebSocketTypes.Server['on'] & {
31
- <T extends string>(event: T, listener: WebSocketCustomListener<InferCustomEventPayload<T>>): void;
32
- };
33
- /**
34
- * Unregister event listener.
35
- */
36
- off: WebSocketTypes.Server['off'] & {
37
- (event: string, listener: Function): void;
38
- };
39
- }
40
- export interface WebSocketClient {
41
- /**
42
- * Send event to the client
43
- */
44
- send(payload: HMRPayload): void;
45
- /**
46
- * Send custom event
47
- */
48
- send(event: string, payload?: CustomPayload['data']): void;
49
- /**
50
- * The raw WebSocket instance
51
- * @advanced
52
- */
53
- socket: WebSocketTypes;
54
- }
55
- export declare function createWebSocketServer(server: Server | null, config: ResolvedConfig, httpsOptions?: HttpsServerOptions): WebSocketServer;