vite 3.0.0-alpha.1 → 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.
Files changed (91) hide show
  1. package/LICENSE.md +1 -1
  2. package/bin/vite.js +5 -5
  3. package/client.d.ts +4 -2
  4. package/dist/client/client.mjs +23 -19
  5. package/dist/client/client.mjs.map +1 -1
  6. package/dist/node/build.d.ts +178 -0
  7. package/dist/node/certificate.d.ts +2 -0
  8. package/dist/node/chunks/{dep-88b8fd2c.js → dep-205b15fe.js} +40 -37
  9. package/dist/node/chunks/{dep-a9015192.js → dep-24157481.js} +20 -20
  10. package/dist/node/chunks/{dep-5cb039d6.js → dep-c15b7842.js} +976 -1104
  11. package/dist/node/chunks/{dep-8db43f98.js → dep-c6d28e94.js} +27 -29
  12. package/dist/node/chunks/{dep-99df5764.js → dep-df464a73.js} +12 -6
  13. package/dist/node/chunks/{dep-2056ae8a.js → dep-e8ca8d40.js} +9 -3
  14. package/dist/node/cli.d.ts +1 -0
  15. package/dist/node/cli.js +41 -42
  16. package/dist/node/config.d.ts +243 -0
  17. package/dist/node/constants.d.ts +35 -0
  18. package/dist/node/constants.js +82 -0
  19. package/dist/node/http.d.ts +88 -0
  20. package/dist/node/index.d.ts +11 -3
  21. package/dist/node/index.js +37 -60
  22. package/dist/node/logger.d.ts +31 -0
  23. package/dist/node/optimizer/esbuildDepPlugin.d.ts +4 -0
  24. package/dist/node/optimizer/index.d.ts +154 -0
  25. package/dist/node/optimizer/registerMissing.d.ts +3 -0
  26. package/dist/node/optimizer/scan.d.ts +8 -0
  27. package/dist/node/packages.d.ts +27 -0
  28. package/dist/node/plugin.d.ts +129 -0
  29. package/dist/node/plugins/asset.d.ts +68 -0
  30. package/dist/node/plugins/assetImportMetaUrl.d.ts +13 -0
  31. package/dist/node/plugins/clientInjections.d.ts +7 -0
  32. package/dist/node/plugins/css.d.ts +86 -0
  33. package/dist/node/plugins/dataUri.d.ts +5 -0
  34. package/dist/node/plugins/define.d.ts +3 -0
  35. package/dist/node/plugins/dynamicImportVars.d.ts +9 -0
  36. package/dist/node/plugins/ensureWatch.d.ts +5 -0
  37. package/dist/node/plugins/esbuild.d.ts +15 -0
  38. package/dist/node/plugins/html.d.ts +120 -0
  39. package/dist/node/plugins/importAnalysis.d.ts +47 -0
  40. package/dist/node/plugins/importAnalysisBuild.d.ts +16 -0
  41. package/dist/node/plugins/importMetaGlob.d.ts +34 -0
  42. package/dist/node/plugins/index.d.ts +3 -0
  43. package/dist/node/plugins/json.d.ts +23 -0
  44. package/dist/node/plugins/loadFallback.d.ts +5 -0
  45. package/dist/node/plugins/manifest.d.ts +14 -0
  46. package/dist/node/plugins/metadata.d.ts +9 -0
  47. package/dist/node/plugins/modulePreloadPolyfill.d.ts +4 -0
  48. package/dist/node/plugins/optimizedDeps.d.ts +4 -0
  49. package/dist/node/plugins/preAlias.d.ts +5 -0
  50. package/dist/node/plugins/reporter.d.ts +3 -0
  51. package/dist/node/plugins/resolve.d.ts +39 -0
  52. package/dist/node/plugins/splitVendorChunk.d.ts +12 -0
  53. package/dist/node/plugins/ssrRequireHook.d.ts +12 -0
  54. package/dist/node/plugins/terser.d.ts +3 -0
  55. package/dist/node/plugins/wasm.d.ts +4 -0
  56. package/dist/node/plugins/worker.d.ts +9 -0
  57. package/dist/node/plugins/workerImportMetaUrl.d.ts +3 -0
  58. package/dist/node/preview.d.ts +33 -0
  59. package/dist/node/publicUtils.d.ts +10 -0
  60. package/dist/node/server/hmr.d.ts +39 -0
  61. package/dist/node/server/index.d.ts +198 -0
  62. package/dist/node/server/middlewares/base.d.ts +3 -0
  63. package/dist/node/server/middlewares/compression.d.ts +1 -0
  64. package/dist/node/server/middlewares/error.d.ts +8 -0
  65. package/dist/node/server/middlewares/indexHtml.d.ts +4 -0
  66. package/dist/node/server/middlewares/proxy.d.ts +20 -0
  67. package/dist/node/server/middlewares/spaFallback.d.ts +2 -0
  68. package/dist/node/server/middlewares/static.d.ts +6 -0
  69. package/dist/node/server/middlewares/time.d.ts +2 -0
  70. package/dist/node/server/middlewares/transform.d.ts +3 -0
  71. package/dist/node/server/moduleGraph.d.ts +55 -0
  72. package/dist/node/server/openBrowser.d.ts +15 -0
  73. package/dist/node/server/pluginContainer.d.ts +41 -0
  74. package/dist/node/server/searchRoot.d.ts +8 -0
  75. package/dist/node/server/send.d.ts +10 -0
  76. package/dist/node/server/sourcemap.d.ts +11 -0
  77. package/dist/node/server/transformRequest.d.ts +14 -0
  78. package/dist/node/server/ws.d.ts +55 -0
  79. package/dist/node/ssr/ssrExternal.d.ts +11 -0
  80. package/dist/node/ssr/ssrManifestPlugin.d.ts +3 -0
  81. package/dist/node/ssr/ssrModuleLoader.d.ts +7 -0
  82. package/dist/node/ssr/ssrStacktrace.d.ts +3 -0
  83. package/dist/node/ssr/ssrTransform.d.ts +14 -0
  84. package/dist/node/utils.d.ts +145 -0
  85. package/dist/node-cjs/publicUtils.cjs +1788 -0
  86. package/dist/{node/terser.js → node-cjs/terser.cjs} +0 -0
  87. package/index.cjs +33 -0
  88. package/package.json +23 -6
  89. package/src/client/client.ts +22 -16
  90. package/src/client/tsconfig.json +1 -1
  91. package/types/importGlob.d.ts +1 -3
