vite 3.0.0-alpha.5 → 3.0.0-alpha.8

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-21067347.js → dep-6b269949.js} +1 -1
  2. package/dist/node/chunks/{dep-0232e200.js → dep-8250f392.js} +422 -200
  3. package/dist/node/chunks/{dep-cd161504.js → dep-8259d5f4.js} +1 -1
  4. package/dist/node/chunks/{dep-13a14c32.js → dep-cfa39351.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 +40 -4
  8. package/dist/node/index.js +1 -1
  9. package/dist/node-cjs/publicUtils.cjs +1 -1
  10. package/dist/node-cjs/terser.cjs +1023 -2876
  11. package/package.json +11 -10
  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 -246
  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 -181
  22. package/dist/node/optimizer/optimizer.d.ts +0 -4
  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 -130
  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 -7
  46. package/dist/node/plugins/preAlias.d.ts +0 -6
  47. package/dist/node/plugins/reporter.d.ts +0 -3
  48. package/dist/node/plugins/resolve.d.ts +0 -41
  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 -189
  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,189 +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 { Logger } from '../logger';
9
- import type { PluginContainer } from './pluginContainer';
10
- import type { WebSocketServer } from './ws';
11
- import { ModuleGraph } from './moduleGraph';
12
- import type { HmrOptions } from './hmr';
13
- import type { TransformOptions, TransformResult } from './transformRequest';
14
- export { searchForWorkspaceRoot } from './searchRoot';
15
- export interface ServerOptions extends CommonServerOptions {
16
- /**
17
- * Configure HMR-specific options (port, host, path & protocol)
18
- */
19
- hmr?: HmrOptions | boolean;
20
- /**
21
- * chokidar watch options
22
- * https://github.com/paulmillr/chokidar#api
23
- */
24
- watch?: WatchOptions;
25
- /**
26
- * Create Vite dev server to be used as a middleware in an existing server
27
- */
28
- middlewareMode?: boolean | 'html' | 'ssr';
29
- /**
30
- * Prepend this folder to http requests, for use when proxying vite as a subfolder
31
- * Should start and end with the `/` character
32
- */
33
- base?: string;
34
- /**
35
- * Options for files served via '/\@fs/'.
36
- */
37
- fs?: FileSystemServeOptions;
38
- /**
39
- * Origin for the generated asset URLs.
40
- *
41
- * @example `http://127.0.0.1:8080`
42
- */
43
- origin?: string;
44
- /**
45
- * Pre-transform known direct imports
46
- * @default true
47
- */
48
- preTransformRequests?: boolean;
49
- }
50
- export interface ResolvedServerOptions extends ServerOptions {
51
- fs: Required<FileSystemServeOptions>;
52
- }
53
- export interface FileSystemServeOptions {
54
- /**
55
- * Strictly restrict file accessing outside of allowing paths.
56
- *
57
- * Set to `false` to disable the warning
58
- *
59
- * @default true
60
- */
61
- strict?: boolean;
62
- /**
63
- * Restrict accessing files outside the allowed directories.
64
- *
65
- * Accepts absolute path or a path relative to project root.
66
- * Will try to search up for workspace root by default.
67
- */
68
- allow?: string[];
69
- /**
70
- * Restrict accessing files that matches the patterns.
71
- *
72
- * This will have higher priority than `allow`.
73
- * Glob patterns are supported.
74
- *
75
- * @default ['.env', '.env.*', '*.crt', '*.pem']
76
- */
77
- deny?: string[];
78
- }
79
- export declare type ServerHook = (server: ViteDevServer) => (() => void) | void | Promise<(() => void) | void>;
80
- export interface ViteDevServer {
81
- /**
82
- * The resolved vite config object
83
- */
84
- config: ResolvedConfig;
85
- /**
86
- * A connect app instance.
87
- * - Can be used to attach custom middlewares to the dev server.
88
- * - Can also be used as the handler function of a custom http server
89
- * or as a middleware in any connect-style Node.js frameworks
90
- *
91
- * https://github.com/senchalabs/connect#use-middleware
92
- */
93
- middlewares: Connect.Server;
94
- /**
95
- * native Node http server instance
96
- * will be null in middleware mode
97
- */
98
- httpServer: http.Server | null;
99
- /**
100
- * chokidar watcher instance
101
- * https://github.com/paulmillr/chokidar#api
102
- */
103
- watcher: FSWatcher;
104
- /**
105
- * web socket server with `send(payload)` method
106
- */
107
- ws: WebSocketServer;
108
- /**
109
- * Rollup plugin container that can run plugin hooks on a given file
110
- */
111
- pluginContainer: PluginContainer;
112
- /**
113
- * Module graph that tracks the import relationships, url to file mapping
114
- * and hmr state.
115
- */
116
- moduleGraph: ModuleGraph;
117
- /**
118
- * Programmatically resolve, load and transform a URL and get the result
119
- * without going through the http request pipeline.
120
- */
121
- transformRequest(url: string, options?: TransformOptions): Promise<TransformResult | null>;
122
- /**
123
- * Apply vite built-in HTML transforms and any plugin HTML transforms.
124
- */
125
- transformIndexHtml(url: string, html: string, originalUrl?: string): Promise<string>;
126
- /**
127
- * Transform module code into SSR format.
128
- */
129
- ssrTransform(code: string, inMap: SourceMap | null, url: string): Promise<TransformResult | null>;
130
- /**
131
- * Load a given URL as an instantiated module for SSR.
132
- */
133
- ssrLoadModule(url: string, opts?: {
134
- fixStacktrace?: boolean;
135
- }): Promise<Record<string, any>>;
136
- /**
137
- * Returns a fixed version of the given stack
138
- */
139
- ssrRewriteStacktrace(stack: string): string;
140
- /**
141
- * Mutates the given SSR error by rewriting the stacktrace
142
- */
143
- ssrFixStacktrace(e: Error): void;
144
- /**
145
- * Start the server.
146
- */
147
- listen(port?: number, isRestart?: boolean): Promise<ViteDevServer>;
148
- /**
149
- * Stop the server.
150
- */
151
- close(): Promise<void>;
152
- /**
153
- * Print server urls
154
- */
155
- printUrls(): void;
156
- /**
157
- * Restart the server.
158
- *
159
- * @param forceOptimize - force the optimizer to re-bundle, same as --force cli flag
160
- */
161
- restart(forceOptimize?: boolean): Promise<void>;
162
- /**
163
- * @internal
164
- */
165
- _importGlobMap: Map<string, string[][]>;
166
- /**
167
- * Deps that are externalized
168
- * @internal
169
- */
170
- _ssrExternals: string[] | null;
171
- /**
172
- * @internal
173
- */
174
- _restartPromise: Promise<void> | null;
175
- /**
176
- * @internal
177
- */
178
- _forceOptimizeOnRestart: boolean;
179
- /**
180
- * @internal
181
- */
182
- _pendingRequests: Map<string, {
183
- request: Promise<TransformResult | null>;
184
- timestamp: number;
185
- abort: () => void;
186
- }>;
187
- }
188
- export declare function createServer(inlineConfig?: InlineConfig): Promise<ViteDevServer>;
189
- 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;
@@ -1,11 +0,0 @@
1
- import type { ResolvedConfig } from '..';
2
- /**
3
- * Converts "parent > child" syntax to just "child"
4
- */
5
- export declare function stripNesting(packages: string[]): string[];
6
- /**
7
- * Heuristics for determining whether a dependency should be externalized for
8
- * server-side rendering.
9
- */
10
- export declare function resolveSSRExternal(config: ResolvedConfig, knownImports: string[]): string[];
11
- export declare function shouldExternalizeForSSR(id: string, externals: string[]): boolean;
@@ -1,3 +0,0 @@
1
- import type { ResolvedConfig } from '..';
2
- import type { Plugin } from '../plugin';
3
- export declare function ssrManifestPlugin(config: ResolvedConfig): Plugin;
@@ -1,7 +0,0 @@
1
- import type { ViteDevServer } from '../server';
2
- interface SSRContext {
3
- global: typeof globalThis;
4
- }
5
- declare type SSRModule = Record<string, any>;
6
- export declare function ssrLoadModule(url: string, server: ViteDevServer, context?: SSRContext, urlStack?: string[], fixStacktrace?: boolean): Promise<SSRModule>;
7
- export {};
@@ -1,3 +0,0 @@
1
- import type { ModuleGraph } from '../server/moduleGraph';
2
- export declare function ssrRewriteStacktrace(stack: string, moduleGraph: ModuleGraph): string;
3
- export declare function rebindErrorStacktrace(e: Error, stacktrace: string): void;
@@ -1,14 +0,0 @@
1
- import type { SourceMap } from 'rollup';
2
- import type { TransformResult } from '../server/transformRequest';
3
- interface TransformOptions {
4
- json?: {
5
- stringify?: boolean;
6
- };
7
- }
8
- export declare const ssrModuleExportsKey = "__vite_ssr_exports__";
9
- export declare const ssrImportKey = "__vite_ssr_import__";
10
- export declare const ssrDynamicImportKey = "__vite_ssr_dynamic_import__";
11
- export declare const ssrExportAllKey = "__vite_ssr_exportAll__";
12
- export declare const ssrImportMetaKey = "__vite_ssr_import_meta__";
13
- export declare function ssrTransform(code: string, inMap: SourceMap | null, url: string, options?: TransformOptions): Promise<TransformResult | null>;
14
- export {};
@@ -1,144 +0,0 @@
1
- /// <reference types="node" />
2
- import fs from 'fs';
3
- import type { FSWatcher } from 'chokidar';
4
- import type { DecodedSourceMap, RawSourceMap } from '@ampproject/remapping';
5
- import debug from 'debug';
6
- import type { Alias, AliasOptions } from 'types/alias';
7
- export declare function slash(p: string): string;
8
- export declare function unwrapId(id: string): string;
9
- export declare const flattenId: (id: string) => string;
10
- export declare const normalizeId: (id: string) => string;
11
- export declare function isBuiltin(id: string): boolean;
12
- export declare function moduleListContains(moduleList: string[] | undefined, id: string): boolean | undefined;
13
- export declare const bareImportRE: RegExp;
14
- export declare const deepImportRE: RegExp;
15
- export declare let isRunningWithYarnPnp: boolean;
16
- export declare function resolveFrom(id: string, basedir: string, preserveSymlinks?: boolean, ssr?: boolean): string;
17
- /**
18
- * like `resolveFrom` but supports resolving `>` path in `id`,
19
- * for example: `foo > bar > baz`
20
- */
21
- export declare function nestedResolveFrom(id: string, basedir: string, preserveSymlinks?: boolean): string;
22
- interface DebuggerOptions {
23
- onlyWhenFocused?: boolean | string;
24
- }
25
- export declare type ViteDebugScope = `vite:${string}`;
26
- export declare function createDebugger(namespace: ViteDebugScope, options?: DebuggerOptions): debug.Debugger['log'];
27
- export declare const isCaseInsensitiveFS: boolean;
28
- export declare const isWindows: boolean;
29
- export declare function normalizePath(id: string): string;
30
- export declare function fsPathFromId(id: string): string;
31
- export declare function fsPathFromUrl(url: string): string;
32
- /**
33
- * Check if dir is a parent of file
34
- *
35
- * Warning: parameters are not validated, only works with normalized absolute paths
36
- *
37
- * @param dir - normalized absolute path
38
- * @param file - normalized absolute path
39
- * @returns true if dir is a parent of file
40
- */
41
- export declare function isParentDirectory(dir: string, file: string): boolean;
42
- export declare function ensureVolumeInPath(file: string): string;
43
- export declare const queryRE: RegExp;
44
- export declare const hashRE: RegExp;
45
- export declare const cleanUrl: (url: string) => string;
46
- export declare const externalRE: RegExp;
47
- export declare const isExternalUrl: (url: string) => boolean;
48
- export declare const dataUrlRE: RegExp;
49
- export declare const isDataUrl: (url: string) => boolean;
50
- export declare const virtualModuleRE: RegExp;
51
- export declare const virtualModulePrefix = "virtual-module:";
52
- export declare const isJSRequest: (url: string) => boolean;
53
- export declare const isTsRequest: (url: string) => boolean;
54
- export declare const isPossibleTsOutput: (url: string) => boolean;
55
- export declare function getPotentialTsSrcPaths(filePath: string): string[];
56
- export declare const isImportRequest: (url: string) => boolean;
57
- export declare const isInternalRequest: (url: string) => boolean;
58
- export declare function removeImportQuery(url: string): string;
59
- export declare function injectQuery(url: string, queryToInject: string): string;
60
- export declare function removeTimestampQuery(url: string): string;
61
- export declare function isRelativeBase(base: string): boolean;
62
- export declare function asyncReplace(input: string, re: RegExp, replacer: (match: RegExpExecArray) => string | Promise<string>): Promise<string>;
63
- export declare function timeFrom(start: number, subtract?: number): string;
64
- /**
65
- * pretty url for logging.
66
- */
67
- export declare function prettifyUrl(url: string, root: string): string;
68
- export declare function isObject(value: unknown): value is Record<string, any>;
69
- export declare function isDefined<T>(value: T | undefined | null): value is T;
70
- interface LookupFileOptions {
71
- pathOnly?: boolean;
72
- rootDir?: string;
73
- }
74
- export declare function lookupFile(dir: string, formats: string[], options?: LookupFileOptions): string | undefined;
75
- export declare function pad(source: string, n?: number): string;
76
- export declare function posToNumber(source: string, pos: number | {
77
- line: number;
78
- column: number;
79
- }): number;
80
- export declare function numberToPos(source: string, offset: number | {
81
- line: number;
82
- column: number;
83
- }): {
84
- line: number;
85
- column: number;
86
- };
87
- export declare function generateCodeFrame(source: string, start?: number | {
88
- line: number;
89
- column: number;
90
- }, end?: number): string;
91
- export declare function writeFile(filename: string, content: string | Uint8Array): void;
92
- /**
93
- * Use instead of fs.existsSync(filename)
94
- * #2051 if we don't have read permission on a directory, existsSync() still
95
- * works and will result in massively slow subsequent checks (which are
96
- * unnecessary in the first place)
97
- */
98
- export declare function isFileReadable(filename: string): boolean;
99
- /**
100
- * Delete every file and subdirectory. **The given directory must exist.**
101
- * Pass an optional `skip` array to preserve files in the root directory.
102
- */
103
- export declare function emptyDir(dir: string, skip?: string[]): void;
104
- export declare function copyDir(srcDir: string, destDir: string): void;
105
- export declare const removeDir: (dir: string) => void;
106
- export declare const renameDir: ((arg1: string, arg2: string) => Promise<void>) | typeof fs.renameSync;
107
- export declare function ensureWatchedFile(watcher: FSWatcher, file: string | null, root: string): void;
108
- interface ImageCandidate {
109
- url: string;
110
- descriptor: string;
111
- }
112
- export declare function processSrcSet(srcs: string, replacer: (arg: ImageCandidate) => Promise<string>): Promise<string>;
113
- export declare function processSrcSetSync(srcs: string, replacer: (arg: ImageCandidate) => string): string;
114
- export declare function combineSourcemaps(filename: string, sourcemapList: Array<DecodedSourceMap | RawSourceMap>, excludeContent?: boolean): RawSourceMap;
115
- export declare function unique<T>(arr: T[]): T[];
116
- export interface Hostname {
117
- host: string | undefined;
118
- name: string;
119
- }
120
- export declare function resolveHostname(optionsHost: string | boolean | undefined): Hostname;
121
- export declare function arraify<T>(target: T | T[]): T[];
122
- export declare function toUpperCaseDriveLetter(pathName: string): string;
123
- export declare const multilineCommentsRE: RegExp;
124
- export declare const singlelineCommentsRE: RegExp;
125
- export declare const requestQuerySplitRE: RegExp;
126
- export declare const usingDynamicImport: boolean;
127
- /**
128
- * Dynamically import files. It will make sure it's not being compiled away by TS/Rollup.
129
- *
130
- * As a temporary workaround for Jest's lack of stable ESM support, we fallback to require
131
- * if we're in a Jest environment.
132
- * See https://github.com/vitejs/vite/pull/5197#issuecomment-938054077
133
- *
134
- * @param file File path to import.
135
- */
136
- export declare const dynamicImport: Function;
137
- export declare function parseRequest(id: string): Record<string, string> | null;
138
- export declare const blankReplacer: (match: string) => string;
139
- export declare function getHash(text: Buffer | string): string;
140
- export declare function emptyCssComments(raw: string): string;
141
- export declare function mergeConfig(defaults: Record<string, any>, overrides: Record<string, any>, isRoot?: boolean): Record<string, any>;
142
- export declare function mergeAlias(a?: AliasOptions, b?: AliasOptions): AliasOptions | undefined;
143
- export declare function normalizeAlias(o?: AliasOptions): Alias[];
144
- export {};