vite 3.0.6 → 3.0.9

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.
@@ -1,5 +1,5 @@
1
1
  import require$$0$1 from 'postcss';
2
- import { z as commonjsGlobal } from './dep-88cc3a4f.js';
2
+ import { z as commonjsGlobal } from './dep-0fc8e132.js';
3
3
  import require$$0 from 'path';
4
4
  import require$$5 from 'crypto';
5
5
  import require$$0__default from 'fs';
@@ -1,4 +1,4 @@
1
- import { A as getAugmentedNamespace, B as getDefaultExportFromCjs } from './dep-88cc3a4f.js';
1
+ import { A as getAugmentedNamespace, B as getDefaultExportFromCjs } from './dep-0fc8e132.js';
2
2
 
3
3
  import { fileURLToPath as __cjs_fileURLToPath } from 'node:url';
4
4
  import { dirname as __cjs_dirname } from 'node:path';
package/dist/node/cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { performance } from 'node:perf_hooks';
2
2
  import { EventEmitter } from 'events';
3
- import { y as picocolors, u as createLogger, e as resolveConfig } from './chunks/dep-88cc3a4f.js';
3
+ import { y as picocolors, u as createLogger, e as resolveConfig } from './chunks/dep-0fc8e132.js';
4
4
  import { VERSION } from './constants.js';
5
5
  import 'node:fs';
6
6
  import 'node:path';
