vite 2.7.0-beta.1 → 2.7.0-beta.5

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,11 +12,11 @@ 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';
19
18
  import { ModuleFormat } from 'rollup';
19
+ import { ModuleInfo } from 'rollup';
20
20
  import * as net from 'net';
21
21
  import { OutgoingHttpHeaders } from 'http';
22
22
  import { OutputBundle } from 'rollup';
@@ -33,8 +33,9 @@ import { RollupOutput } from 'rollup';
33
33
  import { RollupWatcher } from 'rollup';
34
34
  import { SecureContextOptions } from 'tls';
35
35
  import { Server } from 'http';
36
- import { Server as Server_2 } from 'https';
37
- import { Server as Server_3 } from 'net';
36
+ import { Server as Server_2 } from 'net';
37
+ import { Server as Server_3 } from 'https';
38
+ import { ServerOptions as ServerOptions_2 } from 'https';
38
39
  import { ServerResponse } from 'http';
39
40
  import { Socket } from 'net';
40
41
  import { SourceDescription } from 'rollup';
@@ -46,6 +47,7 @@ import { TransformResult as TransformResult_3 } from 'rollup';
46
47
  import { URL } from 'url';
47
48
  import * as url from 'url';
48
49
  import { WatcherOptions } from 'rollup';
50
+ import { WebSocketServer as WebSocketServer_2 } from 'ws';
49
51
  import { ZlibOptions } from 'zlib';
50
52
 
