vite 2.6.13 → 2.7.0-beta.3

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.

@@ -12,7 +12,6 @@ import { EventEmitter } from 'events';
12
12
  import * as events from 'events';
13
13
  import * as fs from 'fs';
14
14
  import * as http from 'http';
15
- import * as https from 'https';
16
15
  import { IncomingMessage } from 'http';
17
16
  import { InputOptions } from 'rollup';
18
17
  import { LoadResult } from 'rollup';
@@ -33,8 +32,9 @@ import { RollupOutput } from 'rollup';
33
32
  import { RollupWatcher } from 'rollup';
34
33
  import { SecureContextOptions } from 'tls';
35
34
  import { Server } from 'http';
36
- import { Server as Server_2 } from 'https';
37
- import { Server as Server_3 } from 'net';
35
+ import { Server as Server_2 } from 'net';
36
+ import { Server as Server_3 } from 'https';
37
+ import { ServerOptions as ServerOptions_2 } from 'https';
38
38
  import { ServerResponse } from 'http';
39
39
  import { Socket } from 'net';
40
40
  import { SourceDescription } from 'rollup';
@@ -46,6 +46,7 @@ import { TransformResult as TransformResult_3 } from 'rollup';
46
46
  import { URL } from 'url';
47
47
  import * as url from 'url';
48
48
  import { WatcherOptions } from 'rollup';
49
+ import { WebSocketServer as WebSocketServer_2 } from 'ws';
49
50
  import { ZlibOptions } from 'zlib';
50
51
 
