vite 2.9.7 → 3.0.0-alpha.0

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.
@@ -2,29 +2,29 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('./chunks/dep-88bd5805.js');
5
+ var index = require('./chunks/dep-fafc4143.js');
6
6
  require('fs');
7
7
  require('path');
8
+ require('url');
9
+ require('perf_hooks');
8
10
  require('tty');
11
+ require('os');
12
+ require('esbuild');
13
+ require('events');
14
+ require('assert');
15
+ require('resolve');
9
16
  require('util');
10
17
  require('net');
11
- require('events');
12
- require('url');
13
18
  require('http');
14
19
  require('stream');
15
- require('os');
16
- require('resolve');
17
- require('module');
18
- require('perf_hooks');
19
- require('https');
20
- require('zlib');
20
+ require('child_process');
21
21
  require('crypto');
22
- require('tls');
23
- require('assert');
24
- require('esbuild');
22
+ require('module');
25
23
  require('buffer');
26
24
  require('querystring');
27
- require('child_process');
25
+ require('zlib');
26
+ require('https');
27
+ require('tls');
28
28
  require('worker_threads');
29
29
  require('readline');
30
30
 
@@ -144,7 +144,6 @@ exports.mergeConfig = index.mergeConfig;
144
144
  exports.normalizePath = index.normalizePath;
145
145
  exports.optimizeDeps = index.optimizeDeps;
146
146
  exports.preview = index.preview;
147
- exports.printHttpServerUrls = index.printHttpServerUrls;
148
147
  exports.resolveConfig = index.resolveConfig;
149
148
  exports.resolveEnvPrefix = index.resolveEnvPrefix;
150
149
  exports.resolvePackageData = index.resolvePackageData;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "2.9.7",
3
+ "version": "3.0.0-alpha.0",
4
4
  "license": "MIT",
5
5
  "author": "Evan You",
6
6
  "description": "Native-ESM powered web dev build tool",
@@ -17,7 +17,7 @@
17
17
  "types"
18
18
  ],
19
19
  "engines": {
20
- "node": ">=12.2.0"
20
+ "node": ">=14.6.0"
21
21
  },
