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,82 @@
|
|
|
1
|
+
import path, { resolve } from 'path';
|
|
2
|
+
import { fileURLToPath } from 'url';
|
|
3
|
+
|
|
4
|
+
var version = "3.0.0-alpha.2";
|
|
5
|
+
|
|
6
|
+
const VERSION = version;
|
|
7
|
+
const DEFAULT_MAIN_FIELDS = [
|
|
8
|
+
'module',
|
|
9
|
+
'jsnext:main',
|
|
10
|
+
'jsnext'
|
|
11
|
+
];
|
|
12
|
+
const DEFAULT_EXTENSIONS = [
|
|
13
|
+
'.mjs',
|
|
14
|
+
'.js',
|
|
15
|
+
'.ts',
|
|
16
|
+
'.jsx',
|
|
17
|
+
'.tsx',
|
|
18
|
+
'.json'
|
|
19
|
+
];
|
|
20
|
+
const JS_TYPES_RE = /\.(?:j|t)sx?$|\.mjs$/;
|
|
21
|
+
const OPTIMIZABLE_ENTRY_RE = /\.(?:m?js|ts)$/;
|
|
22
|
+
const SPECIAL_QUERY_RE = /[\?&](?:worker|sharedworker|raw|url)\b/;
|
|
23
|
+
/**
|
|
24
|
+
* Prefix for resolved fs paths, since windows paths may not be valid as URLs.
|
|
25
|
+
*/
|
|
26
|
+
const FS_PREFIX = `/@fs/`;
|
|
27
|
+
/**
|
|
28
|
+
* Prefix for resolved Ids that are not valid browser import specifiers
|
|
29
|
+
*/
|
|
30
|
+
const VALID_ID_PREFIX = `/@id/`;
|
|
31
|
+
/**
|
|
32
|
+
* Plugins that use 'virtual modules' (e.g. for helper functions), prefix the
|
|
33
|
+
* module ID with `\0`, a convention from the rollup ecosystem.
|
|
34
|
+
* This prevents other plugins from trying to process the id (like node resolution),
|
|
35
|
+
* and core features like sourcemaps can use this info to differentiate between
|
|
36
|
+
* virtual modules and regular files.
|
|
37
|
+
* `\0` is not a permitted char in import URLs so we have to replace them during
|
|
38
|
+
* import analysis. The id will be decoded back before entering the plugins pipeline.
|
|
39
|
+
* These encoded virtual ids are also prefixed by the VALID_ID_PREFIX, so virtual
|
|
40
|
+
* modules in the browser end up encoded as `/@id/__x00__{id}`
|
|
41
|
+
*/
|
|
42
|
+
const NULL_BYTE_PLACEHOLDER = `__x00__`;
|
|
43
|
+
const CLIENT_PUBLIC_PATH = `/@vite/client`;
|
|
44
|
+
const ENV_PUBLIC_PATH = `/@vite/env`;
|
|
45
|
+
const VITE_PACKAGE_DIR = resolve(fileURLToPath(import.meta.url), '../../..');
|
|
46
|
+
const CLIENT_ENTRY = resolve(VITE_PACKAGE_DIR, 'dist/client/client.mjs');
|
|
47
|
+
const ENV_ENTRY = resolve(VITE_PACKAGE_DIR, 'dist/client/env.mjs');
|
|
48
|
+
const CLIENT_DIR = path.dirname(CLIENT_ENTRY);
|
|
49
|
+
// ** READ THIS ** before editing `KNOWN_ASSET_TYPES`.
|
|
50
|
+
// If you add an asset to `KNOWN_ASSET_TYPES`, make sure to also add it
|
|
51
|
+
// to the TypeScript declaration file `packages/vite/client.d.ts`.
|
|
52
|
+
const KNOWN_ASSET_TYPES = [
|
|
53
|
+
// images
|
|
54
|
+
'png',
|
|
55
|
+
'jpe?g',
|
|
56
|
+
'gif',
|
|
57
|
+
'svg',
|
|
58
|
+
'ico',
|
|
59
|
+
'webp',
|
|
60
|
+
'avif',
|
|
61
|
+
// media
|
|
62
|
+
'mp4',
|
|
63
|
+
'webm',
|
|
64
|
+
'ogg',
|
|
65
|
+
'mp3',
|
|
66
|
+
'wav',
|
|
67
|
+
'flac',
|
|
68
|
+
'aac',
|
|
69
|
+
// fonts
|
|
70
|
+
'woff2?',
|
|
71
|
+
'eot',
|
|
72
|
+
'ttf',
|
|
73
|
+
'otf',
|
|
74
|
+
// other
|
|
75
|
+
'webmanifest',
|
|
76
|
+
'pdf',
|
|
77
|
+
'txt'
|
|
78
|
+
];
|
|
79
|
+
const DEFAULT_ASSETS_RE = new RegExp(`\\.(` + KNOWN_ASSET_TYPES.join('|') + `)(\\?.*)?$`);
|
|
80
|
+
const DEP_VERSION_RE = /[\?&](v=[\w\.-]+)\b/;
|
|
81
|
+
|
|
82
|
+
export { CLIENT_DIR, CLIENT_ENTRY, CLIENT_PUBLIC_PATH, DEFAULT_ASSETS_RE, DEFAULT_EXTENSIONS, DEFAULT_MAIN_FIELDS, DEP_VERSION_RE, ENV_ENTRY, ENV_PUBLIC_PATH, FS_PREFIX, JS_TYPES_RE, KNOWN_ASSET_TYPES, NULL_BYTE_PLACEHOLDER, OPTIMIZABLE_ENTRY_RE, SPECIAL_QUERY_RE, VALID_ID_PREFIX, VERSION, VITE_PACKAGE_DIR };
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { Server as HttpServer, OutgoingHttpHeaders as HttpServerHeaders } from 'http';
|
|
3
|
+
import type { ServerOptions as HttpsServerOptions } from 'https';
|
|
4
|
+
import type { Connect } from 'types/connect';
|
|
5
|
+
import type { ProxyOptions } from './server/middlewares/proxy';
|
|
6
|
+
import type { Logger } from './logger';
|
|
7
|
+
export interface CommonServerOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Specify server port. Note if the port is already being used, Vite will
|
|
10
|
+
* automatically try the next available port so this may not be the actual
|
|
11
|
+
* port the server ends up listening on.
|
|
12
|
+
*/
|
|
13
|
+
port?: number;
|
|
14
|
+
/**
|
|
15
|
+
* If enabled, vite will exit if specified port is already in use
|
|
16
|
+
*/
|
|
17
|
+
strictPort?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Specify which IP addresses the server should listen on.
|
|
20
|
+
* Set to 0.0.0.0 to listen on all addresses, including LAN and public addresses.
|
|
21
|
+
*/
|
|
22
|
+
host?: string | boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Enable TLS + HTTP/2.
|
|
25
|
+
* Note: this downgrades to TLS only when the proxy option is also used.
|
|
26
|
+
*/
|
|
27
|
+
https?: boolean | HttpsServerOptions;
|
|
28
|
+
/**
|
|
29
|
+
* Open browser window on startup
|
|
30
|
+
*/
|
|
31
|
+
open?: boolean | string;
|
|
32
|
+
/**
|
|
33
|
+
* Configure custom proxy rules for the dev server. Expects an object
|
|
34
|
+
* of `{ key: options }` pairs.
|
|
35
|
+
* Uses [`http-proxy`](https://github.com/http-party/node-http-proxy).
|
|
36
|
+
* Full options [here](https://github.com/http-party/node-http-proxy#options).
|
|
37
|
+
*
|
|
38
|
+
* Example `vite.config.js`:
|
|
39
|
+
* ``` js
|
|
40
|
+
* module.exports = {
|
|
41
|
+
* proxy: {
|
|
42
|
+
* // string shorthand
|
|
43
|
+
* '/foo': 'http://localhost:4567/foo',
|
|
44
|
+
* // with options
|
|
45
|
+
* '/api': {
|
|
46
|
+
* target: 'http://jsonplaceholder.typicode.com',
|
|
47
|
+
* changeOrigin: true,
|
|
48
|
+
* rewrite: path => path.replace(/^\/api/, '')
|
|
49
|
+
* }
|
|
50
|
+
* }
|
|
51
|
+
* }
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
proxy?: Record<string, string | ProxyOptions>;
|
|
55
|
+
/**
|
|
56
|
+
* Configure CORS for the dev server.
|
|
57
|
+
* Uses https://github.com/expressjs/cors.
|
|
58
|
+
* Set to `true` to allow all methods from any origin, or configure separately
|
|
59
|
+
* using an object.
|
|
60
|
+
*/
|
|
61
|
+
cors?: CorsOptions | boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Specify server response headers.
|
|
64
|
+
*/
|
|
65
|
+
headers?: HttpServerHeaders;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* https://github.com/expressjs/cors#configuration-options
|
|
69
|
+
*/
|
|
70
|
+
export interface CorsOptions {
|
|
71
|
+
origin?: CorsOrigin | ((origin: string, cb: (err: Error, origins: CorsOrigin) => void) => void);
|
|
72
|
+
methods?: string | string[];
|
|
73
|
+
allowedHeaders?: string | string[];
|
|
74
|
+
exposedHeaders?: string | string[];
|
|
75
|
+
credentials?: boolean;
|
|
76
|
+
maxAge?: number;
|
|
77
|
+
preflightContinue?: boolean;
|
|
78
|
+
optionsSuccessStatus?: number;
|
|
79
|
+
}
|
|
80
|
+
export declare type CorsOrigin = boolean | string | RegExp | (string | RegExp)[];
|
|
81
|
+
export declare function resolveHttpServer({ proxy }: CommonServerOptions, app: Connect.Server, httpsOptions?: HttpsServerOptions): Promise<HttpServer>;
|
|
82
|
+
export declare function resolveHttpsConfig(https: boolean | HttpsServerOptions | undefined, cacheDir: string): Promise<HttpsServerOptions | undefined>;
|
|
83
|
+
export declare function httpServerStart(httpServer: HttpServer, serverOptions: {
|
|
84
|
+
port: number;
|
|
85
|
+
strictPort: boolean | undefined;
|
|
86
|
+
host: string | undefined;
|
|
87
|
+
logger: Logger;
|
|
88
|
+
}): Promise<number>;
|