@@ -694,7 +694,7 @@ cli
694
694
  .action(async (root, options) => {
695
695
  // output structure is preserved even after bundling so require()
696
696
  // is ok here
697
- const { createServer } = await import('./chunks/dep-88cc3a4f.js').then(function (n) { return n.E; });
697
+ const { createServer } = await import('./chunks/dep-0fc8e132.js').then(function (n) { return n.E; });
698
698
  try {
699
699
  const server = await createServer({
700
700
  root,
@@ -741,7 +741,7 @@ cli
741
741
  .option('--emptyOutDir', `[boolean] force empty outDir when it's outside of root`)
742
742
  .option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
743
743
  .action(async (root, options) => {
744
- const { build } = await import('./chunks/dep-88cc3a4f.js').then(function (n) { return n.D; });
744
+ const { build } = await import('./chunks/dep-0fc8e132.js').then(function (n) { return n.D; });
745
745
  const buildOptions = cleanOptions(options);
746
746
  try {
747
747
  await build({
@@ -765,7 +765,7 @@ cli
765
765
  .command('optimize [root]', 'pre-bundle dependencies')
766
766
  .option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
767
767
  .action(async (root, options) => {
768
- const { optimizeDeps } = await import('./chunks/dep-88cc3a4f.js').then(function (n) { return n.C; });
768
+ const { optimizeDeps } = await import('./chunks/dep-0fc8e132.js').then(function (n) { return n.C; });
769
769
  try {
770
770
  const config = await resolveConfig({
771
771
  root,
@@ -788,7 +788,7 @@ cli
788
788
  .option('--https', `[boolean] use TLS + HTTP/2`)
789
789
  .option('--open [path]', `[boolean | string] open browser on startup`)
790
790
  .action(async (root, options) => {
791
- const { preview } = await import('./chunks/dep-88cc3a4f.js').then(function (n) { return n.F; });
791
+ const { preview } = await import('./chunks/dep-0fc8e132.js').then(function (n) { return n.F; });
792
792
  try {
793
793
  const server = await preview({
794
794
  root,
@@ -1,7 +1,7 @@
1
1
  import path, { resolve } from 'node:path';
2
2
  import { fileURLToPath } from 'node:url';
3
3
 
4
- var version = "3.0.6";
4
+ var version = "3.0.9";
5
5
 
6
6
  const VERSION = version;
7
7
  const DEFAULT_MAIN_FIELDS = [
@@ -894,7 +894,7 @@ export declare namespace HttpProxy {
894
894
  * Used for proxying regular HTTP(S) requests
895
895
  * @param req - Client request.
896
896
  * @param res - Client response.
897
- * @param options - Additionnal options.
897
+ * @param options - Additional options.
898
898
  */
899
899
  web(
900
900
  req: http.IncomingMessage,
@@ -1088,7 +1088,9 @@ export declare namespace HttpProxy {
1088
1088
 
1089
1089
  export declare interface ImportGlobEagerFunction {
1090
1090
  /**
1091
- * 1. No generic provided, infer the type from `as`
1091
+ * Eagerly import a list of files with a glob pattern.
1092
+ *
1093
+ * Overload 1: No generic provided, infer the type from `as`
1092
1094
  */
1093
1095
  <
1094
1096
  As extends string,
@@ -1098,7 +1100,9 @@ export declare interface ImportGlobEagerFunction {
1098
1100
  options?: Omit<ImportGlobOptions<boolean, As>, 'eager'>
1099
1101
  ): Record<string, T>
1100
1102
  /**
1101
- * 2. Module generic provided
1103
+ * Eagerly import a list of files with a glob pattern.
1104
+ *
1105
+ * Overload 2: Module generic provided
1102
1106
  */
1103
1107
  <M>(
1104
1108
  glob: string | string[],
@@ -1108,7 +1112,9 @@ export declare interface ImportGlobEagerFunction {
1108
1112
 
1109
1113
  export declare interface ImportGlobFunction {
1110
1114
  /**
1111
- * 1. No generic provided, infer the type from `eager` and `as`
1115
+ * Import a list of files with a glob pattern.
1116
+ *
1117
+ * Overload 1: No generic provided, infer the type from `eager` and `as`
1112
1118
  */
1113
1119
  <
1114
1120
  Eager extends boolean,
@@ -1121,14 +1127,18 @@ export declare interface ImportGlobFunction {
1121
1127
  ? Record<string, T>
1122
1128
  : Record<string, () => Promise<T>>
1123
1129
  /**
1124
- * 2. Module generic provided, infer the type from `eager: false`
1130
+ * Import a list of files with a glob pattern.
1131
+ *
1132
+ * Overload 2: Module generic provided, infer the type from `eager: false`
1125
1133
  */
1126
1134
  <M>(
1127
1135
  glob: string | string[],
1128
1136
  options?: ImportGlobOptions<false, string>
1129
1137
  ): Record<string, () => Promise<M>>
1130
1138
  /**
1131
- * 3. Module generic provided, infer the type from `eager: true`
1139
+ * Import a list of files with a glob pattern.
1140
+ *
1141
+ * Overload 3: Module generic provided, infer the type from `eager: true`
1132
1142
  */
1133
1143
  <M>(
1134
1144
  glob: string | string[],
@@ -3254,7 +3264,7 @@ export declare interface WebSocketServer {
3254
3264
  */
3255
3265
  clients: Set<WebSocketClient>;
3256
3266
  /**
3257
- * Boardcast events to all clients
3267
+ * Broadcast events to all clients
3258
3268
  */
3259
3269
  send(payload: HMRPayload): void;
3260
3270
  /**
@@ -1,4 +1,4 @@
1
- export { b as build, k as createFilter, u as createLogger, c as createServer, d as defineConfig, f as formatPostcssSourceMap, h as getDepOptimizationConfig, i as isDepsOptimizerEnabled, l as loadConfigFromFile, w as loadEnv, j as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, p as preview, g as resolveBaseUrl, e as resolveConfig, x as resolveEnvPrefix, a as resolvePackageData, r as resolvePackageEntry, v as searchForWorkspaceRoot, q as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-88cc3a4f.js';
1
+ export { b as build, k as createFilter, u as createLogger, c as createServer, d as defineConfig, f as formatPostcssSourceMap, h as getDepOptimizationConfig, i as isDepsOptimizerEnabled, l as loadConfigFromFile, w as loadEnv, j as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, p as preview, g as resolveBaseUrl, e as resolveConfig, x as resolveEnvPrefix, a as resolvePackageData, r as resolvePackageEntry, v as searchForWorkspaceRoot, q as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-0fc8e132.js';
2
2
  export { VERSION as version } from './constants.js';
3
3
  export { version as esbuildVersion } from 'esbuild';
4
4
  export { VERSION as rollupVersion } from 'rollup';
@@ -31,7 +31,7 @@ var require$$1__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$1$1);
31
31
  var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);
32
32
  var require$$2__default = /*#__PURE__*/_interopDefaultLegacy(require$$2);
33
33
 
34
- var version = "3.0.6";
34
+ var version = "3.0.9";
35
35
 
36
36
  const VERSION = version;
37
37
  const VITE_PACKAGE_DIR = path$3.resolve(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "3.0.6",
3
+ "version": "3.0.9",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",
@@ -70,7 +70,7 @@
70
70
  "@ampproject/remapping": "^2.2.0",
71
71
  "@babel/parser": "^7.18.11",
72
72
  "@babel/types": "^7.18.10",
73
- "@jridgewell/trace-mapping": "^0.3.14",
73
+ "@jridgewell/trace-mapping": "^0.3.15",
74
74
  "@rollup/plugin-alias": "^3.1.9",
75
75
  "@rollup/plugin-commonjs": "^22.0.2",
76
76
  "@rollup/plugin-dynamic-import-vars": "^1.4.4",
@@ -90,7 +90,7 @@
90
90
  "debug": "^4.3.4",
91
91
  "dotenv": "^14.3.2",
92
92
  "dotenv-expand": "^5.1.0",
93
- "es-module-lexer": "^0.10.5",
93
+ "es-module-lexer": "^1.0.3",
94
94
  "estree-walker": "^3.0.1",
95
95
  "etag": "^1.8.1",
96
96
  "fast-glob": "^3.2.11",
@@ -99,7 +99,7 @@
99
99
  "launch-editor-middleware": "^2.5.0",
100
100
  "magic-string": "^0.26.2",
101
101
  "micromatch": "^4.0.5",
102
- "mlly": "^0.5.7",
102
+ "mlly": "^0.5.12",
103
103
  "mrmime": "^1.0.1",
104
104
  "okie": "^1.0.1",
105
105
  "open": "^8.4.0",
@@ -101,7 +101,7 @@ function setupWebSocket(
101
101
  }
102
102
 
103
103
  console.log(`[vite] server connection lost. polling for restart...`)
104
- await waitForSuccessfulPing(hostAndPath)
104
+ await waitForSuccessfulPing(protocol, hostAndPath)
105
105
  location.reload()
106
106
  })
107
107
 
@@ -126,6 +126,7 @@ function cleanUrl(pathname: string): string {
126
126
  }
127
127
 
128
128
  let isFirstUpdate = true
129
+ const outdatedLinkTags = new WeakSet<HTMLLinkElement>()
129
130
 
130
131
  async function handleMessage(payload: HMRPayload) {
131
132
  switch (payload.type) {
@@ -166,7 +167,10 @@ async function handleMessage(payload: HMRPayload) {
166
167
  // URL for the include check.
167
168
  const el = Array.from(
168
169
  document.querySelectorAll<HTMLLinkElement>('link')
169
- ).find((e) => cleanUrl(e.href).includes(searchUrl))
170
+ ).find(
171
+ (e) =>
172
+ !outdatedLinkTags.has(e) && cleanUrl(e.href).includes(searchUrl)
173
+ )
170
174
  if (el) {
171
175
  const newPath = `${base}${searchUrl.slice(1)}${
172
176
  searchUrl.includes('?') ? '&' : '?'
@@ -182,6 +186,7 @@ async function handleMessage(payload: HMRPayload) {
182
186
  const removeOldEl = () => el.remove()
183
187
  newLinkTag.addEventListener('load', removeOldEl)
184
188
  newLinkTag.addEventListener('error', removeOldEl)
189
+ outdatedLinkTags.add(el)
185
190
  el.after(newLinkTag)
186
191
  }
187
192
  console.log(`[vite] css hot updated: ${searchUrl}`)
@@ -292,14 +297,22 @@ async function queueUpdate(p: Promise<(() => void) | undefined>) {
292
297
  }
293
298
  }
294
299
 
295
- async function waitForSuccessfulPing(hostAndPath: string, ms = 1000) {
300
+ async function waitForSuccessfulPing(
301
+ socketProtocol: string,
302
+ hostAndPath: string,
303
+ ms = 1000
304
+ ) {
305
+ const pingHostProtocol = socketProtocol === 'wss' ? 'https' : 'http'
306
+
296
307
  // eslint-disable-next-line no-constant-condition
297
308
  while (true) {
298
309
  try {
299
310
  // A fetch on a websocket URL will return a successful promise with status 400,
300
311
  // but will reject a networking error.
301
312
  // When running on middleware mode, it returns status 426, and an cors error happens if mode is not no-cors
302
- await fetch(`${location.protocol}//${hostAndPath}`, { mode: 'no-cors' })
313
+ await fetch(`${pingHostProtocol}://${hostAndPath}`, {
314
+ mode: 'no-cors'
315
+ })
303
316
  break
304
317
  } catch (e) {
305
318
  // wait ms before attempting to ping again
@@ -57,7 +57,7 @@ export namespace HttpProxy {
57
57
  * Used for proxying regular HTTP(S) requests
58
58
  * @param req - Client request.
59
59
  * @param res - Client response.
60
- * @param options - Additionnal options.
60
+ * @param options - Additional options.
61
61
  */
62
62
  web(
63
63
  req: http.IncomingMessage,
@@ -38,7 +38,9 @@ export interface KnownAsTypeMap {
38
38
 
39
39
  export interface ImportGlobFunction {
40
40
  /**
41
- * 1. No generic provided, infer the type from `eager` and `as`
41
+ * Import a list of files with a glob pattern.
42
+ *
43
+ * Overload 1: No generic provided, infer the type from `eager` and `as`
42
44
  */
43
45
  <
44
46
  Eager extends boolean,
@@ -51,14 +53,18 @@ export interface ImportGlobFunction {
51
53
  ? Record<string, T>
52
54
  : Record<string, () => Promise<T>>
53
55
  /**
54
- * 2. Module generic provided, infer the type from `eager: false`
56
+ * Import a list of files with a glob pattern.
57
+ *
58
+ * Overload 2: Module generic provided, infer the type from `eager: false`
55
59
  */
56
60
  <M>(
57
61
  glob: string | string[],
58
62
  options?: ImportGlobOptions<false, string>
59
63
  ): Record<string, () => Promise<M>>
60
64
  /**
61
- * 3. Module generic provided, infer the type from `eager: true`
65
+ * Import a list of files with a glob pattern.
66
+ *
67
+ * Overload 3: Module generic provided, infer the type from `eager: true`
62
68
  */
63
69
  <M>(
64
70
  glob: string | string[],
@@ -68,7 +74,9 @@ export interface ImportGlobFunction {
68
74
 
69
75
  export interface ImportGlobEagerFunction {
70
76
  /**
71
- * 1. No generic provided, infer the type from `as`
77
+ * Eagerly import a list of files with a glob pattern.
78
+ *
79
+ * Overload 1: No generic provided, infer the type from `as`
72
80
  */
73
81
  <
74
82
  As extends string,
@@ -78,7 +86,9 @@ export interface ImportGlobEagerFunction {
78
86
  options?: Omit<ImportGlobOptions<boolean, As>, 'eager'>
79
87
  ): Record<string, T>
80
88
  /**
81
- * 2. Module generic provided
89
+ * Eagerly import a list of files with a glob pattern.
90
+ *
91
+ * Overload 2: Module generic provided
82
92
  */
83
93
  <M>(
84
94
  glob: string | string[],