22
22
  "repository": {
23
23
  "type": "git",
@@ -30,11 +30,10 @@
30
30
  "homepage": "https://github.com/vitejs/vite/tree/main/#readme",
31
31
  "scripts": {
32
32
  "dev": "rimraf dist && rollup -c -w",
33
- "build": "rimraf dist && npm run lint && run-s build-bundle build-types",
33
+ "build": "rimraf dist && run-s build-bundle build-types",
34
34
  "build-bundle": "rollup -c",
35
35
  "build-types": "run-s build-temp-types patch-types roll-types",
36
36
  "build-temp-types": "tsc --emitDeclarationOnly --outDir temp/node -p src/node",
37
- "ci-build": "rimraf dist && run-s build-bundle build-types",
38
37
  "patch-types": "ts-node scripts/patchTypes.ts",
39
38
  "roll-types": "api-extractor run && rimraf temp",
40
39
  "lint": "eslint --ext .ts src/**",
@@ -43,10 +42,10 @@
43
42
  },
44
43
  "//": "READ CONTRIBUTING.md to understand what to put under deps vs. devDeps!",
45
44
  "dependencies": {
46
- "esbuild": "^0.14.27",
45
+ "esbuild": "^0.14.38",
47
46
  "postcss": "^8.4.13",
48
47
  "resolve": "^1.22.0",
49
- "rollup": "^2.59.0"
48
+ "rollup": "^2.72.1"
50
49
  },
51
50
  "optionalDependencies": {
52
51
  "fsevents": "~2.3.2"
@@ -55,7 +54,7 @@
55
54
  "@ampproject/remapping": "^2.2.0",
56
55
  "@babel/parser": "^7.17.10",
57
56
  "@babel/types": "^7.17.10",
58
- "@jridgewell/trace-mapping": "^0.3.9",
57
+ "@jridgewell/trace-mapping": "^0.3.10",
59
58
  "@rollup/plugin-alias": "^3.1.9",
60
59
  "@rollup/plugin-commonjs": "^21.1.0",
61
60
  "@rollup/plugin-dynamic-import-vars": "^1.4.3",
@@ -63,19 +62,6 @@
63
62
  "@rollup/plugin-node-resolve": "13.2.1",
64
63
  "@rollup/plugin-typescript": "^8.3.2",
65
64
  "@rollup/pluginutils": "^4.2.1",
66
- "@types/convert-source-map": "^1.5.2",
67
- "@types/cross-spawn": "^6.0.2",
68
- "@types/debug": "^4.1.7",
69
- "@types/estree": "^0.0.51",
70
- "@types/etag": "^1.8.1",
71
- "@types/less": "^3.0.3",
72
- "@types/micromatch": "^4.0.2",
73
- "@types/mime": "^2.0.3",
74
- "@types/node": "^17.0.25",
75
- "@types/resolve": "^1.20.2",
76
- "@types/sass": "~1.43.1",
77
- "@types/stylus": "^0.48.37",
78
- "@types/ws": "^8.5.3",
79
65
  "@vue/compiler-dom": "^3.2.33",
80
66
  "acorn": "^8.7.1",
81
67
  "cac": "6.7.9",
@@ -112,10 +98,12 @@
112
98
  "source-map-js": "^1.0.2",
113
99
  "source-map-support": "^0.5.21",
114
100
  "strip-ansi": "^6.0.1",
101
+ "strip-literal": "^0.3.0",
115
102
  "terser": "^5.13.1",
116
- "tsconfck": "^1.2.2",
103
+ "tsconfck": "^2.0.0",
117
104
  "tslib": "^2.4.0",
118
105
  "types": "link:./types",
106
+ "ufo": "^0.8.4",
119
107
  "ws": "^8.6.0"
120
108
  },
121
109
  "peerDependencies": {
@@ -106,6 +106,7 @@ async function handleMessage(payload: HMRPayload) {
106
106
  const payloadPath = base + payload.path.slice(1)
107
107
  if (
108
108
  pagePath === payloadPath ||
109
+ payload.path === '/index.html' ||
109
110
  (pagePath.endsWith('/') && pagePath + 'index.html' === payloadPath)
110
111
  ) {
111
112
  location.reload()
@@ -200,12 +201,10 @@ async function waitForSuccessfulPing(ms = 1000) {
200
201
  // eslint-disable-next-line no-constant-condition
201
202
  while (true) {
202
203
  try {
203
- const pingResponse = await fetch(`${base}__vite_ping`)
204
-
205
- // success - 2xx status code
206
- if (pingResponse.ok) break
207
- // failure - non-2xx status code
208
- else throw new Error()
204
+ // A fetch on a websocket URL will return a successful promise with status 400,
205
+ // but will reject a networking error.
206
+ await fetch(`${location.protocol}//${socketHost}`)
207
+ break
209
208
  } catch (e) {
210
209
  // wait ms before attempting to ping again
211
210
  await new Promise((resolve) => setTimeout(resolve, ms))
@@ -432,13 +431,6 @@ export function createHotContext(ownerPath: string): ViteHotContext {
432
431
  }
433
432
  },
434
433
 
435
- acceptDeps() {
436
- throw new Error(
437
- `hot.acceptDeps() is deprecated. ` +
438
- `Use hot.accept() with the same signature instead.`
439
- )
440
- },
441
-
442
434
  dispose(cb) {
443
435
  disposeMap.set(ownerPath, cb)
444
436
  },
@@ -140,8 +140,10 @@ export interface WatchOptions {
140
140
  cwd?: string
141
141
 
142
142
  /**
143
- * If set to true then the strings passed to .watch() and .add() are treated as literal path
144
- * names, even if they look like globs. Default: false.
143
+ * If set to true then the strings passed to .watch() and .add() are treated as literal path
144
+ * names, even if they look like globs.
145
+ *
146
+ * @default false
145
147
  */
146
148
  disableGlobbing?: boolean
147
149
 
package/types/hot.d.ts CHANGED
@@ -7,12 +7,6 @@ export interface ViteHotContext {
7
7
  accept(cb: (mod: any) => void): void
8
8
  accept(dep: string, cb: (mod: any) => void): void
9
9
  accept(deps: readonly string[], cb: (mods: any[]) => void): void
10
-
11
- /**
12
- * @deprecated
13
- */
14
- acceptDeps(): never
15
-
16
10
  dispose(cb: (data: any) => void): void
17
11
  decline(): void
18
12
  invalidate(): void
@@ -0,0 +1,89 @@
1
+ import type { Worker } from 'okie'
2
+
3
+ export interface ImportGlobOptions<
4
+ Eager extends boolean,
5
+ AsType extends string
6
+ > {
7
+ /**
8
+ * Import type for the import url.
9
+ */
10
+ as?: AsType
11
+ /**
12
+ * Import as static or dynamic
13
+ *
14
+ * @default false
15
+ */
16
+ eager?: Eager
17
+ /**
18
+ * Import only the specific named export. Set to `default` to import the default export.
19
+ */
20
+ import?: string
21
+ /**
22
+ * Custom queries
23
+ */
24
+ query?: string | Record<string, string | number | boolean>
25
+ /**
26
+ * Search files also inside `node_modules/` and hidden directories (e.g. `.git/`). This might have impact on performance.
27
+ *
28
+ * @default false
29
+ */
30
+ exhaustive?: boolean
31
+ }
32
+
33
+ export type GeneralImportGlobOptions = ImportGlobOptions<boolean, string>
34
+
35
+ export interface KnownAsTypeMap {
36
+ raw: string
37
+ url: string
38
+ worker: Worker<any, any>
39
+ }
40
+
41
+ export interface ImportGlobFunction {
42
+ /**
43
+ * 1. No generic provided, infer the type from `eager` and `as`
44
+ */
45
+ <
46
+ Eager extends boolean,
47
+ As extends string,
48
+ T = As extends keyof KnownAsTypeMap ? KnownAsTypeMap[As] : unknown
49
+ >(
50
+ glob: string | string[],
51
+ options?: ImportGlobOptions<Eager, As>
52
+ ): (Eager extends true ? true : false) extends true
53
+ ? Record<string, T>
54
+ : Record<string, () => Promise<T>>
55
+ /**
56
+ * 2. Module generic provided, infer the type from `eager: false`
57
+ */
58
+ <M>(
59
+ glob: string | string[],
60
+ options?: ImportGlobOptions<false, string>
61
+ ): Record<string, () => Promise<M>>
62
+ /**
63
+ * 3. Module generic provided, infer the type from `eager: true`
64
+ */
65
+ <M>(
66
+ glob: string | string[],
67
+ options: ImportGlobOptions<true, string>
68
+ ): Record<string, M>
69
+ }
70
+
71
+ export interface ImportGlobEagerFunction {
72
+ /**
73
+ * 1. No generic provided, infer the type from `as`
74
+ */
75
+ <
76
+ As extends string,
77
+ T = As extends keyof KnownAsTypeMap ? KnownAsTypeMap[As] : unknown
78
+ >(
79
+ glob: string | string[],
80
+ options?: Omit<ImportGlobOptions<boolean, As>, 'eager'>
81
+ ): Record<string, T>
82
+ /**
83
+ * 2. Module generic provided
84
+ */
85
+ <M>(
86
+ glob: string | string[],
87
+ options?: Omit<ImportGlobOptions<boolean, string>, 'eager'>
88
+ ): Record<string, M>
89
+ }
@@ -9,12 +9,6 @@
9
9
  // in vite/client.d.ts and in production src/node/importGlob.ts doesn't exist.
10
10
  interface GlobOptions {
11
11
  as?: string
12
- /**
13
- * @deprecated
14
- */
15
- assert?: {
16
- type: string
17
- }
18
12
  }
19
13
 
20
14
  interface ImportMeta {
@@ -24,15 +18,11 @@ interface ImportMeta {
24
18
 
25
19
  readonly env: ImportMetaEnv
26
20
 
27
- glob<Module = { [key: string]: any }>(
28
- pattern: string,
29
- options?: GlobOptions
30
- ): Record<string, () => Promise<Module>>
31
-
32
- globEager<Module = { [key: string]: any }>(
33
- pattern: string,
34
- options?: GlobOptions
35
- ): Record<string, Module>
21
+ glob: import('./importGlob').ImportGlobFunction
22
+ /**
23
+ * @deprecated Use `import.meta.glob('*', { eager: true })` instead
24
+ */
25
+ globEager: import('./importGlob').ImportGlobEagerFunction
36
26
  }
37
27
 
38
28
  interface ImportMetaEnv {
package/types/shims.d.ts CHANGED
@@ -28,7 +28,7 @@ declare module 'launch-editor-middleware' {
28
28
  }
29
29
 
30
30
  declare module 'postcss-load-config' {
31
- import type { ProcessOptions, Plugin } from 'postcss'
31
+ import type { Plugin, ProcessOptions } from 'postcss'
32
32
  function load(
33
33
  inline: any,
34
34
  root: string
@@ -59,6 +59,7 @@ declare module 'postcss-modules' {
59
59
 
60
60
  declare module '@rollup/plugin-dynamic-import-vars' {
61
61
  import type { Plugin } from 'rollup'
62
+ import type { BaseNode } from 'estree'
62
63
 
63
64
  interface Options {
64
65
  include?: string | RegExp | (string | RegExp)[]
@@ -68,6 +69,10 @@ declare module '@rollup/plugin-dynamic-import-vars' {
68
69
 
69
70
  const p: (o?: Options) => Plugin
70
71
  export default p
72
+ export function dynamicImportToGlob(
73
+ ast: BaseNode,
74
+ source: string
75
+ ): null | string
71
76
  }
72
77
 
73
78
  declare module 'rollup-plugin-web-worker-loader' {
@@ -85,14 +90,6 @@ declare module 'rollup-plugin-web-worker-loader' {
85
90
  export default p
86
91
  }
87
92
 
88
- declare module 'micromatch' {
89
- export function isMatch(
90
- path: string,
91
- pattern: string,
92
- options?: { matchBase?: boolean }
93
- ): boolean
94
- }
95
-
96
93
  // LESS' types somewhat references this which doesn't make sense in Node,
97
94
  // so we have to shim it
98
95
  declare interface HTMLLinkElement {}
package/types/terser.d.ts CHANGED
@@ -185,8 +185,6 @@ export namespace Terser {
185
185
  module?: boolean
186
186
  nameCache?: object
187
187
  format?: FormatOptions
188
- /** @deprecated use format instead */
189
- output?: FormatOptions
190
188
  parse?: ParseOptions
191
189
  safari10?: boolean
192
190
  sourceMap?: boolean | SourceMapOptions
package/types/ws.d.ts CHANGED
@@ -20,9 +20,9 @@ import type {
20
20
  Agent,
21
21
  ClientRequest,
22
22
  ClientRequestArgs,
23
+ Server as HTTPServer,
23
24
  IncomingMessage,
24
- OutgoingHttpHeaders,
25
- Server as HTTPServer
25
+ OutgoingHttpHeaders
26
26
  } from 'http'
27
27
  import type { Server as HTTPSServer } from 'https'
28
28
  import type { Duplex, DuplexOptions } from 'stream'