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.
Files changed (98) hide show
  1. package/LICENSE.md +29 -1
  2. package/bin/vite.js +5 -5
  3. package/client.d.ts +4 -3
  4. package/dist/client/client.mjs +28 -30
  5. package/dist/client/client.mjs.map +1 -1
  6. package/dist/client/env.mjs.map +1 -1
  7. package/dist/node/build.d.ts +178 -0
  8. package/dist/node/certificate.d.ts +2 -0
  9. package/dist/node/chunks/{dep-ac1ae66b.js → dep-205b15fe.js} +40 -37
  10. package/dist/node/chunks/{dep-a9015192.js → dep-24157481.js} +20 -20
  11. package/dist/node/chunks/{dep-59dc6e00.js → dep-c15b7842.js} +42425 -44710
  12. package/dist/node/chunks/{dep-d2c728c0.js → dep-c6d28e94.js} +28 -30
  13. package/dist/node/chunks/{dep-739cc694.js → dep-df464a73.js} +12 -6
  14. package/dist/node/chunks/{dep-2056ae8a.js → dep-e8ca8d40.js} +9 -3
  15. package/dist/node/cli.d.ts +1 -0
  16. package/dist/node/cli.js +41 -42
  17. package/dist/node/config.d.ts +243 -0
  18. package/dist/node/constants.d.ts +35 -0
  19. package/dist/node/constants.js +82 -0
  20. package/dist/node/http.d.ts +88 -0
  21. package/dist/node/index.d.ts +234 -160
  22. package/dist/node/index.js +37 -61
  23. package/dist/node/logger.d.ts +31 -0
  24. package/dist/node/optimizer/esbuildDepPlugin.d.ts +4 -0
  25. package/dist/node/optimizer/index.d.ts +154 -0
  26. package/dist/node/optimizer/registerMissing.d.ts +3 -0
  27. package/dist/node/optimizer/scan.d.ts +8 -0
  28. package/dist/node/packages.d.ts +27 -0
  29. package/dist/node/plugin.d.ts +129 -0
  30. package/dist/node/plugins/asset.d.ts +68 -0
  31. package/dist/node/plugins/assetImportMetaUrl.d.ts +13 -0
  32. package/dist/node/plugins/clientInjections.d.ts +7 -0
  33. package/dist/node/plugins/css.d.ts +86 -0
  34. package/dist/node/plugins/dataUri.d.ts +5 -0
  35. package/dist/node/plugins/define.d.ts +3 -0
  36. package/dist/node/plugins/dynamicImportVars.d.ts +9 -0
  37. package/dist/node/plugins/ensureWatch.d.ts +5 -0
  38. package/dist/node/plugins/esbuild.d.ts +15 -0
  39. package/dist/node/plugins/html.d.ts +120 -0
  40. package/dist/node/plugins/importAnalysis.d.ts +47 -0
  41. package/dist/node/plugins/importAnalysisBuild.d.ts +16 -0
  42. package/dist/node/plugins/importMetaGlob.d.ts +34 -0
  43. package/dist/node/plugins/index.d.ts +3 -0
  44. package/dist/node/plugins/json.d.ts +23 -0
  45. package/dist/node/plugins/loadFallback.d.ts +5 -0
  46. package/dist/node/plugins/manifest.d.ts +14 -0
  47. package/dist/node/plugins/metadata.d.ts +9 -0
  48. package/dist/node/plugins/modulePreloadPolyfill.d.ts +4 -0
  49. package/dist/node/plugins/optimizedDeps.d.ts +4 -0
  50. package/dist/node/plugins/preAlias.d.ts +5 -0
  51. package/dist/node/plugins/reporter.d.ts +3 -0
  52. package/dist/node/plugins/resolve.d.ts +39 -0
  53. package/dist/node/plugins/splitVendorChunk.d.ts +12 -0
  54. package/dist/node/plugins/ssrRequireHook.d.ts +12 -0
  55. package/dist/node/plugins/terser.d.ts +3 -0
  56. package/dist/node/plugins/wasm.d.ts +4 -0
  57. package/dist/node/plugins/worker.d.ts +9 -0
  58. package/dist/node/plugins/workerImportMetaUrl.d.ts +3 -0
  59. package/dist/node/preview.d.ts +33 -0
  60. package/dist/node/publicUtils.d.ts +10 -0
  61. package/dist/node/server/hmr.d.ts +39 -0
  62. package/dist/node/server/index.d.ts +198 -0
  63. package/dist/node/server/middlewares/base.d.ts +3 -0
  64. package/dist/node/server/middlewares/compression.d.ts +1 -0
  65. package/dist/node/server/middlewares/error.d.ts +8 -0
  66. package/dist/node/server/middlewares/indexHtml.d.ts +4 -0
  67. package/dist/node/server/middlewares/proxy.d.ts +20 -0
  68. package/dist/node/server/middlewares/spaFallback.d.ts +2 -0
  69. package/dist/node/server/middlewares/static.d.ts +6 -0
  70. package/dist/node/server/middlewares/time.d.ts +2 -0
  71. package/dist/node/server/middlewares/transform.d.ts +3 -0
  72. package/dist/node/server/moduleGraph.d.ts +55 -0
  73. package/dist/node/server/openBrowser.d.ts +15 -0
  74. package/dist/node/server/pluginContainer.d.ts +41 -0
  75. package/dist/node/server/searchRoot.d.ts +8 -0
  76. package/dist/node/server/send.d.ts +10 -0
  77. package/dist/node/server/sourcemap.d.ts +11 -0
  78. package/dist/node/server/transformRequest.d.ts +14 -0
  79. package/dist/node/server/ws.d.ts +55 -0
  80. package/dist/node/ssr/ssrExternal.d.ts +11 -0
  81. package/dist/node/ssr/ssrManifestPlugin.d.ts +3 -0
  82. package/dist/node/ssr/ssrModuleLoader.d.ts +7 -0
  83. package/dist/node/ssr/ssrStacktrace.d.ts +3 -0
  84. package/dist/node/ssr/ssrTransform.d.ts +14 -0
  85. package/dist/node/utils.d.ts +145 -0
  86. package/dist/node-cjs/publicUtils.cjs +1788 -0
  87. package/dist/{node/terser.js → node-cjs/terser.cjs} +0 -0
  88. package/index.cjs +33 -0
  89. package/package.json +31 -27
  90. package/src/client/client.ts +27 -29
  91. package/src/client/tsconfig.json +1 -1
  92. package/types/chokidar.d.ts +4 -2
  93. package/types/hot.d.ts +0 -6
  94. package/types/importGlob.d.ts +87 -0
  95. package/types/importMeta.d.ts +5 -15
  96. package/types/shims.d.ts +6 -9
  97. package/types/terser.d.ts +0 -2
  98. 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>;