vite 2.9.9 → 3.0.0-alpha.2
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.
- package/LICENSE.md +29 -1
- package/bin/vite.js +5 -5
- package/client.d.ts +4 -3
- package/dist/client/client.mjs +28 -30
- package/dist/client/client.mjs.map +1 -1
- package/dist/client/env.mjs.map +1 -1
- package/dist/node/build.d.ts +178 -0
- package/dist/node/certificate.d.ts +2 -0
- package/dist/node/chunks/{dep-ac1ae66b.js → dep-205b15fe.js} +40 -37
- package/dist/node/chunks/{dep-a9015192.js → dep-24157481.js} +20 -20
- package/dist/node/chunks/{dep-59dc6e00.js → dep-c15b7842.js} +42425 -44710
- package/dist/node/chunks/{dep-d2c728c0.js → dep-c6d28e94.js} +28 -30
- package/dist/node/chunks/{dep-739cc694.js → dep-df464a73.js} +12 -6
- package/dist/node/chunks/{dep-2056ae8a.js → dep-e8ca8d40.js} +9 -3
- package/dist/node/cli.d.ts +1 -0
- package/dist/node/cli.js +41 -42
- package/dist/node/config.d.ts +243 -0
- package/dist/node/constants.d.ts +35 -0
- package/dist/node/constants.js +82 -0
- package/dist/node/http.d.ts +88 -0
- package/dist/node/index.d.ts +234 -160
- package/dist/node/index.js +37 -61
- package/dist/node/logger.d.ts +31 -0
- package/dist/node/optimizer/esbuildDepPlugin.d.ts +4 -0
- package/dist/node/optimizer/index.d.ts +154 -0
- package/dist/node/optimizer/registerMissing.d.ts +3 -0
- package/dist/node/optimizer/scan.d.ts +8 -0
- package/dist/node/packages.d.ts +27 -0
- package/dist/node/plugin.d.ts +129 -0
- package/dist/node/plugins/asset.d.ts +68 -0
- package/dist/node/plugins/assetImportMetaUrl.d.ts +13 -0
- package/dist/node/plugins/clientInjections.d.ts +7 -0
- package/dist/node/plugins/css.d.ts +86 -0
- package/dist/node/plugins/dataUri.d.ts +5 -0
- package/dist/node/plugins/define.d.ts +3 -0
- package/dist/node/plugins/dynamicImportVars.d.ts +9 -0
- package/dist/node/plugins/ensureWatch.d.ts +5 -0
- package/dist/node/plugins/esbuild.d.ts +15 -0
- package/dist/node/plugins/html.d.ts +120 -0
- package/dist/node/plugins/importAnalysis.d.ts +47 -0
- package/dist/node/plugins/importAnalysisBuild.d.ts +16 -0
- package/dist/node/plugins/importMetaGlob.d.ts +34 -0
- package/dist/node/plugins/index.d.ts +3 -0
- package/dist/node/plugins/json.d.ts +23 -0
- package/dist/node/plugins/loadFallback.d.ts +5 -0
- package/dist/node/plugins/manifest.d.ts +14 -0
- package/dist/node/plugins/metadata.d.ts +9 -0
- package/dist/node/plugins/modulePreloadPolyfill.d.ts +4 -0
- package/dist/node/plugins/optimizedDeps.d.ts +4 -0
- package/dist/node/plugins/preAlias.d.ts +5 -0
- package/dist/node/plugins/reporter.d.ts +3 -0
- package/dist/node/plugins/resolve.d.ts +39 -0
- package/dist/node/plugins/splitVendorChunk.d.ts +12 -0
- package/dist/node/plugins/ssrRequireHook.d.ts +12 -0
- package/dist/node/plugins/terser.d.ts +3 -0
- package/dist/node/plugins/wasm.d.ts +4 -0
- package/dist/node/plugins/worker.d.ts +9 -0
- package/dist/node/plugins/workerImportMetaUrl.d.ts +3 -0
- package/dist/node/preview.d.ts +33 -0
- package/dist/node/publicUtils.d.ts +10 -0
- package/dist/node/server/hmr.d.ts +39 -0
- package/dist/node/server/index.d.ts +198 -0
- package/dist/node/server/middlewares/base.d.ts +3 -0
- package/dist/node/server/middlewares/compression.d.ts +1 -0
- package/dist/node/server/middlewares/error.d.ts +8 -0
- package/dist/node/server/middlewares/indexHtml.d.ts +4 -0
- package/dist/node/server/middlewares/proxy.d.ts +20 -0
- package/dist/node/server/middlewares/spaFallback.d.ts +2 -0
- package/dist/node/server/middlewares/static.d.ts +6 -0
- package/dist/node/server/middlewares/time.d.ts +2 -0
- package/dist/node/server/middlewares/transform.d.ts +3 -0
- package/dist/node/server/moduleGraph.d.ts +55 -0
- package/dist/node/server/openBrowser.d.ts +15 -0
- package/dist/node/server/pluginContainer.d.ts +41 -0
- package/dist/node/server/searchRoot.d.ts +8 -0
- package/dist/node/server/send.d.ts +10 -0
- package/dist/node/server/sourcemap.d.ts +11 -0
- package/dist/node/server/transformRequest.d.ts +14 -0
- package/dist/node/server/ws.d.ts +55 -0
- package/dist/node/ssr/ssrExternal.d.ts +11 -0
- package/dist/node/ssr/ssrManifestPlugin.d.ts +3 -0
- package/dist/node/ssr/ssrModuleLoader.d.ts +7 -0
- package/dist/node/ssr/ssrStacktrace.d.ts +3 -0
- package/dist/node/ssr/ssrTransform.d.ts +14 -0
- package/dist/node/utils.d.ts +145 -0
- package/dist/node-cjs/publicUtils.cjs +1788 -0
- package/dist/{node/terser.js → node-cjs/terser.cjs} +0 -0
- package/index.cjs +33 -0
- package/package.json +31 -27
- package/src/client/client.ts +27 -29
- package/src/client/tsconfig.json +1 -1
- package/types/chokidar.d.ts +4 -2
- package/types/hot.d.ts +0 -6
- package/types/importGlob.d.ts +87 -0
- package/types/importMeta.d.ts +5 -15
- package/types/shims.d.ts +6 -9
- package/types/terser.d.ts +0 -2
- package/types/ws.d.ts +2 -2
|
@@ -0,0 +1,198 @@
|
|
|
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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function compression(): (req: any, res: any, next?: () => void) => void;
|
|
@@ -0,0 +1,8 @@
|
|
|
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;
|
|
@@ -0,0 +1,4 @@
|
|
|
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;
|
|
@@ -0,0 +1,20 @@
|
|
|
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;
|
|
@@ -0,0 +1,6 @@
|
|
|
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;
|
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
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;
|
|
@@ -0,0 +1,41 @@
|
|
|
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>;
|
|
@@ -0,0 +1,8 @@
|
|
|
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;
|
|
@@ -0,0 +1,10 @@
|
|
|
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;
|
|
@@ -0,0 +1,11 @@
|
|
|
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 {};
|
|
@@ -0,0 +1,14 @@
|
|
|
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>;
|
|
@@ -0,0 +1,55 @@
|
|
|
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;
|
|
@@ -0,0 +1,11 @@
|
|
|
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;
|
|
@@ -0,0 +1,7 @@
|
|
|
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 {};
|
|
@@ -0,0 +1,14 @@
|
|
|
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 {};
|