vite 2.7.0-beta.8 → 2.7.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.

Potentially problematic release.


This version of vite might be problematic. Click here for more details.

Files changed (77) hide show
  1. package/CHANGELOG.md +106 -29
  2. package/LICENSE.md +0 -17
  3. package/dist/node/build.d.ts +200 -0
  4. package/dist/node/chunks/{dep-03d6dbab.js → dep-453486e7.js} +2 -2
  5. package/dist/node/chunks/{dep-03d6dbab.js.map → dep-453486e7.js.map} +1 -1
  6. package/dist/node/chunks/{dep-d87be5e9.js → dep-7817f5b4.js} +1557 -1382
  7. package/dist/node/chunks/dep-7817f5b4.js.map +1 -0
  8. package/dist/node/chunks/{dep-8fdf8f48.js → dep-93096c54.js} +2 -2
  9. package/dist/node/chunks/{dep-8fdf8f48.js.map → dep-93096c54.js.map} +1 -1
  10. package/dist/node/chunks/{dep-b192ffe4.js → dep-fffc0487.js} +2 -2
  11. package/dist/node/chunks/{dep-b192ffe4.js.map → dep-fffc0487.js.map} +1 -1
  12. package/dist/node/cli.d.ts +1 -0
  13. package/dist/node/cli.js +4 -4
  14. package/dist/node/cli.js.map +1 -1
  15. package/dist/node/config.d.ts +202 -0
  16. package/dist/node/constants.d.ts +33 -0
  17. package/dist/node/http.d.ts +84 -0
  18. package/dist/node/importGlob.d.ts +9 -0
  19. package/dist/node/index.d.ts +280 -280
  20. package/dist/node/index.js +1 -1
  21. package/dist/node/logger.d.ts +35 -0
  22. package/dist/node/optimizer/esbuildDepPlugin.d.ts +4 -0
  23. package/dist/node/optimizer/index.d.ts +66 -0
  24. package/dist/node/optimizer/registerMissing.d.ts +2 -0
  25. package/dist/node/optimizer/scan.d.ts +9 -0
  26. package/dist/node/packages.d.ts +25 -0
  27. package/dist/node/plugin.d.ts +115 -0
  28. package/dist/node/plugins/asset.d.ts +40 -0
  29. package/dist/node/plugins/assetImportMetaUrl.d.ts +13 -0
  30. package/dist/node/plugins/clientInjections.d.ts +7 -0
  31. package/dist/node/plugins/css.d.ts +72 -0
  32. package/dist/node/plugins/dataUri.d.ts +5 -0
  33. package/dist/node/plugins/define.d.ts +3 -0
  34. package/dist/node/plugins/esbuild.d.ts +15 -0
  35. package/dist/node/plugins/html.d.ts +102 -0
  36. package/dist/node/plugins/importAnalysis.d.ts +46 -0
  37. package/dist/node/plugins/importAnalysisBuild.d.ts +15 -0
  38. package/dist/node/plugins/index.d.ts +3 -0
  39. package/dist/node/plugins/json.d.ts +22 -0
  40. package/dist/node/plugins/loadFallback.d.ts +5 -0
  41. package/dist/node/plugins/manifest.d.ts +14 -0
  42. package/dist/node/plugins/modulePreloadPolyfill.d.ts +4 -0
  43. package/dist/node/plugins/preAlias.d.ts +5 -0
  44. package/dist/node/plugins/reporter.d.ts +3 -0
  45. package/dist/node/plugins/resolve.d.ts +38 -0
  46. package/dist/node/plugins/ssrRequireHook.d.ts +12 -0
  47. package/dist/node/plugins/terser.d.ts +3 -0
  48. package/dist/node/plugins/wasm.d.ts +3 -0
  49. package/dist/node/plugins/worker.d.ts +3 -0
  50. package/dist/node/preview.d.ts +31 -0
  51. package/dist/node/server/hmr.d.ts +37 -0
  52. package/dist/node/server/index.d.ts +214 -0
  53. package/dist/node/server/middlewares/base.d.ts +3 -0
  54. package/dist/node/server/middlewares/error.d.ts +8 -0
  55. package/dist/node/server/middlewares/indexHtml.d.ts +4 -0
  56. package/dist/node/server/middlewares/proxy.d.ts +20 -0
  57. package/dist/node/server/middlewares/spaFallback.d.ts +2 -0
  58. package/dist/node/server/middlewares/static.d.ts +6 -0
  59. package/dist/node/server/middlewares/time.d.ts +2 -0
  60. package/dist/node/server/middlewares/transform.d.ts +3 -0
  61. package/dist/node/server/moduleGraph.d.ts +53 -0
  62. package/dist/node/server/openBrowser.d.ts +15 -0
  63. package/dist/node/server/pluginContainer.d.ts +37 -0
  64. package/dist/node/server/searchRoot.d.ts +8 -0
  65. package/dist/node/server/send.d.ts +4 -0
  66. package/dist/node/server/sourcemap.d.ts +8 -0
  67. package/dist/node/server/transformRequest.d.ts +14 -0
  68. package/dist/node/server/ws.d.ts +14 -0
  69. package/dist/node/ssr/ssrExternal.d.ts +7 -0
  70. package/dist/node/ssr/ssrManifestPlugin.d.ts +3 -0
  71. package/dist/node/ssr/ssrModuleLoader.d.ts +7 -0
  72. package/dist/node/ssr/ssrStacktrace.d.ts +3 -0
  73. package/dist/node/ssr/ssrTransform.d.ts +8 -0
  74. package/dist/node/utils.d.ts +114 -0
  75. package/package.json +9 -10
  76. package/types/ws.d.ts +277 -281
  77. package/dist/node/chunks/dep-d87be5e9.js.map +0 -1
