vite 2.8.6 → 2.9.0-beta.2

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.

@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var build = require('./dep-9c153816.js');
3
+ var index = require('./dep-6ae84d6b.js');
4
4
 
5
5
  function _mergeNamespaces(n, m) {
6
6
  for (var i = 0; i < m.length; i++) {
@@ -5642,9 +5642,9 @@ var compilerCore_esmBundler = {
5642
5642
  generateCodeFrame: generateCodeFrame
5643
5643
  };
5644
5644
 
5645
- var require$$0 = /*@__PURE__*/build.getAugmentedNamespace(compilerCore_esmBundler);
5645
+ var require$$0 = /*@__PURE__*/index.getAugmentedNamespace(compilerCore_esmBundler);
5646
5646
 
5647
- var require$$1 = /*@__PURE__*/build.getAugmentedNamespace(shared_esmBundler);
5647
+ var require$$1 = /*@__PURE__*/index.getAugmentedNamespace(shared_esmBundler);
5648
5648
 
5649
5649
  (function (exports) {
5650
5650
 
@@ -8747,7 +8747,7 @@ exports.parserOptions = parserOptions;
8747
8747
  exports.transformStyle = transformStyle;
8748
8748
  }(compilerDom_cjs$2));
8749
8749
 
8750
- var compilerDom_cjs = /*@__PURE__*/build.getDefaultExportFromCjs(compilerDom_cjs$2);
8750
+ var compilerDom_cjs = /*@__PURE__*/index.getDefaultExportFromCjs(compilerDom_cjs$2);
8751
8751
 
8752
8752
  var compilerDom_cjs$1 = /*#__PURE__*/_mergeNamespaces({
8753
8753
  __proto__: null,
@@ -1,12 +1,12 @@
1
1
  'use strict';
2
2
 
3
3
  var require$$0 = require('postcss');
4
- var build$2 = require('./dep-9c153816.js');
4
+ var index$1 = require('./dep-6ae84d6b.js');
5
5
  var path$2 = require('path');
6
6
  var require$$1 = require('crypto');
7
7
  var fs = require('fs');
8
8
  var require$$0$1 = require('util');
9
- var index$1 = require('./dep-2056ae8a.js');
9
+ var index$2 = require('./dep-2056ae8a.js');
10
10
 
11
11
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
12
12
 
@@ -181,7 +181,7 @@ var deburredLetters = {
181
181
  };
182
182
 
183
183
  /** Detect free variable `global` from Node.js. */
184
- var freeGlobal = typeof build$2.commonjsGlobal == 'object' && build$2.commonjsGlobal && build$2.commonjsGlobal.Object === Object && build$2.commonjsGlobal;
184
+ var freeGlobal = typeof index$1.commonjsGlobal == 'object' && index$1.commonjsGlobal && index$1.commonjsGlobal.Object === Object && index$1.commonjsGlobal;
185
185
 
186
186
  /** Detect free variable `self`. */
187
187
  var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
@@ -6001,7 +6001,7 @@ var src$3 = {
6001
6001
  };
6002
6002
 
6003
6003
  const selectorParser$1 = dist.exports;
6004
- const valueParser = index$1.lib;
6004
+ const valueParser = index$2.lib;
6005
6005
  const { extractICSS } = src$3;
6006
6006
 
6007
6007
  const isSpacing = (node) => node.type === "combinator" && node.value === " ";
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-9c153816.js');
4
+ var index = require('./chunks/dep-6ae84d6b.js');
5
5
  var perf_hooks = require('perf_hooks');
6
6
  require('fs');
7
7
  require('path');
@@ -683,7 +683,7 @@ cli
683
683
  .action(async (root, options) => {
684
684
  // output structure is preserved even after bundling so require()
685
685
  // is ok here
686
- const { createServer } = await Promise.resolve().then(function () { return require('./chunks/dep-9c153816.js'); }).then(function (n) { return n.index$1; });
686
+ const { createServer } = await Promise.resolve().then(function () { return require('./chunks/dep-6ae84d6b.js'); }).then(function (n) { return n.index$1; });
687
687
  try {
688
688
  const server = await createServer({
689
689
  root,
@@ -699,8 +699,8 @@ cli
699
699
  }
700
700
  await server.listen();
701
701
  const info = server.config.logger.info;
702
- info(build.colors.cyan(`\n vite v${require('vite/package.json').version}`) +
703
- build.colors.green(` dev server running at:\n`), {
702
+ info(index.colors.cyan(`\n vite v${require('vite/package.json').version}`) +
703
+ index.colors.green(` dev server running at:\n`), {
704
704
  clear: !server.config.logger.hasWarned
705
705
  });
706
706
  server.printUrls();
@@ -708,11 +708,11 @@ cli
708
708
  if (global.__vite_start_time) {
709
709
  // @ts-ignore
710
710
  const startupDuration = perf_hooks.performance.now() - global.__vite_start_time;
711
- info(`\n ${build.colors.cyan(`ready in ${Math.ceil(startupDuration)}ms.`)}\n`);
711
+ info(`\n ${index.colors.cyan(`ready in ${Math.ceil(startupDuration)}ms.`)}\n`);
712
712
  }
713
713
  }
714
714
  catch (e) {
715
- build.createLogger(options.logLevel).error(build.colors.red(`error when starting dev server:\n${e.stack}`), { error: e });
715
+ index.createLogger(options.logLevel).error(index.colors.red(`error when starting dev server:\n${e.stack}`), { error: e });
716
716
  process.exit(1);
717
717
  }
718
718
  });
@@ -732,10 +732,10 @@ cli
732
732
  .option('--emptyOutDir', `[boolean] force empty outDir when it's outside of root`)
733
733
  .option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
734
734
  .action(async (root, options) => {
735
- const { build: build$1 } = await Promise.resolve().then(function () { return require('./chunks/dep-9c153816.js'); }).then(function (n) { return n.build$1; });
735
+ const { build } = await Promise.resolve().then(function () { return require('./chunks/dep-6ae84d6b.js'); }).then(function (n) { return n.build$1; });
736
736
  const buildOptions = cleanOptions(options);
737
737
  try {
738
- await build$1({
738
+ await build({
739
739
  root,
740
740
  base: options.base,
741
741
  mode: options.mode,
@@ -746,7 +746,7 @@ cli
746
746
  });
747
747
  }
748
748
  catch (e) {
749
- build.createLogger(options.logLevel).error(build.colors.red(`error during build:\n${e.stack}`), { error: e });
749
+ index.createLogger(options.logLevel).error(index.colors.red(`error during build:\n${e.stack}`), { error: e });
750
750
  process.exit(1);
751
751
  }
752
752
  });
@@ -755,9 +755,9 @@ cli
755
755
  .command('optimize [root]', 'pre-bundle dependencies')
756
756
  .option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
757
757
  .action(async (root, options) => {
758
- const { optimizeDeps } = await Promise.resolve().then(function () { return require('./chunks/dep-9c153816.js'); }).then(function (n) { return n.index; });
758
+ const { optimizeDeps } = await Promise.resolve().then(function () { return require('./chunks/dep-6ae84d6b.js'); }).then(function (n) { return n.index; });
759
759
  try {
760
- const config = await build.resolveConfig({
760
+ const config = await index.resolveConfig({
761
761
  root,
762
762
  base: options.base,
763
763
  configFile: options.config,
@@ -766,7 +766,7 @@ cli
766
766
  await optimizeDeps(config, options.force, true);
767
767
  }
768
768
  catch (e) {
769
- build.createLogger(options.logLevel).error(build.colors.red(`error when optimizing deps:\n${e.stack}`), { error: e });
769
+ index.createLogger(options.logLevel).error(index.colors.red(`error when optimizing deps:\n${e.stack}`), { error: e });
770
770
  process.exit(1);
771
771
  }
772
772
  });
@@ -778,7 +778,7 @@ cli
778
778
  .option('--https', `[boolean] use TLS + HTTP/2`)
779
779
  .option('--open [path]', `[boolean | string] open browser on startup`)
780
780
  .action(async (root, options) => {
781
- const { preview } = await Promise.resolve().then(function () { return require('./chunks/dep-9c153816.js'); }).then(function (n) { return n.preview$1; });
781
+ const { preview } = await Promise.resolve().then(function () { return require('./chunks/dep-6ae84d6b.js'); }).then(function (n) { return n.preview$1; });
782
782
  try {
783
783
  const server = await preview({
784
784
  root,
@@ -797,7 +797,7 @@ cli
797
797
  server.printUrls();
798
798
  }
799
799
  catch (e) {
800
- build.createLogger(options.logLevel).error(build.colors.red(`error when starting preview server:\n${e.stack}`), { error: e });
800
+ index.createLogger(options.logLevel).error(index.colors.red(`error when starting preview server:\n${e.stack}`), { error: e });
801
801
  process.exit(1);
802
802
  }
803
803
  });
@@ -11,6 +11,7 @@ import { TransformOptions as EsbuildTransformOptions } from 'esbuild';
11
11
  import { EventEmitter } from 'events';
12
12
  import * as events from 'events';
13
13
  import type * as fs from 'fs';
14
+ import type { GetManualChunk } from 'rollup';
14
15
  import * as http from 'http';
15
16
  import type { IncomingMessage } from 'http';
16
17
  import type { InputOptions } from 'rollup';
@@ -267,6 +268,11 @@ export declare interface BuildOptions {
267
268
  watch?: WatcherOptions | null;
268
269
  }
269
270
 
271
+ export declare interface ChunkMetadata {
272
+ importedAssets: Set<string>;
273
+ importedCss: Set<string>;
274
+ }
275
+
270
276
  export declare interface CommonServerOptions {
271
277
  /**
272
278
  * Specify server port. Note if the port is already being used, Vite will
@@ -506,11 +512,19 @@ export declare interface DepOptimizationMetadata {
506
512
  * optimized deps.
507
513
  */
508
514
  browserHash: string;
509
- optimized: Record<string, {
510
- file: string;
511
- src: string;
512
- needsInterop: boolean;
513
- }>;
515
+ /**
516
+ * Metadata for each already optimized dependency
517
+ */
518
+ optimized: Record<string, OptimizedDepInfo>;
519
+ /**
520
+ * Metadata for each newly discovered dependency after processing
521
+ */
522
+ discovered: Record<string, OptimizedDepInfo>;
523
+ /**
524
+ * During optimization, ids can still be resolved to their final location
525
+ * but the bundles may not yet be saved to disk
526
+ */
527
+ processing: Promise<DepOptimizationResult | undefined>;
514
528
  }
515
529
 
516
530
  export declare interface DepOptimizationOptions {
@@ -552,6 +566,31 @@ export declare interface DepOptimizationOptions {
552
566
  * @deprecated use `esbuildOptions.keepNames`
553
567
  */
554
568
  keepNames?: boolean;
569
+ /**
570
+ * List of file extensions that can be optimized. A corresponding esbuild
571
+ * plugin must exist to handle the specific extension.
572
+ *
573
+ * By default, Vite can optimize `.mjs`, `.js`, and `.ts` files. This option
574
+ * allows specifying additional extensions.
575
+ *
576
+ * @experimental
577
+ */
578
+ extensions?: string[];
579
+ }
580
+
581
+ export declare interface DepOptimizationProcessing {
582
+ promise: Promise<DepOptimizationResult | undefined>;
583
+ resolve: (result?: DepOptimizationResult) => void;
584
+ }
585
+
586
+ export declare interface DepOptimizationResult {
587
+ /**
588
+ * After a re-optimization, the internal bundled chunks may change
589
+ * and a full page reload is required if that is the case
590
+ * If the files are stable, we can avoid the reload that is expensive
591
+ * for large applications
592
+ */
593
+ alteredFiles: boolean;
555
594
  }
556
595
 
557
596
  export declare interface ErrorPayload {
@@ -701,7 +740,7 @@ export declare interface HmrContext {
701
740
  export declare interface HmrOptions {
702
741
  protocol?: string;
703
742
  host?: string;
704
- port?: number;
743
+ port?: number | false;
705
744
  clientPort?: number;
706
745
  path?: string;
707
746
  timeout?: number;
@@ -1091,7 +1130,7 @@ export declare class ModuleGraph {
1091
1130
  getModuleById(id: string): ModuleNode | undefined;
1092
1131
  getModulesByFile(file: string): Set<ModuleNode> | undefined;
1093
1132
  onFileChange(file: string): void;
1094
- invalidateModule(mod: ModuleNode, seen?: Set<ModuleNode>): void;
1133
+ invalidateModule(mod: ModuleNode, seen?: Set<ModuleNode>, timestamp?: number): void;
1095
1134
  invalidateAll(): void;
1096
1135
  /**
1097
1136
  * Update the module graph based on a module's updated imports information
@@ -1125,13 +1164,30 @@ export declare class ModuleNode {
1125
1164
  ssrTransformResult: TransformResult | null;
1126
1165
  ssrModule: Record<string, any> | null;
1127
1166
  lastHMRTimestamp: number;
1167
+ lastInvalidationTimestamp: number;
1128
1168
  constructor(url: string);
1129
1169
  }
1130
1170
 
1131
1171
  export declare function normalizePath(id: string): string;
1132
1172
 
1133
- export declare function optimizeDeps(config: ResolvedConfig, force?: boolean | undefined, asCommand?: boolean, newDeps?: Record<string, string>, // missing imports encountered after server has started
1134
- ssr?: boolean): Promise<DepOptimizationMetadata | null>;
1173
+ export declare interface OptimizedDepInfo {
1174
+ file: string;
1175
+ src: string;
1176
+ needsInterop?: boolean;
1177
+ browserHash?: string;
1178
+ fileHash?: string;
1179
+ /**
1180
+ * During optimization, ids can still be resolved to their final location
1181
+ * but the bundles may not yet be saved to disk
1182
+ */
1183
+ processing: Promise<DepOptimizationResult | undefined>;
1184
+ }
1185
+
1186
+ /**
1187
+ * Used by Vite CLI when running `vite optimize`
1188
+ */
1189
+ export declare function optimizeDeps(config: ResolvedConfig, force?: boolean | undefined, asCommand?: boolean, newDeps?: Record<string, OptimizedDepInfo>, // missing imports encountered after server has started
1190
+ ssr?: boolean): Promise<DepOptimizationMetadata>;
1135
1191
 
1136
1192
  /** Cache for package.json resolution and package.json contents */
1137
1193
  export declare type PackageCache = Map<string, PackageData>;
@@ -1666,6 +1722,18 @@ export declare interface ServerOptions extends CommonServerOptions {
1666
1722
 
1667
1723
  export declare function sortUserPlugins(plugins: (Plugin | Plugin[])[] | undefined): [Plugin[], Plugin[], Plugin[]];
1668
1724
 
1725
+ export declare function splitVendorChunk(options?: {
1726
+ cache?: SplitVendorChunkCache;
1727
+ }): GetManualChunk;
1728
+
1729
+ export declare class SplitVendorChunkCache {
1730
+ cache: Map<string, boolean>;
1731
+ constructor();
1732
+ reset(): void;
1733
+ }
1734
+
1735
+ export declare function splitVendorChunkPlugin(): Plugin;
1736
+
1669
1737
  export declare interface SSROptions {
1670
1738
  external?: string[];
1671
1739
  noExternal?: string | RegExp | (string | RegExp)[] | true;
@@ -2093,7 +2161,11 @@ export declare interface ViteDevServer {
2093
2161
  fixStacktrace?: boolean;
2094
2162
  }): Promise<Record<string, any>>;
2095
2163
  /**
2096
- * Fix ssr error stacktrace
2164
+ * Returns a fixed version of the given stack
2165
+ */
2166
+ ssrRewriteStacktrace(stack: string): string;
2167
+ /**
2168
+ * Mutates the given SSR error by rewriting the stacktrace
2097
2169
  */
2098
2170
  ssrFixStacktrace(e: Error): void;
2099
2171
  /**
@@ -2119,9 +2191,7 @@ export declare interface ViteDevServer {
2119
2191
  /* Excluded from this release type: _globImporters */
2120
2192
  /* Excluded from this release type: _restartPromise */
2121
2193
  /* Excluded from this release type: _forceOptimizeOnRestart */
2122
- /* Excluded from this release type: _isRunningOptimizer */
2123
2194
  /* Excluded from this release type: _registerMissingImport */
2124
- /* Excluded from this release type: _pendingReload */
2125
2195
  /* Excluded from this release type: _pendingRequests */
2126
2196
  }
2127
2197
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var build = require('./chunks/dep-9c153816.js');
5
+ var index = require('./chunks/dep-6ae84d6b.js');
6
6
  require('fs');
7
7
  require('path');
8
8
  require('tty');
@@ -28,24 +28,129 @@ require('child_process');
28
28
  require('worker_threads');
29
29
  require('readline');
30
30
 
31
+ // Use splitVendorChunkPlugin() to get the same manualChunks strategy as Vite 2.7
32
+ // We don't recommend using this strategy as a general solution moving forward
33
+ // splitVendorChunk is a simple index/vendor strategy that was used in Vite
34
+ // until v2.8. It is exposed to let people continue to use it in case it was
35
+ // working well for their setups.
36
+ // The cache needs to be reset on buildStart for watch mode to work correctly
37
+ // Don't use this manualChunks strategy for ssr, lib mode, and 'umd' or 'iife'
38
+ class SplitVendorChunkCache {
39
+ constructor() {
40
+ this.cache = new Map();
41
+ }
42
+ reset() {
43
+ this.cache = new Map();
44
+ }
45
+ }
46
+ function splitVendorChunk(options = {}) {
47
+ var _a;
48
+ const cache = (_a = options.cache) !== null && _a !== void 0 ? _a : new SplitVendorChunkCache();
49
+ return (id, { getModuleInfo }) => {
50
+ if (id.includes('node_modules') &&
51
+ !index.isCSSRequest(id) &&
52
+ staticImportedByEntry(id, getModuleInfo, cache.cache)) {
53
+ return 'vendor';
54
+ }
55
+ };
56
+ }
57
+ function staticImportedByEntry(id, getModuleInfo, cache, importStack = []) {
58
+ if (cache.has(id)) {
59
+ return cache.get(id);
60
+ }
61
+ if (importStack.includes(id)) {
62
+ // circular deps!
63
+ cache.set(id, false);
64
+ return false;
65
+ }
66
+ const mod = getModuleInfo(id);
67
+ if (!mod) {
68
+ cache.set(id, false);
69
+ return false;
70
+ }
71
+ if (mod.isEntry) {
72
+ cache.set(id, true);
73
+ return true;
74
+ }
75
+ const someImporterIs = mod.importers.some((importer) => staticImportedByEntry(importer, getModuleInfo, cache, importStack.concat(id)));
76
+ cache.set(id, someImporterIs);
77
+ return someImporterIs;
78
+ }
79
+ function splitVendorChunkPlugin() {
80
+ const caches = [];
81
+ function createSplitVendorChunk(output, config) {
82
+ var _a;
83
+ const cache = new SplitVendorChunkCache();
84
+ caches.push(cache);
85
+ const build = (_a = config.build) !== null && _a !== void 0 ? _a : {};
86
+ const format = output === null || output === void 0 ? void 0 : output.format;
87
+ if (!build.ssr && !build.lib && format !== 'umd' && format !== 'iife') {
88
+ return splitVendorChunk({ cache });
89
+ }
90
+ }
91
+ return {
92
+ name: 'vite:split-vendor-chunk',
93
+ config(config) {
94
+ var _a, _b;
95
+ let outputs = (_b = (_a = config === null || config === void 0 ? void 0 : config.build) === null || _a === void 0 ? void 0 : _a.rollupOptions) === null || _b === void 0 ? void 0 : _b.output;
96
+ if (outputs) {
97
+ outputs = Array.isArray(outputs) ? outputs : [outputs];
98
+ for (const output of outputs) {
99
+ const viteManualChunks = createSplitVendorChunk(output, config);
100
+ if (viteManualChunks) {
101
+ if (output.manualChunks) {
102
+ if (typeof output.manualChunks === 'function') {
103
+ const userManualChunks = output.manualChunks;
104
+ output.manualChunks = (id, api) => {
105
+ var _a;
106
+ return (_a = userManualChunks(id, api)) !== null && _a !== void 0 ? _a : viteManualChunks(id, api);
107
+ };
108
+ }
109
+ // else, leave the object form of manualChunks untouched, as
110
+ // we can't safely replicate rollup handling.
111
+ }
112
+ else {
113
+ output.manualChunks = viteManualChunks;
114
+ }
115
+ }
116
+ }
117
+ }
118
+ else {
119
+ return {
120
+ build: {
121
+ rollupOptions: {
122
+ output: {
123
+ manualChunks: createSplitVendorChunk({}, config)
124
+ }
125
+ }
126
+ }
127
+ };
128
+ }
129
+ },
130
+ buildStart() {
131
+ caches.forEach((cache) => cache.reset());
132
+ }
133
+ };
134
+ }
31
135
 
32
-
33
- exports.build = build.build;
34
- exports.createLogger = build.createLogger;
35
- exports.createServer = build.createServer;
36
- exports.defineConfig = build.defineConfig;
37
- exports.loadConfigFromFile = build.loadConfigFromFile;
38
- exports.loadEnv = build.loadEnv;
39
- exports.mergeConfig = build.mergeConfig;
40
- exports.normalizePath = build.normalizePath;
41
- exports.optimizeDeps = build.optimizeDeps;
42
- exports.preview = build.preview;
43
- exports.printHttpServerUrls = build.printHttpServerUrls;
44
- exports.resolveConfig = build.resolveConfig;
45
- exports.resolveEnvPrefix = build.resolveEnvPrefix;
46
- exports.resolvePackageData = build.resolvePackageData;
47
- exports.resolvePackageEntry = build.resolvePackageEntry;
48
- exports.searchForWorkspaceRoot = build.searchForWorkspaceRoot;
49
- exports.send = build.send;
50
- exports.sortUserPlugins = build.sortUserPlugins;
51
- exports.transformWithEsbuild = build.transformWithEsbuild;
136
+ exports.build = index.build;
137
+ exports.createLogger = index.createLogger;
138
+ exports.createServer = index.createServer;
139
+ exports.defineConfig = index.defineConfig;
140
+ exports.loadConfigFromFile = index.loadConfigFromFile;
141
+ exports.loadEnv = index.loadEnv;
142
+ exports.mergeConfig = index.mergeConfig;
143
+ exports.normalizePath = index.normalizePath;
144
+ exports.optimizeDeps = index.optimizeDeps;
145
+ exports.preview = index.preview;
146
+ exports.printHttpServerUrls = index.printHttpServerUrls;
147
+ exports.resolveConfig = index.resolveConfig;
148
+ exports.resolveEnvPrefix = index.resolveEnvPrefix;
149
+ exports.resolvePackageData = index.resolvePackageData;
150
+ exports.resolvePackageEntry = index.resolvePackageEntry;
151
+ exports.searchForWorkspaceRoot = index.searchForWorkspaceRoot;
152
+ exports.send = index.send;
153
+ exports.sortUserPlugins = index.sortUserPlugins;
154
+ exports.transformWithEsbuild = index.transformWithEsbuild;
155
+ exports.splitVendorChunk = splitVendorChunk;
156
+ exports.splitVendorChunkPlugin = splitVendorChunkPlugin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "2.8.6",
3
+ "version": "2.9.0-beta.2",
4
4
  "license": "MIT",
5
5
  "author": "Evan You",
6
6
  "description": "Native-ESM powered web dev build tool",
@@ -55,6 +55,7 @@
55
55
  "@ampproject/remapping": "^2.1.0",
56
56
  "@babel/parser": "^7.17.0",
57
57
  "@babel/types": "^7.17.0",
58
+ "@jridgewell/trace-mapping": "^0.3.2",
58
59
  "@rollup/plugin-alias": "^3.1.9",
59
60
  "@rollup/plugin-commonjs": "^21.0.1",
60
61
  "@rollup/plugin-dynamic-import-vars": "^1.4.2",
@@ -79,7 +80,6 @@
79
80
  "acorn": "^8.7.0",
80
81
  "cac": "6.7.9",
81
82
  "chokidar": "^3.5.3",
82
- "compression": "^1.7.4",
83
83
  "connect": "^3.7.0",
84
84
  "connect-history-api-fallback": "^1.6.0",
85
85
  "convert-source-map": "^1.8.0",
@@ -104,16 +104,15 @@
104
104
  "periscopic": "^2.0.3",
105
105
  "picocolors": "^1.0.0",
106
106
  "postcss-import": "^14.0.2",
107
- "postcss-load-config": "^3.1.1",
107
+ "postcss-load-config": "^3.1.3",
108
108
  "postcss-modules": "^4.3.0",
109
109
  "resolve.exports": "^1.1.0",
110
110
  "rollup-plugin-license": "^2.6.1",
111
111
  "sirv": "^2.0.2",
112
- "source-map-js": "^1.0.2",
113
112
  "source-map-support": "^0.5.21",
114
113
  "strip-ansi": "^6.0.1",
115
114
  "terser": "^5.10.0",
116
- "tsconfck": "1.1.2",
115
+ "tsconfck": "^1.2.0",
117
116
  "tslib": "^2.3.1",
118
117
  "types": "link:./types",
119
118
  "ws": "^8.5.0"
@@ -15,7 +15,7 @@ import '@vite/env'
15
15
  declare const __BASE__: string
16
16
  declare const __HMR_PROTOCOL__: string
17
17
  declare const __HMR_HOSTNAME__: string
18
- declare const __HMR_PORT__: string
18
+ declare const __HMR_PORT__: string | false
19
19
  declare const __HMR_TIMEOUT__: number
20
20
  declare const __HMR_ENABLE_OVERLAY__: boolean
21
21
 
@@ -24,7 +24,10 @@ console.log('[vite] connecting...')
24
24
  // use server configuration, then fallback to inference
25
25
  const socketProtocol =
26
26
  __HMR_PROTOCOL__ || (location.protocol === 'https:' ? 'wss' : 'ws')
27
- const socketHost = `${__HMR_HOSTNAME__ || location.hostname}:${__HMR_PORT__}`
27
+ const socketHost = __HMR_PORT__
28
+ ? `${__HMR_HOSTNAME__ || location.hostname}:${__HMR_PORT__}`
29
+ : `${__HMR_HOSTNAME__ || location.hostname}`
30
+
28
31
  const socket = new WebSocket(`${socketProtocol}://${socketHost}`, 'vite-hmr')
29
32
  const base = __BASE__ || '/'
30
33
 
@@ -214,9 +217,14 @@ async function waitForSuccessfulPing(ms = 1000) {
214
217
  // eslint-disable-next-line no-constant-condition
215
218
  while (true) {
216
219
  try {
217
- await fetch(`${base}__vite_ping`)
218
- break
220
+ const pingResponse = await fetch(`${base}__vite_ping`)
221
+
222
+ // success - 2xx status code
223
+ if (pingResponse.ok) break
224
+ // failure - non-2xx status code
225
+ else throw new Error()
219
226
  } catch (e) {
227
+ // wait ms before attempting to ping again
220
228
  await new Promise((resolve) => setTimeout(resolve, ms))
221
229
  }
222
230
  }
@@ -4,10 +4,14 @@
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 {
7
+ // Duplicate of import('../src/node/importGlob').GlobOptions in order to
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 GlobOptions {
11
+ as?: string
12
+ /**
13
+ * @deprecated
14
+ */
11
15
  assert?: {
12
16
  type: string
13
17
  }
@@ -61,12 +65,12 @@ interface ImportMeta {
61
65
 
62
66
  glob<Module = { [key: string]: any }>(
63
67
  pattern: string,
64
- options?: AssertOptions
68
+ options?: GlobOptions
65
69
  ): Record<string, () => Promise<Module>>
66
70
 
67
71
  globEager<Module = { [key: string]: any }>(
68
72
  pattern: string,
69
- options?: AssertOptions
73
+ options?: GlobOptions
70
74
  ): Record<string, Module>
71
75
  }
72
76
 
package/types/shims.d.ts CHANGED
@@ -93,11 +93,6 @@ declare module 'micromatch' {
93
93
  ): boolean
94
94
  }
95
95
 
96
- declare module 'compression' {
97
- function compression(): any
98
- export default compression
99
- }
100
-
101
96
  // LESS' types somewhat references this which doesn't make sense in Node,
102
97
  // so we have to shim it
103
98
  declare interface HTMLLinkElement {}