51
53
  export declare interface Alias {
@@ -255,6 +257,63 @@ export declare interface BuildOptions {
255
257
  watch?: WatcherOptions | null;
256
258
  }
257
259
 
260
+ export declare interface CommonServerOptions {
261
+ /**
262
+ * Specify server port. Note if the port is already being used, Vite will
263
+ * automatically try the next available port so this may not be the actual
264
+ * port the server ends up listening on.
265
+ */
266
+ port?: number;
267
+ /**
268
+ * If enabled, vite will exit if specified port is already in use
269
+ */
270
+ strictPort?: boolean;
271
+ /**
272
+ * Specify which IP addresses the server should listen on.
273
+ * Set to 0.0.0.0 to listen on all addresses, including LAN and public addresses.
274
+ */
275
+ host?: string | boolean;
276
+ /**
277
+ * Enable TLS + HTTP/2.
278
+ * Note: this downgrades to TLS only when the proxy option is also used.
279
+ */
280
+ https?: boolean | ServerOptions_2;
281
+ /**
282
+ * Open browser window on startup
283
+ */
284
+ open?: boolean | string;
285
+ /**
286
+ * Configure custom proxy rules for the dev server. Expects an object
287
+ * of `{ key: options }` pairs.
288
+ * Uses [`http-proxy`](https://github.com/http-party/node-http-proxy).
289
+ * Full options [here](https://github.com/http-party/node-http-proxy#options).
290
+ *
291
+ * Example `vite.config.js`:
292
+ * ``` js
293
+ * module.exports = {
294
+ * proxy: {
295
+ * // string shorthand
296
+ * '/foo': 'http://localhost:4567/foo',
297
+ * // with options
298
+ * '/api': {
299
+ * target: 'http://jsonplaceholder.typicode.com',
300
+ * changeOrigin: true,
301
+ * rewrite: path => path.replace(/^\/api/, '')
302
+ * }
303
+ * }
304
+ * }
305
+ * ```
306
+ */
307
+ proxy?: Record<string, string | ProxyOptions>;
308
+ /**
309
+ * Configure CORS for the dev server.
310
+ * Uses https://github.com/expressjs/cors.
311
+ * Set to `true` to allow all methods from any origin, or configure separately
312
+ * using an object.
313
+ */
314
+ cors?: CorsOptions | boolean;
315
+ }
316
+
258
317
  export declare interface ConfigEnv {
259
318
  command: 'build' | 'serve';
260
319
  mode: string;
@@ -924,7 +983,9 @@ export declare interface InternalResolveOptions extends ResolveOptions {
924
983
  tryPrefix?: string;
925
984
  skipPackageJson?: boolean;
926
985
  preferRelative?: boolean;
986
+ preserveSymlinks?: boolean;
927
987
  isRequire?: boolean;
988
+ isFromTsImporter?: boolean;
928
989
  }
929
990
 
930
991
  export declare interface JsonOptions {
@@ -1005,12 +1066,12 @@ export declare type Matcher = AnymatchPattern | AnymatchPattern[]
1005
1066
  export declare function mergeConfig(a: Record<string, any>, b: Record<string, any>, isRoot?: boolean): Record<string, any>;
1006
1067
 
1007
1068
  export declare class ModuleGraph {
1069
+ private resolveId;
1008
1070
  urlToModuleMap: Map<string, ModuleNode>;
1009
1071
  idToModuleMap: Map<string, ModuleNode>;
1010
1072
  fileToModulesMap: Map<string, Set<ModuleNode>>;
1011
1073
  safeModulesPath: Set<string>;
1012
- container: PluginContainer;
1013
- constructor(container: PluginContainer);
1074
+ constructor(resolveId: (url: string) => Promise<PartialResolvedId | null>);
1014
1075
  getModuleByUrl(rawUrl: string): Promise<ModuleNode | undefined>;
1015
1076
  getModuleById(id: string): ModuleNode | undefined;
1016
1077
  getModulesByFile(file: string): Set<ModuleNode> | undefined;
@@ -1025,7 +1086,7 @@ export declare class ModuleGraph {
1025
1086
  updateModuleInfo(mod: ModuleNode, importedModules: Set<string | ModuleNode>, acceptedModules: Set<string | ModuleNode>, isSelfAccepting: boolean): Promise<Set<ModuleNode> | undefined>;
1026
1087
  ensureEntryFromUrl(rawUrl: string): Promise<ModuleNode>;
1027
1088
  createFileOnlyEntry(file: string): ModuleNode;
1028
- resolveUrl(url: string): Promise<[string, string]>;
1089
+ resolveUrl(url: string): Promise<ResolvedUrl>;
1029
1090
  }
1030
1091
 
1031
1092
  export declare class ModuleNode {
@@ -1039,6 +1100,8 @@ export declare class ModuleNode {
1039
1100
  id: string | null;
1040
1101
  file: string | null;
1041
1102
  type: 'js' | 'css';
1103
+ info?: ModuleInfo;
1104
+ meta?: Record<string, any>;
1042
1105
  importers: Set<ModuleNode>;
1043
1106
  importedModules: Set<ModuleNode>;
1044
1107
  acceptedHmrDeps: Set<ModuleNode>;
@@ -1184,6 +1247,7 @@ export declare interface Plugin extends Plugin_2 {
1184
1247
 
1185
1248
  export declare interface PluginContainer {
1186
1249
  options: InputOptions;
1250
+ getModuleInfo(id: string): ModuleInfo | null;
1187
1251
  buildStart(options: InputOptions): Promise<void>;
1188
1252
  resolveId(id: string, importer?: string, options?: {
1189
1253
  skip?: Set<Plugin>;
@@ -1209,6 +1273,9 @@ export declare type PluginOption = Plugin | false | null | undefined;
1209
1273
  */
1210
1274
  export declare function preview(inlineConfig: InlineConfig): Promise<PreviewServer>;
1211
1275
 
1276
+ export declare interface PreviewOptions extends CommonServerOptions {
1277
+ }
1278
+
1212
1279
  export declare interface PreviewServer {
1213
1280
  /**
1214
1281
  * The resolved vite config object
@@ -1224,7 +1291,10 @@ export declare interface PreviewServer {
1224
1291
  printUrls: () => void;
1225
1292
  }
1226
1293
 
1227
- export declare function printHttpServerUrls(server: Server_3, config: ResolvedConfig): void;
1294
+ /**
1295
+ * @deprecated Use `server.printUrls()` instead
1296
+ */
1297
+ export declare function printHttpServerUrls(server: Server_2, config: ResolvedConfig): void;
1228
1298
 
1229
1299
  export declare interface ProxyOptions extends HttpProxy.ServerOptions {
1230
1300
  /**
@@ -1267,16 +1337,26 @@ export declare type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | 'alia
1267
1337
  plugins: readonly Plugin[];
1268
1338
  server: ResolvedServerOptions;
1269
1339
  build: ResolvedBuildOptions;
1340
+ preview: ResolvedPreviewOptions;
1270
1341
  assetsInclude: (file: string) => boolean;
1271
1342
  logger: Logger;
1272
1343
  createResolver: (options?: Partial<InternalResolveOptions>) => ResolveFn;
1273
1344
  optimizeDeps: Omit<DepOptimizationOptions, 'keepNames'>;
1274
1345
  }>;
1275
1346
 
1347
+ export declare interface ResolvedPreviewOptions extends PreviewOptions {
1348
+ }
1349
+
1276
1350
  export declare interface ResolvedServerOptions extends ServerOptions {
1277
1351
  fs: Required<FileSystemServeOptions>;
1278
1352
  }
1279
1353
 
1354
+ export declare type ResolvedUrl = [
1355
+ url: string,
1356
+ resolvedId: string,
1357
+ meta: object | null | undefined
1358
+ ];
1359
+
1280
1360
  export declare function resolveEnvPrefix({ envPrefix }: UserConfig): string[];
1281
1361
 
1282
1362
  export declare type ResolveFn = (id: string, importer?: string, aliasOnly?: boolean, ssr?: boolean) => Promise<string | undefined>;
@@ -1309,7 +1389,7 @@ export declare interface ResolverObject {
1309
1389
  */
1310
1390
  export declare interface RollupCommonJSOptions {
1311
1391
  /**
1312
- * A minimatch pattern, or array of patterns, which specifies the files in
1392
+ * A picomatch pattern, or array of patterns, which specifies the files in
1313
1393
  * the build the plugin should operate on. By default, all files with
1314
1394
  * extension `".cjs"` or those in `extensions` are included, but you can narrow
1315
1395
  * this list by only including specific files. These files will be analyzed
@@ -1319,7 +1399,7 @@ export declare interface RollupCommonJSOptions {
1319
1399
  */
1320
1400
  include?: string | RegExp | readonly (string | RegExp)[]
1321
1401
  /**
1322
- * A minimatch pattern, or array of patterns, which specifies the files in
1402
+ * A picomatch pattern, or array of patterns, which specifies the files in
1323
1403
  * the build the plugin should _ignore_. By default, all files with
1324
1404
  * extensions other than those in `extensions` or `".cjs"` are ignored, but you
1325
1405
  * can exclude additional files. See also the `include` option.
@@ -1373,6 +1453,26 @@ export declare interface RollupCommonJSOptions {
1373
1453
  * @default []
1374
1454
  */
1375
1455
  ignore?: ReadonlyArray<string> | ((id: string) => boolean)
1456
+ /**
1457
+ * In most cases, where `require` calls are inside a `try-catch` clause,
1458
+ * they should be left unconverted as it requires an optional dependency
1459
+ * that may or may not be installed beside the rolled up package.
1460
+ * Due to the conversion of `require` to a static `import` - the call is hoisted
1461
+ * to the top of the file, outside of the `try-catch` clause.
1462
+ *
1463
+ * - `true`: All `require` calls inside a `try` will be left unconverted.
1464
+ * - `false`: All `require` calls inside a `try` will be converted as if the `try-catch` clause is not there.
1465
+ * - `remove`: Remove all `require` calls from inside any `try` block.
1466
+ * - `string[]`: Pass an array containing the IDs to left unconverted.
1467
+ * - `((id: string) => boolean|'remove')`: Pass a function that control individual IDs.
1468
+ *
1469
+ * @default false
1470
+ */
1471
+ ignoreTryCatch?:
1472
+ | boolean
1473
+ | 'remove'
1474
+ | ReadonlyArray<string>
1475
+ | ((id: string) => boolean | 'remove')
1376
1476
  /**
1377
1477
  * Controls how to render imports from external dependencies. By default,
1378
1478
  * this plugin assumes that all external dependencies are CommonJS. This
@@ -1490,52 +1590,7 @@ export declare function send(req: IncomingMessage, res: ServerResponse, content:
1490
1590
 
1491
1591
  export declare type ServerHook = (server: ViteDevServer) => (() => void) | void | Promise<(() => void) | void>;
1492
1592
 
1493
- export declare interface ServerOptions {
1494
- host?: string | boolean;
1495
- port?: number;
1496
- /**
1497
- * If enabled, vite will exit if specified port is already in use
1498
- */
1499
- strictPort?: boolean;
1500
- /**
1501
- * Enable TLS + HTTP/2.
1502
- * Note: this downgrades to TLS only when the proxy option is also used.
1503
- */
1504
- https?: boolean | https.ServerOptions;
1505
- /**
1506
- * Open browser window on startup
1507
- */
1508
- open?: boolean | string;
1509
- /**
1510
- * Configure custom proxy rules for the dev server. Expects an object
1511
- * of `{ key: options }` pairs.
1512
- * Uses [`http-proxy`](https://github.com/http-party/node-http-proxy).
1513
- * Full options [here](https://github.com/http-party/node-http-proxy#options).
1514
- *
1515
- * Example `vite.config.js`:
1516
- * ``` js
1517
- * module.exports = {
1518
- * proxy: {
1519
- * // string shorthand
1520
- * '/foo': 'http://localhost:4567/foo',
1521
- * // with options
1522
- * '/api': {
1523
- * target: 'http://jsonplaceholder.typicode.com',
1524
- * changeOrigin: true,
1525
- * rewrite: path => path.replace(/^\/api/, '')
1526
- * }
1527
- * }
1528
- * }
1529
- * ```
1530
- */
1531
- proxy?: Record<string, string | ProxyOptions>;
1532
- /**
1533
- * Configure CORS for the dev server.
1534
- * Uses https://github.com/expressjs/cors.
1535
- * Set to `true` to allow all methods from any origin, or configure separately
1536
- * using an object.
1537
- */
1538
- cors?: CorsOptions | boolean;
1593
+ export declare interface ServerOptions extends CommonServerOptions {
1539
1594
  /**
1540
1595
  * Force dep pre-optimization regardless of whether deps have changed.
1541
1596
  */
@@ -1859,6 +1914,10 @@ export declare interface UserConfig {
1859
1914
  * Build specific options
1860
1915
  */
1861
1916
  build?: BuildOptions;
1917
+ /**
1918
+ * Preview specific options, e.g. host, port, https...
1919
+ */
1920
+ preview?: PreviewOptions;
1862
1921
  /**
1863
1922
  * Dep optimization options
1864
1923
  */
@@ -2491,7 +2550,7 @@ export declare namespace WebSocket {
2491
2550
  host?: string | undefined
2492
2551
  port?: number | undefined
2493
2552
  backlog?: number | undefined
2494
- server?: Server | Server_2 | undefined
2553
+ server?: Server | Server_3 | undefined
2495
2554
  verifyClient?:
2496
2555
  | VerifyClientCallbackAsync
2497
2556
  | VerifyClientCallbackSync
@@ -2607,8 +2666,8 @@ export declare namespace WebSocket {
2607
2666
  }
2608
2667
 
2609
2668
  export declare interface WebSocketServer {
2610
- on: WebSocket.Server['on'];
2611
- off: WebSocket.Server['off'];
2669
+ on: WebSocketServer_2['on'];
2670
+ off: WebSocketServer_2['off'];
2612
2671
  send(payload: HMRPayload): void;
2613
2672
  close(): Promise<void>;
2614
2673
  }
@@ -2,31 +2,31 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var build = require('./chunks/dep-966eddc9.js');
6
- require('path');
5
+ var build = require('./chunks/dep-6920cd01.js');
7
6
  require('fs');
8
- require('querystring');
7
+ require('path');
8
+ require('os');
9
9
  require('tty');
10
10
  require('util');
11
11
  require('net');
12
12
  require('events');
13
13
  require('url');
14
14
  require('http');
15
- require('buffer');
16
- require('zlib');
17
- require('os');
15
+ require('stream');
18
16
  require('resolve');
19
17
  require('module');
20
18
  require('perf_hooks');
21
- require('readline');
22
- require('crypto');
23
- require('stream');
24
- require('esbuild');
25
- require('worker_threads');
26
- require('assert');
27
19
  require('https');
20
+ require('zlib');
21
+ require('crypto');
28
22
  require('tls');
23
+ require('assert');
24
+ require('buffer');
25
+ require('querystring');
26
+ require('esbuild');
29
27
  require('child_process');
28
+ require('worker_threads');
29
+ require('readline');
30
30
 
31
31
 
32
32
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "2.7.0-beta.1",
3
+ "version": "2.7.0-beta.5",
4
4
  "license": "MIT",
5
5
  "author": "Evan You",
6
6
  "description": "Native-ESM powered web dev build tool",
@@ -44,18 +44,18 @@
44
44
  },
45
45
  "//": "READ CONTRIBUTING.md to understand what to put under deps vs. devDeps!",
46
46
  "dependencies": {
47
- "esbuild": "^0.13.10",
47
+ "esbuild": "^0.13.12",
48
48
  "postcss": "^8.3.11",
49
49
  "resolve": "^1.20.0",
50
- "rollup": "^2.58.3"
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",
57
+ "@babel/parser": "^7.16.2",
58
+ "@babel/types": "^7.16.0",
59
59
  "@rollup/plugin-alias": "^3.1.8",
60
60
  "@rollup/plugin-commonjs": "^21.0.1",
61
61
  "@rollup/plugin-dynamic-import-vars": "^1.4.1",
@@ -65,22 +65,22 @@
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.4.1",
69
68
  "@types/estree": "^0.0.50",
70
69
  "@types/etag": "^1.8.1",
71
70
  "@types/less": "^3.0.3",
71
+ "@types/micromatch": "^4.0.0",
72
72
  "@types/mime": "^2.0.3",
73
- "@types/node": "^15.14.9",
73
+ "@types/node": "^16.11.7",
74
74
  "@types/resolve": "^1.20.1",
75
- "@types/sass": "~1.16.1",
75
+ "@types/sass": "~1.43.0",
76
76
  "@types/stylus": "^0.48.36",
77
- "@types/ws": "^7.4.7",
78
- "@vue/compiler-dom": "^3.2.20",
77
+ "@types/ws": "^8.2.0",
78
+ "@vue/compiler-dom": "^3.2.21",
79
79
  "acorn": "^8.5.0",
80
80
  "acorn-class-fields": "^1.0.0",
81
81
  "acorn-static-class-features": "^1.0.0",
82
82
  "builtin-modules": "^3.2.0",
83
- "cac": "6.7.3",
83
+ "cac": "6.7.9",
84
84
  "chalk": "^4.1.2",
85
85
  "chokidar": "^3.5.2",
86
86
  "compression": "^1.7.4",
@@ -99,8 +99,8 @@
99
99
  "http-proxy": "^1.18.1",
100
100
  "launch-editor-middleware": "^2.2.1",
101
101
  "magic-string": "^0.25.7",
102
- "mime": "^2.5.2",
103
- "minimatch": "^3.0.4",
102
+ "micromatch": "^4.0.4",
103
+ "mime": "^3.0.0",
104
104
  "okie": "^1.0.1",
105
105
  "open": "^8.4.0",
106
106
  "periscopic": "^2.0.3",
@@ -115,10 +115,10 @@
115
115
  "source-map-support": "^0.5.20",
116
116
  "strip-ansi": "^6.0.1",
117
117
  "terser": "^5.9.0",
118
- "tsconfck": "1.0.0",
118
+ "tsconfck": "1.1.1",
119
119
  "tslib": "^2.3.1",
120
120
  "types": "link:./types",
121
- "ws": "^7.5.5"
121
+ "ws": "^8.2.3"
122
122
  },
123
123
  "peerDependencies": {
124
124
  "less": "*",
@@ -7,7 +7,7 @@
7
7
  */
8
8
  export interface RollupCommonJSOptions {
9
9
  /**
10
- * A minimatch pattern, or array of patterns, which specifies the files in
10
+ * A picomatch pattern, or array of patterns, which specifies the files in
11
11
  * the build the plugin should operate on. By default, all files with
12
12
  * extension `".cjs"` or those in `extensions` are included, but you can narrow
13
13
  * this list by only including specific files. These files will be analyzed
@@ -17,7 +17,7 @@ export interface RollupCommonJSOptions {
17
17
  */
18
18
  include?: string | RegExp | readonly (string | RegExp)[]
19
19
  /**
20
- * A minimatch pattern, or array of patterns, which specifies the files in
20
+ * A picomatch pattern, or array of patterns, which specifies the files in
21
21
  * the build the plugin should _ignore_. By default, all files with
22
22
  * extensions other than those in `extensions` or `".cjs"` are ignored, but you
23
23
  * can exclude additional files. See also the `include` option.
@@ -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
@@ -95,13 +95,12 @@ declare module 'rollup-plugin-web-worker-loader' {
95
95
  export default p
96
96
  }
97
97
 
98
- declare module 'minimatch' {
99
- function match(
98
+ declare module 'micromatch' {
99
+ export function isMatch(
100
100
  path: string,
101
101
  pattern: string,
102
102
  options?: { matchBase?: boolean }
103
103
  ): boolean
104
- export default match
105
104
  }
106
105
 
107
106
  declare module 'compression' {