@@ -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,3 @@
1
+ import type { ResolvedConfig } from '..';
2
+ import type { Plugin } from '../plugin';
3
+ export declare function ssrManifestPlugin(config: ResolvedConfig): Plugin;
@@ -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,3 @@
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;
@@ -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 {};
@@ -0,0 +1,145 @@
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 function removeDirSync(dir: string): void;
106
+ export declare const removeDir: typeof removeDirSync;
107
+ export declare const renameDir: ((arg1: string, arg2: string) => Promise<void>) | typeof fs.renameSync;
108
+ export declare function ensureWatchedFile(watcher: FSWatcher, file: string | null, root: string): void;
109
+ interface ImageCandidate {
110
+ url: string;
111
+ descriptor: string;
112
+ }
113
+ export declare function processSrcSet(srcs: string, replacer: (arg: ImageCandidate) => Promise<string>): Promise<string>;
114
+ export declare function processSrcSetSync(srcs: string, replacer: (arg: ImageCandidate) => string): string;
115
+ export declare function combineSourcemaps(filename: string, sourcemapList: Array<DecodedSourceMap | RawSourceMap>, excludeContent?: boolean): RawSourceMap;
116
+ export declare function unique<T>(arr: T[]): T[];
117
+ export interface Hostname {
118
+ host: string | undefined;
119
+ name: string;
120
+ }
121
+ export declare function resolveHostname(optionsHost: string | boolean | undefined): Hostname;
122
+ export declare function arraify<T>(target: T | T[]): T[];
123
+ export declare function toUpperCaseDriveLetter(pathName: string): string;
124
+ export declare const multilineCommentsRE: RegExp;
125
+ export declare const singlelineCommentsRE: RegExp;
126
+ export declare const requestQuerySplitRE: RegExp;
127
+ export declare const usingDynamicImport: boolean;
128
+ /**
129
+ * Dynamically import files. It will make sure it's not being compiled away by TS/Rollup.
130
+ *
131
+ * As a temporary workaround for Jest's lack of stable ESM support, we fallback to require
132
+ * if we're in a Jest environment.
133
+ * See https://github.com/vitejs/vite/pull/5197#issuecomment-938054077
134
+ *
135
+ * @param file File path to import.
136
+ */
137
+ export declare const dynamicImport: Function;
138
+ export declare function parseRequest(id: string): Record<string, string> | null;
139
+ export declare const blankReplacer: (match: string) => string;
140
+ export declare function getHash(text: Buffer | string): string;
141
+ export declare function emptyCssComments(raw: string): string;
142
+ export declare function mergeConfig(defaults: Record<string, any>, overrides: Record<string, any>, isRoot?: boolean): Record<string, any>;
143
+ export declare function mergeAlias(a?: AliasOptions, b?: AliasOptions): AliasOptions | undefined;
144
+ export declare function normalizeAlias(o?: AliasOptions): Alias[];
145
+ export {};