vite 2.8.0-beta.2 → 2.8.0-beta.6

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.

package/dist/node/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var require$$0 = require('events');
4
- var build = require('./chunks/dep-8a5fd784.js');
4
+ var build = require('./chunks/dep-b8b00184.js');
5
5
  var perf_hooks = require('perf_hooks');
6
6
  require('fs');
7
7
  require('path');
@@ -22,7 +22,6 @@ require('assert');
22
22
  require('buffer');
23
23
  require('querystring');
24
24
  require('esbuild');
25
- require('json5');
26
25
  require('child_process');
27
26
  require('worker_threads');
28
27
  require('readline');
@@ -684,7 +683,7 @@ cli
684
683
  .action(async (root, options) => {
685
684
  // output structure is preserved even after bundling so require()
686
685
  // is ok here
687
- const { createServer } = await Promise.resolve().then(function () { return require('./chunks/dep-8a5fd784.js'); }).then(function (n) { return n.index$1; });
686
+ const { createServer } = await Promise.resolve().then(function () { return require('./chunks/dep-b8b00184.js'); }).then(function (n) { return n.index$1; });
688
687
  try {
689
688
  const server = await createServer({
690
689
  root,
@@ -733,7 +732,7 @@ cli
733
732
  .option('--emptyOutDir', `[boolean] force empty outDir when it's outside of root`)
734
733
  .option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
735
734
  .action(async (root, options) => {
736
- const { build: build$1 } = await Promise.resolve().then(function () { return require('./chunks/dep-8a5fd784.js'); }).then(function (n) { return n.build$1; });
735
+ const { build: build$1 } = await Promise.resolve().then(function () { return require('./chunks/dep-b8b00184.js'); }).then(function (n) { return n.build$1; });
737
736
  const buildOptions = cleanOptions(options);
738
737
  try {
739
738
  await build$1({
@@ -756,7 +755,7 @@ cli
756
755
  .command('optimize [root]')
757
756
  .option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
758
757
  .action(async (root, options) => {
759
- const { optimizeDeps } = await Promise.resolve().then(function () { return require('./chunks/dep-8a5fd784.js'); }).then(function (n) { return n.index; });
758
+ const { optimizeDeps } = await Promise.resolve().then(function () { return require('./chunks/dep-b8b00184.js'); }).then(function (n) { return n.index; });
760
759
  try {
761
760
  const config = await build.resolveConfig({
762
761
  root,
@@ -74,6 +74,18 @@ export declare type AnymatchFn = (testString: string) => boolean
74
74
 
75
75
  export declare type AnymatchPattern = string | RegExp | AnymatchFn
76
76
 
77
+ export declare interface AwaitWriteFinishOptions {
78
+ /**
79
+ * Amount of time in milliseconds for a file size to remain constant before emitting its event.
80
+ */
81
+ stabilityThreshold?: number
82
+
83
+ /**
84
+ * File size polling interval.
85
+ */
86
+ pollInterval?: number
87
+ }
88
+
77
89
  /**
78
90
  * Bundles the app for production.
79
91
  * Returns a Promise containing the build result.
@@ -601,25 +613,25 @@ export declare interface FileSystemServeOptions {
601
613
  deny?: string[];
602
614
  }
603
615
 
604
- export declare interface FSWatcher extends fs.FSWatcher {
616
+ export declare class FSWatcher extends EventEmitter implements fs.FSWatcher {
605
617
  options: WatchOptions
606
618
 
607
619
  /**
608
620
  * Constructs a new FSWatcher instance with optional WatchOptions parameter.
609
621
  */
610
- (options?: WatchOptions): void
622
+ constructor(options?: WatchOptions)
611
623
 
612
624
  /**
613
625
  * Add files, directories, or glob patterns for tracking. Takes an array of strings or just one
614
626
  * string.
615
627
  */
616
- add(paths: string | ReadonlyArray<string>): void
628
+ add(paths: string | ReadonlyArray<string>): this
617
629
 
618
630
  /**
619
631
  * Stop watching files, directories, or glob patterns. Takes an array of strings or just one
620
632
  * string.
621
633
  */
622
- unwatch(paths: string | ReadonlyArray<string>): void
634
+ unwatch(paths: string | ReadonlyArray<string>): this
623
635
 
624
636
  /**
625
637
  * Returns an object representing all the paths on the file system being watched by this
@@ -1333,6 +1345,7 @@ export declare type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | 'alia
1333
1345
  root: string;
1334
1346
  base: string;
1335
1347
  publicDir: string;
1348
+ cacheDir: string;
1336
1349
  command: 'build' | 'serve';
1337
1350
  mode: string;
1338
1351
  isProduction: boolean;
@@ -1894,6 +1907,7 @@ export declare interface UserConfig {
1894
1907
  * the performance. You can use `--force` flag or manually delete the directory
1895
1908
  * to regenerate the cache files. The value can be either an absolute file
1896
1909
  * system path or a path relative to <root>.
1910
+ * Default to `.vite` when no package.json is detected.
1897
1911
  * @default 'node_modules/.vite'
1898
1912
  */
1899
1913
  cacheDir?: string;
@@ -2161,7 +2175,7 @@ export declare interface WatchOptions {
2161
2175
 
2162
2176
  /**
2163
2177
  * Whether to use the `fsevents` watching interface if available. When set to `true` explicitly
2164
- * and `fsevents` is available this supersedes the `usePolling` setting. When set to `false` on
2178
+ * and `fsevents` is available this supercedes the `usePolling` setting. When set to `false` on
2165
2179
  * OS X, `usePolling: true` becomes the default.
2166
2180
  */
2167
2181
  useFsEvents?: boolean
@@ -2208,19 +2222,7 @@ export declare interface WatchOptions {
2208
2222
  /**
2209
2223
  * can be set to an object in order to adjust timing params:
2210
2224
  */
2211
- awaitWriteFinish?:
2212
- | {
2213
- /**
2214
- * Amount of time in milliseconds for a file size to remain constant before emitting its event.
2215
- */
2216
- stabilityThreshold?: number
2217
-
2218
- /**
2219
- * File size polling interval.
2220
- */
2221
- pollInterval?: number
2222
- }
2223
- | boolean
2225
+ awaitWriteFinish?: AwaitWriteFinishOptions | boolean
2224
2226
  }
2225
2227
 
2226
2228
  export declare class WebSocket extends EventEmitter {
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var build = require('./chunks/dep-8a5fd784.js');
5
+ var build = require('./chunks/dep-b8b00184.js');
6
6
  require('fs');
7
7
  require('path');
8
8
  require('tty');
@@ -24,7 +24,6 @@ require('assert');
24
24
  require('buffer');
25
25
  require('querystring');
26
26
  require('esbuild');
27
- require('json5');
28
27
  require('child_process');
29
28
  require('worker_threads');
30
29
  require('readline');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "2.8.0-beta.2",
3
+ "version": "2.8.0-beta.6",
4
4
  "license": "MIT",
5
5
  "author": "Evan You",
6
6
  "description": "Native-ESM powered web dev build tool",
@@ -44,24 +44,23 @@
44
44
  },
45
45
  "//": "READ CONTRIBUTING.md to understand what to put under deps vs. devDeps!",
46
46
  "dependencies": {
47
- "esbuild": "0.14.3",
48
- "json5": "^2.2.0",
47
+ "esbuild": "^0.14.14",
49
48
  "postcss": "^8.4.5",
50
- "resolve": "^1.20.0",
49
+ "resolve": "^1.22.0",
51
50
  "rollup": "^2.59.0"
52
51
  },
53
52
  "optionalDependencies": {
54
53
  "fsevents": "~2.3.2"
55
54
  },
56
55
  "devDependencies": {
57
- "@ampproject/remapping": "^1.0.2",
58
- "@babel/parser": "^7.16.6",
59
- "@babel/types": "^7.16.0",
60
- "@rollup/plugin-alias": "^3.1.8",
56
+ "@ampproject/remapping": "^1.1.1",
57
+ "@babel/parser": "^7.16.12",
58
+ "@babel/types": "^7.16.8",
59
+ "@rollup/plugin-alias": "^3.1.9",
61
60
  "@rollup/plugin-commonjs": "^21.0.1",
62
61
  "@rollup/plugin-dynamic-import-vars": "^1.4.2",
63
62
  "@rollup/plugin-json": "^4.1.0",
64
- "@rollup/plugin-node-resolve": "13.1.1",
63
+ "@rollup/plugin-node-resolve": "13.1.3",
65
64
  "@rollup/plugin-typescript": "^8.3.0",
66
65
  "@rollup/pluginutils": "^4.1.2",
67
66
  "@types/convert-source-map": "^1.5.2",
@@ -72,15 +71,15 @@
72
71
  "@types/less": "^3.0.3",
73
72
  "@types/micromatch": "^4.0.2",
74
73
  "@types/mime": "^2.0.3",
75
- "@types/node": "^16.11.17",
74
+ "@types/node": "^16.11.21",
76
75
  "@types/resolve": "^1.20.1",
77
76
  "@types/sass": "~1.43.1",
78
77
  "@types/stylus": "^0.48.36",
79
78
  "@types/ws": "^8.2.2",
80
- "@vue/compiler-dom": "^3.2.26",
79
+ "@vue/compiler-dom": "^3.2.29",
81
80
  "acorn": "^8.7.0",
82
81
  "cac": "6.7.9",
83
- "chokidar": "^3.5.2",
82
+ "chokidar": "^3.5.3",
84
83
  "compression": "^1.7.4",
85
84
  "connect": "^3.7.0",
86
85
  "connect-history-api-fallback": "^1.6.0",
@@ -88,36 +87,37 @@
88
87
  "cors": "^2.8.5",
89
88
  "cross-spawn": "^7.0.3",
90
89
  "debug": "^4.3.3",
91
- "dotenv": "^10.0.0",
92
- "dotenv-expand": "^5.1.0",
90
+ "dotenv": "^14.3.2",
91
+ "dotenv-expand": "^6.0.1",
93
92
  "es-module-lexer": "^0.9.3",
94
93
  "estree-walker": "^2.0.2",
95
94
  "etag": "^1.8.1",
96
- "fast-glob": "^3.2.7",
95
+ "fast-glob": "^3.2.11",
97
96
  "http-proxy": "^1.18.1",
97
+ "json5": "^2.2.0",
98
98
  "launch-editor-middleware": "^2.3.0",
99
99
  "magic-string": "^0.25.7",
100
100
  "micromatch": "^4.0.4",
101
101
  "mrmime": "^1.0.0",
102
- "node-forge": "^1.2.0",
102
+ "node-forge": "^1.2.1",
103
103
  "okie": "^1.0.1",
104
104
  "open": "^8.4.0",
105
105
  "periscopic": "^2.0.3",
106
106
  "picocolors": "^1.0.0",
107
107
  "postcss-import": "^14.0.2",
108
- "postcss-load-config": "^3.1.0",
108
+ "postcss-load-config": "^3.1.1",
109
109
  "postcss-modules": "^4.3.0",
110
110
  "resolve.exports": "^1.1.0",
111
- "rollup-plugin-license": "^2.6.0",
112
- "sirv": "^2.0.0",
113
- "source-map": "^0.6.1",
111
+ "rollup-plugin-license": "^2.6.1",
112
+ "sirv": "^2.0.2",
113
+ "source-map-js": "^1.0.2",
114
114
  "source-map-support": "^0.5.21",
115
115
  "strip-ansi": "^6.0.1",
116
116
  "terser": "^5.10.0",
117
- "tsconfck": "1.1.1",
117
+ "tsconfck": "1.1.2",
118
118
  "tslib": "^2.3.1",
119
119
  "types": "link:./types",
120
- "ws": "^8.4.0"
120
+ "ws": "^8.4.2"
121
121
  },
122
122
  "peerDependencies": {
123
123
  "less": "*",
@@ -39,6 +39,12 @@ function warnFailedFetch(err: Error, path: string | string[]) {
39
39
  )
40
40
  }
41
41
 
42
+ function cleanUrl(pathname: string): string {
43
+ const url = new URL(pathname, location.toString())
44
+ url.searchParams.delete('direct')
45
+ return url.pathname + url.search
46
+ }
47
+
42
48
  // Listen for messages
43
49
  socket.addEventListener('message', async ({ data }) => {
44
50
  handleMessage(JSON.parse(data))
@@ -73,21 +79,21 @@ async function handleMessage(payload: HMRPayload) {
73
79
  } else {
74
80
  // css-update
75
81
  // this is only sent when a css file referenced with <link> is updated
76
- let { path, timestamp } = update
77
- path = path.replace(/\?.*/, '')
82
+ const { path, timestamp } = update
83
+ const searchUrl = cleanUrl(path)
78
84
  // can't use querySelector with `[href*=]` here since the link may be
79
85
  // using relative paths so we need to use link.href to grab the full
80
86
  // URL for the include check.
81
87
  const el = Array.from(
82
88
  document.querySelectorAll<HTMLLinkElement>('link')
83
- ).find((e) => e.href.includes(path))
89
+ ).find((e) => cleanUrl(e.href).includes(searchUrl))
84
90
  if (el) {
85
- const newPath = `${base}${path.slice(1)}${
86
- path.includes('?') ? '&' : '?'
91
+ const newPath = `${base}${searchUrl.slice(1)}${
92
+ searchUrl.includes('?') ? '&' : '?'
87
93
  }t=${timestamp}`
88
94
  el.href = new URL(newPath, el.href).href
89
95
  }
90
- console.log(`[vite] css hot updated: ${path}`)
96
+ console.log(`[vite] css hot updated: ${searchUrl}`)
91
97
  }
92
98
  })
93
99
  break
@@ -226,10 +232,12 @@ socket.addEventListener('close', async ({ wasClean }) => {
226
232
 
227
233
  // https://wicg.github.io/construct-stylesheets
228
234
  const supportsConstructedSheet = (() => {
229
- try {
230
- // new CSSStyleSheet()
231
- // return true
232
- } catch (e) {}
235
+ // TODO: re-enable this try block once Chrome fixes the performance of
236
+ // rule insertion in really big stylesheets
237
+ // try {
238
+ // new CSSStyleSheet()
239
+ // return true
240
+ // } catch (e) {}
233
241
  return false
234
242
  })()
235
243
 
@@ -29,27 +29,28 @@ THE SOFTWARE.
29
29
  /// <reference types="node" />
30
30
 
31
31
  import type * as fs from 'fs'
32
+ import { EventEmitter } from 'events'
32
33
  import type { Matcher } from './anymatch'
33
34
 
34
- export interface FSWatcher extends fs.FSWatcher {
35
+ export class FSWatcher extends EventEmitter implements fs.FSWatcher {
35
36
  options: WatchOptions
36
37
 
37
38
  /**
38
39
  * Constructs a new FSWatcher instance with optional WatchOptions parameter.
39
40
  */
40
- (options?: WatchOptions): void
41
+ constructor(options?: WatchOptions)
41
42
 
42
43
  /**
43
44
  * Add files, directories, or glob patterns for tracking. Takes an array of strings or just one
44
45
  * string.
45
46
  */
46
- add(paths: string | ReadonlyArray<string>): void
47
+ add(paths: string | ReadonlyArray<string>): this
47
48
 
48
49
  /**
49
50
  * Stop watching files, directories, or glob patterns. Takes an array of strings or just one
50
51
  * string.
51
52
  */
52
- unwatch(paths: string | ReadonlyArray<string>): void
53
+ unwatch(paths: string | ReadonlyArray<string>): this
53
54
 
54
55
  /**
55
56
  * Returns an object representing all the paths on the file system being watched by this
@@ -155,7 +156,7 @@ export interface WatchOptions {
155
156
 
156
157
  /**
157
158
  * Whether to use the `fsevents` watching interface if available. When set to `true` explicitly
158
- * and `fsevents` is available this supersedes the `usePolling` setting. When set to `false` on
159
+ * and `fsevents` is available this supercedes the `usePolling` setting. When set to `false` on
159
160
  * OS X, `usePolling: true` becomes the default.
160
161
  */
161
162
  useFsEvents?: boolean
@@ -202,17 +203,25 @@ export interface WatchOptions {
202
203
  /**
203
204
  * can be set to an object in order to adjust timing params:
204
205
  */
205
- awaitWriteFinish?:
206
- | {
207
- /**
208
- * Amount of time in milliseconds for a file size to remain constant before emitting its event.
209
- */
210
- stabilityThreshold?: number
211
-
212
- /**
213
- * File size polling interval.
214
- */
215
- pollInterval?: number
216
- }
217
- | boolean
206
+ awaitWriteFinish?: AwaitWriteFinishOptions | boolean
218
207
  }
208
+
209
+ export interface AwaitWriteFinishOptions {
210
+ /**
211
+ * Amount of time in milliseconds for a file size to remain constant before emitting its event.
212
+ */
213
+ stabilityThreshold?: number
214
+
215
+ /**
216
+ * File size polling interval.
217
+ */
218
+ pollInterval?: number
219
+ }
220
+
221
+ /**
222
+ * produces an instance of `FSWatcher`.
223
+ */
224
+ export function watch(
225
+ paths: string | ReadonlyArray<string>,
226
+ options?: WatchOptions
227
+ ): FSWatcher
@@ -4,6 +4,15 @@
4
4
 
5
5
  /* eslint-disable @typescript-eslint/consistent-type-imports */
6
6
 
7
+ // Duplicate import('../src/node/importGlob').AssertOptions
8
+ // Avoid breaking the production client type because this file is referenced
9
+ // in vite/client.d.ts and in production src/node/importGlob.ts doesn't exist
10
+ interface AssertOptions {
11
+ assert?: {
12
+ type: string
13
+ }
14
+ }
15
+
7
16
  interface ImportMeta {
8
17
  url: string
9
18
 
@@ -52,7 +61,7 @@ interface ImportMeta {
52
61
 
53
62
  glob(
54
63
  pattern: string,
55
- options?: import('../src/node/importGlob').AssertOptions
64
+ options?: AssertOptions
56
65
  ): Record<
57
66
  string,
58
67
  () => Promise<{
@@ -62,7 +71,7 @@ interface ImportMeta {
62
71
 
63
72
  globEager(
64
73
  pattern: string,
65
- options?: import('../src/node/importGlob').AssertOptions
74
+ options?: AssertOptions
66
75
  ): Record<
67
76
  string,
68
77
  {