@@ -0,0 +1,3 @@
1
+ import { Plugin } from 'rollup';
2
+ import { ResolvedConfig } from '../config';
3
+ export declare function buildReporterPlugin(config: ResolvedConfig): Plugin;
@@ -0,0 +1,38 @@
1
+ import { Plugin } from '../plugin';
2
+ import { ViteDevServer, SSROptions } from '..';
3
+ import { PartialResolvedId } from 'rollup';
4
+ import { 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
+ }
34
+ export declare function resolvePlugin(baseOptions: InternalResolveOptions): Plugin;
35
+ export declare const idToPkgMap: Map<string, PackageData>;
36
+ export declare function tryNodeResolve(id: string, importer: string | null | undefined, options: InternalResolveOptions, targetWeb: boolean, server?: ViteDevServer, ssr?: boolean): PartialResolvedId | undefined;
37
+ export declare function tryOptimizedResolve(id: string, server: ViteDevServer, importer?: string): string | undefined;
38
+ export declare function resolvePackageEntry(id: string, { dir, data, setResolvedCache, getResolvedCache }: PackageData, targetWeb: boolean, options: InternalResolveOptions): string | undefined;
@@ -0,0 +1,12 @@
1
+ /// <reference types="node" />
2
+ import { ResolvedConfig } from '..';
3
+ import { 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 {};
@@ -0,0 +1,3 @@
1
+ import { Plugin } from '../plugin';
2
+ import { ResolvedConfig } from '..';
3
+ export declare function terserPlugin(config: ResolvedConfig): Plugin;
@@ -0,0 +1,3 @@
1
+ import { ResolvedConfig } from '../config';
2
+ import { Plugin } from '../plugin';
3
+ export declare const wasmPlugin: (config: ResolvedConfig) => Plugin;
@@ -0,0 +1,3 @@
1
+ import { ResolvedConfig } from '../config';
2
+ import { Plugin } from '../plugin';
3
+ export declare function webWorkerPlugin(config: ResolvedConfig): Plugin;
@@ -0,0 +1,31 @@
1
+ /// <reference types="node" />
2
+ import { Server } from 'http';
3
+ import { InlineConfig, ResolvedConfig } from '.';
4
+ import { ResolvedServerOptions } from './server';
5
+ import { CommonServerOptions } from './http';
6
+ export interface PreviewOptions extends CommonServerOptions {
7
+ }
8
+ export interface ResolvedPreviewOptions extends PreviewOptions {
9
+ }
10
+ export declare function resolvePreviewOptions(preview: PreviewOptions | undefined, server: ResolvedServerOptions): ResolvedPreviewOptions;
11
+ export interface PreviewServer {
12
+ /**
13
+ * The resolved vite config object
14
+ */
15
+ config: ResolvedConfig;
16
+ /**
17
+ * native Node http server instance
18
+ */
19
+ httpServer: Server;
20
+ /**
21
+ * Print server urls
22
+ */
23
+ printUrls: () => void;
24
+ }
25
+ /**
26
+ * Starts the Vite server in preview mode, to simulate a production deployment
27
+ * @param config - the resolved Vite config
28
+ * @param serverOptions - what host and port to use
29
+ * @experimental
30
+ */
31
+ export declare function preview(inlineConfig: InlineConfig): Promise<PreviewServer>;
@@ -0,0 +1,37 @@
1
+ /// <reference types="node" />
2
+ import { ViteDevServer } from '..';
3
+ import { ModuleNode } from './moduleGraph';
4
+ import { Server } from 'http';
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 handleHMRUpdate(file: string, server: ViteDevServer): Promise<any>;
24
+ export declare function handleFileAddUnlink(file: string, server: ViteDevServer, isUnlink?: boolean): Promise<void>;
25
+ export declare function handlePrunedModules(mods: Set<ModuleNode>, { ws }: ViteDevServer): void;
26
+ /**
27
+ * Lex import.meta.hot.accept() for accepted deps.
28
+ * Since hot.accept() can only accept string literals or array of string
29
+ * literals, we don't really need a heavy @babel/parse call on the entire source.
30
+ *
31
+ * @returns selfAccepts
32
+ */
33
+ export declare function lexAcceptedHmrDeps(code: string, start: number, urls: Set<{
34
+ url: string;
35
+ start: number;
36
+ end: number;
37
+ }>): boolean;
@@ -0,0 +1,214 @@
1
+ /// <reference types="node" />
2
+ import * as http from 'http';
3
+ import { CommonServerOptions } from '../http';
4
+ import { InlineConfig, ResolvedConfig } from '../config';
5
+ import { PluginContainer } from './pluginContainer';
6
+ import { FSWatcher, WatchOptions } from 'types/chokidar';
7
+ import { WebSocketServer } from './ws';
8
+ import { ModuleGraph, ModuleNode } from './moduleGraph';
9
+ import { Connect } from 'types/connect';
10
+ import { HmrOptions } from './hmr';
11
+ import { TransformOptions, TransformResult } from './transformRequest';
12
+ import { ESBuildTransformResult } from '../plugins/esbuild';
13
+ import { TransformOptions as EsbuildTransformOptions } from 'esbuild';
14
+ import { DepOptimizationMetadata } from '../optimizer';
15
+ import { SourceMap } from 'rollup';
16
+ export { searchForWorkspaceRoot } from './searchRoot';
17
+ export interface ServerOptions extends CommonServerOptions {
18
+ /**
19
+ * Force dep pre-optimization regardless of whether deps have changed.
20
+ */
21
+ force?: boolean;
22
+ /**
23
+ * Configure HMR-specific options (port, host, path & protocol)
24
+ */
25
+ hmr?: HmrOptions | boolean;
26
+ /**
27
+ * chokidar watch options
28
+ * https://github.com/paulmillr/chokidar#api
29
+ */
30
+ watch?: WatchOptions;
31
+ /**
32
+ * Create Vite dev server to be used as a middleware in an existing server
33
+ */
34
+ middlewareMode?: boolean | 'html' | 'ssr';
35
+ /**
36
+ * Prepend this folder to http requests, for use when proxying vite as a subfolder
37
+ * Should start and end with the `/` character
38
+ */
39
+ base?: string;
40
+ /**
41
+ * Options for files served via '/\@fs/'.
42
+ */
43
+ fs?: FileSystemServeOptions;
44
+ /**
45
+ * Origin for the generated asset URLs.
46
+ */
47
+ origin?: string;
48
+ }
49
+ export interface ResolvedServerOptions extends ServerOptions {
50
+ fs: Required<FileSystemServeOptions>;
51
+ }
52
+ export interface FileSystemServeOptions {
53
+ /**
54
+ * Strictly restrict file accessing outside of allowing paths.
55
+ *
56
+ * Set to `false` to disable the warning
57
+ *
58
+ * @default true
59
+ */
60
+ strict?: boolean;
61
+ /**
62
+ * Restrict accessing files outside the allowed directories.
63
+ *
64
+ * Accepts absolute path or a path relative to project root.
65
+ * Will try to search up for workspace root by default.
66
+ */
67
+ allow?: string[];
68
+ /**
69
+ * Restrict accessing files that matches the patterns.
70
+ *
71
+ * This will have higher priority than `allow`.
72
+ * Glob patterns are supported.
73
+ *
74
+ * @default ['.env', '.env.*', '*.crt', '*.pem']
75
+ *
76
+ * @experimental
77
+ */
78
+ deny?: string[];
79
+ }
80
+ export declare type ServerHook = (server: ViteDevServer) => (() => void) | void | Promise<(() => void) | void>;
81
+ export interface ViteDevServer {
82
+ /**
83
+ * The resolved vite config object
84
+ */
85
+ config: ResolvedConfig;
86
+ /**
87
+ * A connect app instance.
88
+ * - Can be used to attach custom middlewares to the dev server.
89
+ * - Can also be used as the handler function of a custom http server
90
+ * or as a middleware in any connect-style Node.js frameworks
91
+ *
92
+ * https://github.com/senchalabs/connect#use-middleware
93
+ */
94
+ middlewares: Connect.Server;
95
+ /**
96
+ * @deprecated use `server.middlewares` instead
97
+ */
98
+ app: 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
+ * Util for transforming a file with esbuild.
133
+ * Can be useful for certain plugins.
134
+ *
135
+ * @deprecated import `transformWithEsbuild` from `vite` instead
136
+ */
137
+ transformWithEsbuild(code: string, filename: string, options?: EsbuildTransformOptions, inMap?: object): Promise<ESBuildTransformResult>;
138
+ /**
139
+ * Transform module code into SSR format.
140
+ * @experimental
141
+ */
142
+ ssrTransform(code: string, inMap: SourceMap | null, url: string): Promise<TransformResult | null>;
143
+ /**
144
+ * Load a given URL as an instantiated module for SSR.
145
+ */
146
+ ssrLoadModule(url: string): Promise<Record<string, any>>;
147
+ /**
148
+ * Fix ssr error stacktrace
149
+ */
150
+ ssrFixStacktrace(e: Error): void;
151
+ /**
152
+ * Start the server.
153
+ */
154
+ listen(port?: number, isRestart?: boolean): Promise<ViteDevServer>;
155
+ /**
156
+ * Stop the server.
157
+ */
158
+ close(): Promise<void>;
159
+ /**
160
+ * Print server urls
161
+ */
162
+ printUrls(): void;
163
+ /**
164
+ * Restart the server.
165
+ *
166
+ * @param forceOptimize - force the optimizer to re-bundle, same as --force cli flag
167
+ */
168
+ restart(forceOptimize?: boolean): Promise<void>;
169
+ /**
170
+ * @internal
171
+ */
172
+ _optimizeDepsMetadata: DepOptimizationMetadata | null;
173
+ /**
174
+ * Deps that are externalized
175
+ * @internal
176
+ */
177
+ _ssrExternals: string[] | null;
178
+ /**
179
+ * @internal
180
+ */
181
+ _globImporters: Record<string, {
182
+ module: ModuleNode;
183
+ importGlobs: {
184
+ base: string;
185
+ pattern: string;
186
+ }[];
187
+ }>;
188
+ /**
189
+ * @internal
190
+ */
191
+ _restartPromise: Promise<void> | null;
192
+ /**
193
+ * @internal
194
+ */
195
+ _forceOptimizeOnRestart: boolean;
196
+ /**
197
+ * @internal
198
+ */
199
+ _isRunningOptimizer: boolean;
200
+ /**
201
+ * @internal
202
+ */
203
+ _registerMissingImport: ((id: string, resolved: string, ssr: boolean | undefined) => void) | null;
204
+ /**
205
+ * @internal
206
+ */
207
+ _pendingReload: Promise<void> | null;
208
+ /**
209
+ * @internal
210
+ */
211
+ _pendingRequests: Map<string, Promise<TransformResult | null>>;
212
+ }
213
+ export declare function createServer(inlineConfig?: InlineConfig): Promise<ViteDevServer>;
214
+ export declare function resolveServerOptions(root: string, raw?: ServerOptions): ResolvedServerOptions;
@@ -0,0 +1,3 @@
1
+ import { ViteDevServer } from '..';
2
+ import { Connect } from 'types/connect';
3
+ export declare function baseMiddleware({ config }: ViteDevServer): Connect.NextHandleFunction;
@@ -0,0 +1,8 @@
1
+ import { RollupError } from 'rollup';
2
+ import { ViteDevServer } from '../..';
3
+ import { Connect } from 'types/connect';
4
+ import { ErrorPayload } from 'types/hmrPayload';
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 { Connect } from 'types/connect';
2
+ import { 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 * as http from 'http';
3
+ import { Connect } from 'types/connect';
4
+ import { HttpProxy } from 'types/http-proxy';
5
+ import { 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, config: ResolvedConfig): Connect.NextHandleFunction;
@@ -0,0 +1,2 @@
1
+ import { Connect } from 'types/connect';
2
+ export declare function spaFallbackMiddleware(root: string): Connect.NextHandleFunction;
@@ -0,0 +1,6 @@
1
+ import { Connect } from 'types/connect';
2
+ import { 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,2 @@
1
+ import { Connect } from 'types/connect';
2
+ export declare function timeMiddleware(root: string): Connect.NextHandleFunction;
@@ -0,0 +1,3 @@
1
+ import { ViteDevServer } from '..';
2
+ import { Connect } from 'types/connect';
3
+ export declare function transformMiddleware(server: ViteDevServer): Connect.NextHandleFunction;
@@ -0,0 +1,53 @@
1
+ import { ModuleInfo, PartialResolvedId } from 'rollup';
2
+ import { 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
+ lastHMRTimestamp: number;
24
+ constructor(url: string);
25
+ }
26
+ export declare type ResolvedUrl = [
27
+ url: string,
28
+ resolvedId: string,
29
+ meta: object | null | undefined
30
+ ];
31
+ export declare class ModuleGraph {
32
+ private resolveId;
33
+ urlToModuleMap: Map<string, ModuleNode>;
34
+ idToModuleMap: Map<string, ModuleNode>;
35
+ fileToModulesMap: Map<string, Set<ModuleNode>>;
36
+ safeModulesPath: Set<string>;
37
+ constructor(resolveId: (url: string) => Promise<PartialResolvedId | null>);
38
+ getModuleByUrl(rawUrl: string): Promise<ModuleNode | undefined>;
39
+ getModuleById(id: string): ModuleNode | undefined;
40
+ getModulesByFile(file: string): Set<ModuleNode> | undefined;
41
+ onFileChange(file: string): void;
42
+ invalidateModule(mod: ModuleNode, seen?: Set<ModuleNode>): void;
43
+ invalidateAll(): void;
44
+ /**
45
+ * Update the module graph based on a module's updated imports information
46
+ * If there are dependencies that no longer have any importers, they are
47
+ * returned as a Set.
48
+ */
49
+ updateModuleInfo(mod: ModuleNode, importedModules: Set<string | ModuleNode>, acceptedModules: Set<string | ModuleNode>, isSelfAccepting: boolean): Promise<Set<ModuleNode> | undefined>;
50
+ ensureEntryFromUrl(rawUrl: string): Promise<ModuleNode>;
51
+ createFileOnlyEntry(file: string): ModuleNode;
52
+ resolveUrl(url: string): Promise<ResolvedUrl>;
53
+ }
@@ -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 { 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,37 @@
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 { Plugin } from '../plugin';
6
+ import { InputOptions, OutputOptions, ModuleInfo, PartialResolvedId, LoadResult, SourceDescription } from 'rollup';
7
+ import * as acorn from 'acorn';
8
+ import { FSWatcher } from 'chokidar';
9
+ import { ResolvedConfig } from '../config';
10
+ import { 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
+ }): Promise<PartialResolvedId | null>;
27
+ transform(code: string, id: string, options?: {
28
+ inMap?: SourceDescription['map'];
29
+ ssr?: boolean;
30
+ }): Promise<SourceDescription | null>;
31
+ load(id: string, options?: {
32
+ ssr?: boolean;
33
+ }): Promise<LoadResult | null>;
34
+ close(): Promise<void>;
35
+ }
36
+ export declare let parser: typeof acorn.Parser;
37
+ 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,4 @@
1
+ /// <reference types="node" />
2
+ import { IncomingMessage, ServerResponse } from 'http';
3
+ import { SourceMap } from 'rollup';
4
+ export declare function send(req: IncomingMessage, res: ServerResponse, content: string | Buffer, type: string, etag?: string, cacheControl?: string, map?: SourceMap | null): void;
@@ -0,0 +1,8 @@
1
+ import { Logger } from '../logger';
2
+ interface SourceMapLike {
3
+ sources: string[];
4
+ sourcesContent?: (string | null)[];
5
+ sourceRoot?: string;
6
+ }
7
+ export declare function injectSourcesContent(map: SourceMapLike, file: string, logger: Logger): Promise<void>;
8
+ export {};
@@ -0,0 +1,14 @@
1
+ import { SourceMap } from 'rollup';
2
+ import { 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,14 @@
1
+ /// <reference types="node" />
2
+ import { Server } from 'http';
3
+ import { ServerOptions as HttpsServerOptions } from 'https';
4
+ import { WebSocket as WebSocketTypes } from 'types/ws';
5
+ import { HMRPayload } from 'types/hmrPayload';
6
+ import { ResolvedConfig } from '..';
7
+ export declare const HMR_HEADER = "vite-hmr";
8
+ export interface WebSocketServer {
9
+ on: WebSocketTypes.Server['on'];
10
+ off: WebSocketTypes.Server['off'];
11
+ send(payload: HMRPayload): void;
12
+ close(): Promise<void>;
13
+ }
14
+ export declare function createWebSocketServer(server: Server | null, config: ResolvedConfig, httpsOptions?: HttpsServerOptions): WebSocketServer;
@@ -0,0 +1,7 @@
1
+ import { ResolvedConfig } from '..';
2
+ /**
3
+ * Heuristics for determining whether a dependency should be externalized for
4
+ * server-side rendering.
5
+ */
6
+ export declare function resolveSSRExternal(config: ResolvedConfig, knownImports: string[]): string[];
7
+ export declare function shouldExternalizeForSSR(id: string, externals: string[]): boolean;
@@ -0,0 +1,3 @@
1
+ import { ResolvedConfig } from '..';
2
+ import { Plugin } from '../plugin';
3
+ export declare function ssrManifestPlugin(config: ResolvedConfig): Plugin;
@@ -0,0 +1,7 @@
1
+ import { 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[]): Promise<SSRModule>;
7
+ export {};
@@ -0,0 +1,3 @@
1
+ import { ModuleGraph } from '../server/moduleGraph';
2
+ export declare function ssrRewriteStacktrace(stack: string, moduleGraph: ModuleGraph): string;
3
+ export declare function rebindErrorStacktrace(e: Error, stacktrace: string): void;
@@ -0,0 +1,8 @@
1
+ import { SourceMap } from 'rollup';
2
+ import { TransformResult } from '../server/transformRequest';
3
+ export declare const ssrModuleExportsKey = "__vite_ssr_exports__";
4
+ export declare const ssrImportKey = "__vite_ssr_import__";
5
+ export declare const ssrDynamicImportKey = "__vite_ssr_dynamic_import__";
6
+ export declare const ssrExportAllKey = "__vite_ssr_exportAll__";
7
+ export declare const ssrImportMetaKey = "__vite_ssr_import_meta__";
8
+ export declare function ssrTransform(code: string, inMap: SourceMap | null, url: string): Promise<TransformResult | null>;