51
52
  export declare interface Alias {
@@ -255,6 +256,63 @@ export declare interface BuildOptions {
255
256
  watch?: WatcherOptions | null;
256
257
  }
257
258
 
259
+ export declare interface CommonServerOptions {
260
+ /**
261
+ * Specify server port. Note if the port is already being used, Vite will
262
+ * automatically try the next available port so this may not be the actual
263
+ * port the server ends up listening on.
264
+ */
265
+ port?: number;
266
+ /**
267
+ * If enabled, vite will exit if specified port is already in use
268
+ */
269
+ strictPort?: boolean;
270
+ /**
271
+ * Specify which IP addresses the server should listen on.
272
+ * Set to 0.0.0.0 to listen on all addresses, including LAN and public addresses.
273
+ */
274
+ host?: string | boolean;
275
+ /**
276
+ * Enable TLS + HTTP/2.
277
+ * Note: this downgrades to TLS only when the proxy option is also used.
278
+ */
279
+ https?: boolean | ServerOptions_2;
280
+ /**
281
+ * Open browser window on startup
282
+ */
283
+ open?: boolean | string;
284
+ /**
285
+ * Configure custom proxy rules for the dev server. Expects an object
286
+ * of `{ key: options }` pairs.
287
+ * Uses [`http-proxy`](https://github.com/http-party/node-http-proxy).
288
+ * Full options [here](https://github.com/http-party/node-http-proxy#options).
289
+ *
290
+ * Example `vite.config.js`:
291
+ * ``` js
292
+ * module.exports = {
293
+ * proxy: {
294
+ * // string shorthand
295
+ * '/foo': 'http://localhost:4567/foo',
296
+ * // with options
297
+ * '/api': {
298
+ * target: 'http://jsonplaceholder.typicode.com',
299
+ * changeOrigin: true,
300
+ * rewrite: path => path.replace(/^\/api/, '')
301
+ * }
302
+ * }
303
+ * }
304
+ * ```
305
+ */
306
+ proxy?: Record<string, string | ProxyOptions>;
307
+ /**
308
+ * Configure CORS for the dev server.
309
+ * Uses https://github.com/expressjs/cors.
310
+ * Set to `true` to allow all methods from any origin, or configure separately
311
+ * using an object.
312
+ */
313
+ cors?: CorsOptions | boolean;
314
+ }
315
+
258
316
  export declare interface ConfigEnv {
259
317
  command: 'build' | 'serve';
260
318
  mode: string;
@@ -518,19 +576,27 @@ export declare interface FileSystemServeOptions {
518
576
  * Set to `false` to disable the warning
519
577
  * Default to false at this moment, will enabled by default in the future versions.
520
578
  *
521
- * @experimental
522
- * @default undefined
579
+ * @default true
523
580
  */
524
- strict?: boolean | undefined;
581
+ strict?: boolean;
525
582
  /**
526
583
  * Restrict accessing files outside the allowed directories.
527
584
  *
528
585
  * Accepts absolute path or a path relative to project root.
529
586
  * Will try to search up for workspace root by default.
587
+ */
588
+ allow?: string[];
589
+ /**
590
+ * Restrict accessing files that matches the patterns.
591
+ *
592
+ * This will have higher priority than `allow`.
593
+ * Glob patterns are supported.
594
+ *
595
+ * @default ['.env', '.env.*', '*.crt', '*.pem']
530
596
  *
531
597
  * @experimental
532
598
  */
533
- allow?: string[];
599
+ deny?: string[];
534
600
  }
535
601
 
536
602
  export declare interface FSWatcher extends fs.FSWatcher {
@@ -917,6 +983,7 @@ export declare interface InternalResolveOptions extends ResolveOptions {
917
983
  skipPackageJson?: boolean;
918
984
  preferRelative?: boolean;
919
985
  isRequire?: boolean;
986
+ isFromTsImporter?: boolean;
920
987
  }
921
988
 
922
989
  export declare interface JsonOptions {
@@ -1164,17 +1231,30 @@ export declare interface Plugin extends Plugin_2 {
1164
1231
  */
1165
1232
  resolveId?(this: PluginContext, source: string, importer: string | undefined, options: {
1166
1233
  custom?: CustomPluginOptions;
1167
- }, ssr?: boolean): Promise<ResolveIdResult> | ResolveIdResult;
1168
- load?(this: PluginContext, id: string, ssr?: boolean): Promise<LoadResult> | LoadResult;
1169
- transform?(this: TransformPluginContext, code: string, id: string, ssr?: boolean): Promise<TransformResult_3> | TransformResult_3;
1234
+ ssr?: boolean;
1235
+ }): Promise<ResolveIdResult> | ResolveIdResult;
1236
+ load?(this: PluginContext, id: string, options?: {
1237
+ ssr?: boolean;
1238
+ }): Promise<LoadResult> | LoadResult;
1239
+ transform?(this: TransformPluginContext, code: string, id: string, options?: {
1240
+ ssr?: boolean;
1241
+ }): Promise<TransformResult_3> | TransformResult_3;
1170
1242
  }
1171
1243
 
1172
1244
  export declare interface PluginContainer {
1173
1245
  options: InputOptions;
1174
1246
  buildStart(options: InputOptions): Promise<void>;
1175
- resolveId(id: string, importer?: string, skip?: Set<Plugin>, ssr?: boolean): Promise<PartialResolvedId | null>;
1176
- transform(code: string, id: string, inMap?: SourceDescription['map'], ssr?: boolean): Promise<SourceDescription | null>;
1177
- load(id: string, ssr?: boolean): Promise<LoadResult | null>;
1247
+ resolveId(id: string, importer?: string, options?: {
1248
+ skip?: Set<Plugin>;
1249
+ ssr?: boolean;
1250
+ }): Promise<PartialResolvedId | null>;
1251
+ transform(code: string, id: string, options?: {
1252
+ inMap?: SourceDescription['map'];
1253
+ ssr?: boolean;
1254
+ }): Promise<SourceDescription | null>;
1255
+ load(id: string, options?: {
1256
+ ssr?: boolean;
1257
+ }): Promise<LoadResult | null>;
1178
1258
  close(): Promise<void>;
1179
1259
  }
1180
1260
 
@@ -1186,9 +1266,30 @@ export declare type PluginOption = Plugin | false | null | undefined;
1186
1266
  * @param serverOptions - what host and port to use
1187
1267
  * @experimental
1188
1268
  */
1189
- export declare function preview(config: ResolvedConfig, serverOptions: Pick<ServerOptions, 'port' | 'host'>): Promise<Server>;
1269
+ export declare function preview(inlineConfig: InlineConfig): Promise<PreviewServer>;
1190
1270
 
1191
- export declare function printHttpServerUrls(server: Server_3, config: ResolvedConfig): void;
1271
+ export declare interface PreviewOptions extends CommonServerOptions {
1272
+ }
1273
+
1274
+ export declare interface PreviewServer {
1275
+ /**
1276
+ * The resolved vite config object
1277
+ */
1278
+ config: ResolvedConfig;
1279
+ /**
1280
+ * native Node http server instance
1281
+ */
1282
+ httpServer: Server;
1283
+ /**
1284
+ * Print server urls
1285
+ */
1286
+ printUrls: () => void;
1287
+ }
1288
+
1289
+ /**
1290
+ * @deprecated Use `server.printUrls()` instead
1291
+ */
1292
+ export declare function printHttpServerUrls(server: Server_2, config: ResolvedConfig): void;
1192
1293
 
1193
1294
  export declare interface ProxyOptions extends HttpProxy.ServerOptions {
1194
1295
  /**
@@ -1231,12 +1332,16 @@ export declare type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | 'alia
1231
1332
  plugins: readonly Plugin[];
1232
1333
  server: ResolvedServerOptions;
1233
1334
  build: ResolvedBuildOptions;
1335
+ preview: ResolvedPreviewOptions;
1234
1336
  assetsInclude: (file: string) => boolean;
1235
1337
  logger: Logger;
1236
1338
  createResolver: (options?: Partial<InternalResolveOptions>) => ResolveFn;
1237
1339
  optimizeDeps: Omit<DepOptimizationOptions, 'keepNames'>;
1238
1340
  }>;
1239
1341
 
1342
+ export declare interface ResolvedPreviewOptions extends PreviewOptions {
1343
+ }
1344
+
1240
1345
  export declare interface ResolvedServerOptions extends ServerOptions {
1241
1346
  fs: Required<FileSystemServeOptions>;
1242
1347
  }
@@ -1337,6 +1442,26 @@ export declare interface RollupCommonJSOptions {
1337
1442
  * @default []
1338
1443
  */
1339
1444
  ignore?: ReadonlyArray<string> | ((id: string) => boolean)
1445
+ /**
1446
+ * In most cases, where `require` calls are inside a `try-catch` clause,
1447
+ * they should be left unconverted as it requires an optional dependency
1448
+ * that may or may not be installed beside the rolled up package.
1449
+ * Due to the conversion of `require` to a static `import` - the call is hoisted
1450
+ * to the top of the file, outside of the `try-catch` clause.
1451
+ *
1452
+ * - `true`: All `require` calls inside a `try` will be left unconverted.
1453
+ * - `false`: All `require` calls inside a `try` will be converted as if the `try-catch` clause is not there.
1454
+ * - `remove`: Remove all `require` calls from inside any `try` block.
1455
+ * - `string[]`: Pass an array containing the IDs to left unconverted.
1456
+ * - `((id: string) => boolean|'remove')`: Pass a function that control individual IDs.
1457
+ *
1458
+ * @default false
1459
+ */
1460
+ ignoreTryCatch?:
1461
+ | boolean
1462
+ | 'remove'
1463
+ | ReadonlyArray<string>
1464
+ | ((id: string) => boolean | 'remove')
1340
1465
  /**
1341
1466
  * Controls how to render imports from external dependencies. By default,
1342
1467
  * this plugin assumes that all external dependencies are CommonJS. This
@@ -1454,18 +1579,7 @@ export declare function send(req: IncomingMessage, res: ServerResponse, content:
1454
1579
 
1455
1580
  export declare type ServerHook = (server: ViteDevServer) => (() => void) | void | Promise<(() => void) | void>;
1456
1581
 
1457
- export declare interface ServerOptions {
1458
- host?: string | boolean;
1459
- port?: number;
1460
- /**
1461
- * Enable TLS + HTTP/2.
1462
- * Note: this downgrades to TLS only when the proxy option is also used.
1463
- */
1464
- https?: boolean | https.ServerOptions;
1465
- /**
1466
- * Open browser window on startup
1467
- */
1468
- open?: boolean | string;
1582
+ export declare interface ServerOptions extends CommonServerOptions {
1469
1583
  /**
1470
1584
  * Force dep pre-optimization regardless of whether deps have changed.
1471
1585
  */
@@ -1479,40 +1593,6 @@ export declare interface ServerOptions {
1479
1593
  * https://github.com/paulmillr/chokidar#api
1480
1594
  */
1481
1595
  watch?: WatchOptions;
1482
- /**
1483
- * Configure custom proxy rules for the dev server. Expects an object
1484
- * of `{ key: options }` pairs.
1485
- * Uses [`http-proxy`](https://github.com/http-party/node-http-proxy).
1486
- * Full options [here](https://github.com/http-party/node-http-proxy#options).
1487
- *
1488
- * Example `vite.config.js`:
1489
- * ``` js
1490
- * module.exports = {
1491
- * proxy: {
1492
- * // string shorthand
1493
- * '/foo': 'http://localhost:4567/foo',
1494
- * // with options
1495
- * '/api': {
1496
- * target: 'http://jsonplaceholder.typicode.com',
1497
- * changeOrigin: true,
1498
- * rewrite: path => path.replace(/^\/api/, '')
1499
- * }
1500
- * }
1501
- * }
1502
- * ```
1503
- */
1504
- proxy?: Record<string, string | ProxyOptions>;
1505
- /**
1506
- * Configure CORS for the dev server.
1507
- * Uses https://github.com/expressjs/cors.
1508
- * Set to `true` to allow all methods from any origin, or configure separately
1509
- * using an object.
1510
- */
1511
- cors?: CorsOptions | boolean;
1512
- /**
1513
- * If enabled, vite will exit if specified port is already in use
1514
- */
1515
- strictPort?: boolean;
1516
1596
  /**
1517
1597
  * Create Vite dev server to be used as a middleware in an existing server
1518
1598
  */
@@ -1823,6 +1903,10 @@ export declare interface UserConfig {
1823
1903
  * Build specific options
1824
1904
  */
1825
1905
  build?: BuildOptions;
1906
+ /**
1907
+ * Preview specific options, e.g. host, port, https...
1908
+ */
1909
+ preview?: PreviewOptions;
1826
1910
  /**
1827
1911
  * Dep optimization options
1828
1912
  */
@@ -2455,7 +2539,7 @@ export declare namespace WebSocket {
2455
2539
  host?: string | undefined
2456
2540
  port?: number | undefined
2457
2541
  backlog?: number | undefined
2458
- server?: Server | Server_2 | undefined
2542
+ server?: Server | Server_3 | undefined
2459
2543
  verifyClient?:
2460
2544
  | VerifyClientCallbackAsync
2461
2545
  | VerifyClientCallbackSync
@@ -2571,8 +2655,8 @@ export declare namespace WebSocket {
2571
2655
  }
2572
2656
 
2573
2657
  export declare interface WebSocketServer {
2574
- on: WebSocket.Server['on'];
2575
- off: WebSocket.Server['off'];
2658
+ on: WebSocketServer_2['on'];
2659
+ off: WebSocketServer_2['off'];
2576
2660
  send(payload: HMRPayload): void;
2577
2661
  close(): Promise<void>;
2578
2662
  }
@@ -2,31 +2,31 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var build = require('./chunks/dep-85dbaaa7.js');
5
+ var build = require('./chunks/dep-5243d0d3.js');
6
6
  require('fs');
7
7
  require('path');
8
- require('events');
8
+ require('os');
9
+ require('tty');
9
10
  require('util');
11
+ require('net');
12
+ require('events');
13
+ require('url');
14
+ require('http');
10
15
  require('stream');
11
- require('os');
16
+ require('resolve');
17
+ require('module');
12
18
  require('perf_hooks');
13
- require('url');
19
+ require('https');
20
+ require('zlib');
14
21
  require('crypto');
15
- require('module');
16
- require('esbuild');
17
- require('worker_threads');
22
+ require('tls');
18
23
  require('assert');
24
+ require('buffer');
25
+ require('querystring');
26
+ require('esbuild');
19
27
  require('child_process');
28
+ require('worker_threads');
20
29
  require('readline');
21
- require('zlib');
22
- require('resolve');
23
- require('querystring');
24
- require('tty');
25
- require('net');
26
- require('http');
27
- require('buffer');
28
- require('https');
29
- require('tls');
30
30
 
31
31
 
32
32
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "2.6.13",
3
+ "version": "2.7.0-beta.3",
4
4
  "license": "MIT",
5
5
  "author": "Evan You",
6
6
  "description": "Native-ESM powered web dev build tool",
@@ -44,43 +44,42 @@
44
44
  },
45
45
  "//": "READ CONTRIBUTING.md to understand what to put under deps vs. devDeps!",
46
46
  "dependencies": {
47
- "esbuild": "^0.13.2",
48
- "postcss": "^8.3.8",
47
+ "esbuild": "^0.13.12",
48
+ "postcss": "^8.3.11",
49
49
  "resolve": "^1.20.0",
50
- "rollup": "^2.57.0"
50
+ "rollup": "^2.59.0"
51
51
  },
52
52
  "optionalDependencies": {
53
53
  "fsevents": "~2.3.2"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@ampproject/remapping": "^1.0.1",
57
- "@babel/parser": "^7.15.8",
58
- "@babel/types": "^7.15.6",
59
- "@rollup/plugin-alias": "^3.1.5",
60
- "@rollup/plugin-commonjs": "^21.0.0",
61
- "@rollup/plugin-dynamic-import-vars": "^1.4.0",
57
+ "@babel/parser": "^7.16.2",
58
+ "@babel/types": "^7.16.0",
59
+ "@rollup/plugin-alias": "^3.1.8",
60
+ "@rollup/plugin-commonjs": "^21.0.1",
61
+ "@rollup/plugin-dynamic-import-vars": "^1.4.1",
62
62
  "@rollup/plugin-json": "^4.1.0",
63
- "@rollup/plugin-node-resolve": "13.0.5",
64
- "@rollup/plugin-typescript": "^8.2.5",
63
+ "@rollup/plugin-node-resolve": "13.0.6",
64
+ "@rollup/plugin-typescript": "^8.3.0",
65
65
  "@rollup/pluginutils": "^4.1.1",
66
66
  "@types/convert-source-map": "^1.5.2",
67
67
  "@types/debug": "^4.1.7",
68
- "@types/es-module-lexer": "^0.3.0",
69
68
  "@types/estree": "^0.0.50",
70
69
  "@types/etag": "^1.8.1",
71
70
  "@types/less": "^3.0.3",
72
71
  "@types/mime": "^2.0.3",
73
- "@types/node": "^15.12.2",
72
+ "@types/node": "^16.11.6",
74
73
  "@types/resolve": "^1.20.1",
75
- "@types/sass": "^1.16.1",
74
+ "@types/sass": "~1.43.0",
76
75
  "@types/stylus": "^0.48.36",
77
- "@types/ws": "^7.4.7",
78
- "@vue/compiler-dom": "^3.2.19",
76
+ "@types/ws": "^8.2.0",
77
+ "@vue/compiler-dom": "^3.2.21",
79
78
  "acorn": "^8.5.0",
80
79
  "acorn-class-fields": "^1.0.0",
81
80
  "acorn-static-class-features": "^1.0.0",
82
81
  "builtin-modules": "^3.2.0",
83
- "cac": "^6.7.3",
82
+ "cac": "6.7.9",
84
83
  "chalk": "^4.1.2",
85
84
  "chokidar": "^3.5.2",
86
85
  "compression": "^1.7.4",
@@ -91,7 +90,7 @@
91
90
  "debug": "^4.3.2",
92
91
  "dotenv": "^10.0.0",
93
92
  "dotenv-expand": "^5.1.0",
94
- "es-module-lexer": "^0.9.2",
93
+ "es-module-lexer": "^0.9.3",
95
94
  "estree-walker": "^2.0.2",
96
95
  "etag": "^1.8.1",
97
96
  "execa": "^5.1.1",
@@ -99,26 +98,26 @@
99
98
  "http-proxy": "^1.18.1",
100
99
  "launch-editor-middleware": "^2.2.1",
101
100
  "magic-string": "^0.25.7",
102
- "mime": "^2.5.2",
101
+ "mime": "^3.0.0",
103
102
  "minimatch": "^3.0.4",
104
103
  "okie": "^1.0.1",
105
- "open": "^8.2.1",
104
+ "open": "^8.4.0",
106
105
  "periscopic": "^2.0.3",
107
106
  "postcss-import": "^14.0.2",
108
107
  "postcss-load-config": "^3.1.0",
109
108
  "postcss-modules": "^4.2.2",
110
- "resolve.exports": "^1.0.2",
111
- "rollup-plugin-license": "^2.5.0",
109
+ "resolve.exports": "^1.1.0",
110
+ "rollup-plugin-license": "^2.6.0",
112
111
  "selfsigned": "^1.10.11",
113
- "sirv": "^1.0.17",
112
+ "sirv": "^1.0.18",
114
113
  "source-map": "^0.6.1",
115
114
  "source-map-support": "^0.5.20",
116
- "strip-ansi": "^6.0.0",
115
+ "strip-ansi": "^6.0.1",
117
116
  "terser": "^5.9.0",
118
- "tsconfck": "^1.0.0",
117
+ "tsconfck": "1.1.1",
119
118
  "tslib": "^2.3.1",
120
119
  "types": "link:./types",
121
- "ws": "^7.5.5"
120
+ "ws": "^8.2.3"
122
121
  },
123
122
  "peerDependencies": {
124
123
  "less": "*",
@@ -71,6 +71,26 @@ export interface RollupCommonJSOptions {
71
71
  * @default []
72
72
  */
73
73
  ignore?: ReadonlyArray<string> | ((id: string) => boolean)
74
+ /**
75
+ * In most cases, where `require` calls are inside a `try-catch` clause,
76
+ * they should be left unconverted as it requires an optional dependency
77
+ * that may or may not be installed beside the rolled up package.
78
+ * Due to the conversion of `require` to a static `import` - the call is hoisted
79
+ * to the top of the file, outside of the `try-catch` clause.
80
+ *
81
+ * - `true`: All `require` calls inside a `try` will be left unconverted.
82
+ * - `false`: All `require` calls inside a `try` will be converted as if the `try-catch` clause is not there.
83
+ * - `remove`: Remove all `require` calls from inside any `try` block.
84
+ * - `string[]`: Pass an array containing the IDs to left unconverted.
85
+ * - `((id: string) => boolean|'remove')`: Pass a function that control individual IDs.
86
+ *
87
+ * @default false
88
+ */
89
+ ignoreTryCatch?:
90
+ | boolean
91
+ | 'remove'
92
+ | ReadonlyArray<string>
93
+ | ((id: string) => boolean | 'remove')
74
94
  /**
75
95
  * Controls how to render imports from external dependencies. By default,
76
96
  * this plugin assumes that all external dependencies are CommonJS. This
package/types/shims.d.ts CHANGED
@@ -96,7 +96,11 @@ declare module 'rollup-plugin-web-worker-loader' {
96
96
  }
97
97
 
98
98
  declare module 'minimatch' {
99
- function match(path: string, pattern: string): boolean
99
+ function match(
100
+ path: string,
101
+ pattern: string,
102
+ options?: { matchBase?: boolean }
103
+ ): boolean
100
104
  export default match
101
105
  }
102
106