vite 2.9.0-beta.6 → 2.9.0-beta.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.
Potentially problematic release.
This version of vite might be problematic. Click here for more details.
- package/dist/client/client.mjs +13 -1
- package/dist/client/client.mjs.map +1 -1
- package/dist/node/chunks/{dep-b1024ee7.js → dep-051d3e69.js} +1 -1
- package/dist/node/chunks/{dep-00d6c1ad.js → dep-368120f8.js} +2 -2
- package/dist/node/chunks/{dep-7a3b37e3.js → dep-f5b7cdd7.js} +775 -533
- package/dist/node/chunks/{dep-5ae06c1f.js → dep-f61a3114.js} +1 -1
- package/dist/node/cli.js +6 -6
- package/dist/node/index.d.ts +77 -20
- package/dist/node/index.js +2 -2
- package/package.json +2 -2
- package/src/client/client.ts +15 -1
- package/types/importMeta.d.ts +2 -0
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 index = require('./chunks/dep-
|
|
4
|
+
var index = require('./chunks/dep-f5b7cdd7.js');
|
|
5
5
|
var perf_hooks = require('perf_hooks');
|
|
6
6
|
require('fs');
|
|
7
7
|
require('path');
|
|
@@ -19,9 +19,9 @@ require('zlib');
|
|
|
19
19
|
require('crypto');
|
|
20
20
|
require('tls');
|
|
21
21
|
require('assert');
|
|
22
|
+
require('esbuild');
|
|
22
23
|
require('buffer');
|
|
23
24
|
require('querystring');
|
|
24
|
-
require('esbuild');
|
|
25
25
|
require('child_process');
|
|
26
26
|
require('worker_threads');
|
|
27
27
|
require('readline');
|
|
@@ -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-
|
|
686
|
+
const { createServer } = await Promise.resolve().then(function () { return require('./chunks/dep-f5b7cdd7.js'); }).then(function (n) { return n.index$1; });
|
|
687
687
|
try {
|
|
688
688
|
const server = await createServer({
|
|
689
689
|
root,
|
|
@@ -732,7 +732,7 @@ 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 } = await Promise.resolve().then(function () { return require('./chunks/dep-
|
|
735
|
+
const { build } = await Promise.resolve().then(function () { return require('./chunks/dep-f5b7cdd7.js'); }).then(function (n) { return n.build$1; });
|
|
736
736
|
const buildOptions = cleanOptions(options);
|
|
737
737
|
try {
|
|
738
738
|
await build({
|
|
@@ -755,7 +755,7 @@ 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-
|
|
758
|
+
const { optimizeDeps } = await Promise.resolve().then(function () { return require('./chunks/dep-f5b7cdd7.js'); }).then(function (n) { return n.index; });
|
|
759
759
|
try {
|
|
760
760
|
const config = await index.resolveConfig({
|
|
761
761
|
root,
|
|
@@ -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-
|
|
781
|
+
const { preview } = await Promise.resolve().then(function () { return require('./chunks/dep-f5b7cdd7.js'); }).then(function (n) { return n.preview$1; });
|
|
782
782
|
try {
|
|
783
783
|
const server = await preview({
|
|
784
784
|
root,
|
package/dist/node/index.d.ts
CHANGED
|
@@ -35,8 +35,8 @@ import type { RollupOutput } from 'rollup';
|
|
|
35
35
|
import type { RollupWatcher } from 'rollup';
|
|
36
36
|
import type { SecureContextOptions } from 'tls';
|
|
37
37
|
import type { Server } from 'http';
|
|
38
|
-
import type { Server as Server_2 } from '
|
|
39
|
-
import type { Server as Server_3 } from '
|
|
38
|
+
import type { Server as Server_2 } from 'net';
|
|
39
|
+
import type { Server as Server_3 } from 'https';
|
|
40
40
|
import type { ServerOptions as ServerOptions_2 } from 'https';
|
|
41
41
|
import type { ServerResponse } from 'http';
|
|
42
42
|
import type { SourceDescription } from 'rollup';
|
|
@@ -48,6 +48,8 @@ import type { TransformResult as TransformResult_3 } from 'rollup';
|
|
|
48
48
|
import type * as url from 'url';
|
|
49
49
|
import type { URL as URL_2 } from 'url';
|
|
50
50
|
import type { WatcherOptions } from 'rollup';
|
|
51
|
+
import type { WebSocket as WebSocket_2 } from 'ws';
|
|
52
|
+
import { WebSocketServer as WebSocketServer_2 } from 'ws';
|
|
51
53
|
import type { ZlibOptions } from 'zlib';
|
|
52
54
|
|
|
53
55
|
export declare interface Alias {
|
|
@@ -485,6 +487,12 @@ export declare interface CSSOptions {
|
|
|
485
487
|
postcss?: string | (Postcss.ProcessOptions & {
|
|
486
488
|
plugins?: Postcss.Plugin[];
|
|
487
489
|
});
|
|
490
|
+
/**
|
|
491
|
+
* Enables css sourcemaps during dev
|
|
492
|
+
* @default false
|
|
493
|
+
* @experimental
|
|
494
|
+
*/
|
|
495
|
+
devSourcemap?: boolean;
|
|
488
496
|
}
|
|
489
497
|
|
|
490
498
|
export declare interface CustomPayload {
|
|
@@ -525,6 +533,10 @@ export declare interface DepOptimizationMetadata {
|
|
|
525
533
|
* Metadata for each newly discovered dependency after processing
|
|
526
534
|
*/
|
|
527
535
|
discovered: Record<string, OptimizedDepInfo>;
|
|
536
|
+
/**
|
|
537
|
+
* OptimizedDepInfo list
|
|
538
|
+
*/
|
|
539
|
+
depInfoList: OptimizedDepInfo[];
|
|
528
540
|
}
|
|
529
541
|
|
|
530
542
|
export declare interface DepOptimizationOptions {
|
|
@@ -584,17 +596,11 @@ export declare interface DepOptimizationProcessing {
|
|
|
584
596
|
}
|
|
585
597
|
|
|
586
598
|
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;
|
|
599
|
+
metadata: DepOptimizationMetadata;
|
|
594
600
|
/**
|
|
595
601
|
* When doing a re-run, if there are newly discovered dependendencies
|
|
596
|
-
* the page reload will be delayed until the next rerun so
|
|
597
|
-
*
|
|
602
|
+
* the page reload will be delayed until the next rerun so we need
|
|
603
|
+
* to be able to discard the result
|
|
598
604
|
*/
|
|
599
605
|
commit: () => void;
|
|
600
606
|
cancel: () => void;
|
|
@@ -1049,6 +1055,7 @@ export declare interface InternalResolveOptions extends ResolveOptions {
|
|
|
1049
1055
|
isRequire?: boolean;
|
|
1050
1056
|
isFromTsImporter?: boolean;
|
|
1051
1057
|
tryEsmOnly?: boolean;
|
|
1058
|
+
scan?: boolean;
|
|
1052
1059
|
}
|
|
1053
1060
|
|
|
1054
1061
|
export declare interface JsonOptions {
|
|
@@ -1180,8 +1187,9 @@ export declare class ModuleNode {
|
|
|
1180
1187
|
export declare function normalizePath(id: string): string;
|
|
1181
1188
|
|
|
1182
1189
|
export declare interface OptimizedDepInfo {
|
|
1190
|
+
id: string;
|
|
1183
1191
|
file: string;
|
|
1184
|
-
src
|
|
1192
|
+
src?: string;
|
|
1185
1193
|
needsInterop?: boolean;
|
|
1186
1194
|
browserHash?: string;
|
|
1187
1195
|
fileHash?: string;
|
|
@@ -1192,11 +1200,16 @@ export declare interface OptimizedDepInfo {
|
|
|
1192
1200
|
processing?: Promise<void>;
|
|
1193
1201
|
}
|
|
1194
1202
|
|
|
1203
|
+
export declare interface OptimizedDeps {
|
|
1204
|
+
metadata: DepOptimizationMetadata;
|
|
1205
|
+
scanProcessing?: Promise<void>;
|
|
1206
|
+
registerMissingImport: (id: string, resolved: string) => OptimizedDepInfo;
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1195
1209
|
/**
|
|
1196
1210
|
* Used by Vite CLI when running `vite optimize`
|
|
1197
1211
|
*/
|
|
1198
|
-
export declare function optimizeDeps(config: ResolvedConfig, force?: boolean | undefined, asCommand?: boolean
|
|
1199
|
-
ssr?: boolean): Promise<DepOptimizationMetadata>;
|
|
1212
|
+
export declare function optimizeDeps(config: ResolvedConfig, force?: boolean | undefined, asCommand?: boolean): Promise<DepOptimizationMetadata>;
|
|
1200
1213
|
|
|
1201
1214
|
/** Cache for package.json resolution and package.json contents */
|
|
1202
1215
|
export declare type PackageCache = Map<string, PackageData>;
|
|
@@ -1319,6 +1332,7 @@ export declare interface Plugin extends Plugin_2 {
|
|
|
1319
1332
|
resolveId?(this: PluginContext, source: string, importer: string | undefined, options: {
|
|
1320
1333
|
custom?: CustomPluginOptions;
|
|
1321
1334
|
ssr?: boolean;
|
|
1335
|
+
/* Excluded from this release type: scan */
|
|
1322
1336
|
}): Promise<ResolveIdResult> | ResolveIdResult;
|
|
1323
1337
|
load?(this: PluginContext, id: string, options?: {
|
|
1324
1338
|
ssr?: boolean;
|
|
@@ -1335,6 +1349,7 @@ export declare interface PluginContainer {
|
|
|
1335
1349
|
resolveId(id: string, importer?: string, options?: {
|
|
1336
1350
|
skip?: Set<Plugin>;
|
|
1337
1351
|
ssr?: boolean;
|
|
1352
|
+
/* Excluded from this release type: scan */
|
|
1338
1353
|
}): Promise<PartialResolvedId | null>;
|
|
1339
1354
|
transform(code: string, id: string, options?: {
|
|
1340
1355
|
inMap?: SourceDescription['map'];
|
|
@@ -1377,7 +1392,7 @@ export declare interface PreviewServer {
|
|
|
1377
1392
|
/**
|
|
1378
1393
|
* @deprecated Use `server.printUrls()` instead
|
|
1379
1394
|
*/
|
|
1380
|
-
export declare function printHttpServerUrls(server:
|
|
1395
|
+
export declare function printHttpServerUrls(server: Server_2, config: ResolvedConfig): void;
|
|
1381
1396
|
|
|
1382
1397
|
export declare interface ProxyOptions extends HttpProxy.ServerOptions {
|
|
1383
1398
|
/**
|
|
@@ -1413,6 +1428,7 @@ export declare type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | 'alia
|
|
|
1413
1428
|
cacheDir: string;
|
|
1414
1429
|
command: 'build' | 'serve';
|
|
1415
1430
|
mode: string;
|
|
1431
|
+
isWorker: boolean;
|
|
1416
1432
|
isProduction: boolean;
|
|
1417
1433
|
env: Record<string, any>;
|
|
1418
1434
|
resolve: ResolveOptions & {
|
|
@@ -2195,12 +2211,11 @@ export declare interface ViteDevServer {
|
|
|
2195
2211
|
* @param forceOptimize - force the optimizer to re-bundle, same as --force cli flag
|
|
2196
2212
|
*/
|
|
2197
2213
|
restart(forceOptimize?: boolean): Promise<void>;
|
|
2198
|
-
/* Excluded from this release type:
|
|
2214
|
+
/* Excluded from this release type: _optimizedDeps */
|
|
2199
2215
|
/* Excluded from this release type: _ssrExternals */
|
|
2200
2216
|
/* Excluded from this release type: _globImporters */
|
|
2201
2217
|
/* Excluded from this release type: _restartPromise */
|
|
2202
2218
|
/* Excluded from this release type: _forceOptimizeOnRestart */
|
|
2203
|
-
/* Excluded from this release type: _registerMissingImport */
|
|
2204
2219
|
/* Excluded from this release type: _pendingRequests */
|
|
2205
2220
|
}
|
|
2206
2221
|
|
|
@@ -2693,7 +2708,7 @@ export declare namespace WebSocket {
|
|
|
2693
2708
|
host?: string | undefined
|
|
2694
2709
|
port?: number | undefined
|
|
2695
2710
|
backlog?: number | undefined
|
|
2696
|
-
server?: Server |
|
|
2711
|
+
server?: Server | Server_3 | undefined
|
|
2697
2712
|
verifyClient?:
|
|
2698
2713
|
| VerifyClientCallbackAsync
|
|
2699
2714
|
| VerifyClientCallbackSync
|
|
@@ -2825,11 +2840,53 @@ export declare const WebSocketAlias: typeof WebSocket;
|
|
|
2825
2840
|
|
|
2826
2841
|
export declare interface WebSocketAlias extends WebSocket {}
|
|
2827
2842
|
|
|
2843
|
+
export declare interface WebSocketClient {
|
|
2844
|
+
/**
|
|
2845
|
+
* Send event to the client
|
|
2846
|
+
*/
|
|
2847
|
+
send(payload: HMRPayload): void;
|
|
2848
|
+
/**
|
|
2849
|
+
* Send custom event
|
|
2850
|
+
*/
|
|
2851
|
+
send(event: string, payload?: CustomPayload['data']): void;
|
|
2852
|
+
/**
|
|
2853
|
+
* The raw WebSocket instance
|
|
2854
|
+
* @advanced
|
|
2855
|
+
*/
|
|
2856
|
+
socket: WebSocket_2;
|
|
2857
|
+
}
|
|
2858
|
+
|
|
2859
|
+
export declare type WebSocketCustomListener<T> = (data: T, client: WebSocketClient) => void;
|
|
2860
|
+
|
|
2828
2861
|
export declare interface WebSocketServer {
|
|
2829
|
-
|
|
2830
|
-
|
|
2862
|
+
/**
|
|
2863
|
+
* Get all connected clients.
|
|
2864
|
+
*/
|
|
2865
|
+
clients: Set<WebSocketClient>;
|
|
2866
|
+
/**
|
|
2867
|
+
* Boardcast events to all clients
|
|
2868
|
+
*/
|
|
2831
2869
|
send(payload: HMRPayload): void;
|
|
2870
|
+
/**
|
|
2871
|
+
* Send custom event
|
|
2872
|
+
*/
|
|
2873
|
+
send(event: string, payload?: CustomPayload['data']): void;
|
|
2874
|
+
/**
|
|
2875
|
+
* Disconnect all clients and terminate the server.
|
|
2876
|
+
*/
|
|
2832
2877
|
close(): Promise<void>;
|
|
2878
|
+
/**
|
|
2879
|
+
* Handle custom event emitted by `import.meta.hot.send`
|
|
2880
|
+
*/
|
|
2881
|
+
on: WebSocketServer_2['on'] & {
|
|
2882
|
+
(event: string, listener: WebSocketCustomListener<any>): void;
|
|
2883
|
+
};
|
|
2884
|
+
/**
|
|
2885
|
+
* Unregister event listener.
|
|
2886
|
+
*/
|
|
2887
|
+
off: WebSocketServer_2['off'] & {
|
|
2888
|
+
(event: string, listener: WebSocketCustomListener<any>): void;
|
|
2889
|
+
};
|
|
2833
2890
|
}
|
|
2834
2891
|
|
|
2835
2892
|
export { }
|
package/dist/node/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var index = require('./chunks/dep-
|
|
5
|
+
var index = require('./chunks/dep-f5b7cdd7.js');
|
|
6
6
|
require('fs');
|
|
7
7
|
require('path');
|
|
8
8
|
require('tty');
|
|
@@ -21,9 +21,9 @@ require('zlib');
|
|
|
21
21
|
require('crypto');
|
|
22
22
|
require('tls');
|
|
23
23
|
require('assert');
|
|
24
|
+
require('esbuild');
|
|
24
25
|
require('buffer');
|
|
25
26
|
require('querystring');
|
|
26
|
-
require('esbuild');
|
|
27
27
|
require('child_process');
|
|
28
28
|
require('worker_threads');
|
|
29
29
|
require('readline');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite",
|
|
3
|
-
"version": "2.9.0-beta.
|
|
3
|
+
"version": "2.9.0-beta.9",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Evan You",
|
|
6
6
|
"description": "Native-ESM powered web dev build tool",
|
|
@@ -113,7 +113,7 @@
|
|
|
113
113
|
"source-map-support": "^0.5.21",
|
|
114
114
|
"strip-ansi": "^6.0.1",
|
|
115
115
|
"terser": "^5.12.1",
|
|
116
|
-
"tsconfck": "^1.2.
|
|
116
|
+
"tsconfck": "^1.2.1",
|
|
117
117
|
"tslib": "^2.3.1",
|
|
118
118
|
"types": "link:./types",
|
|
119
119
|
"ws": "^8.5.0"
|
package/src/client/client.ts
CHANGED
|
@@ -30,6 +30,7 @@ const socketHost = __HMR_PORT__
|
|
|
30
30
|
|
|
31
31
|
const socket = new WebSocket(`${socketProtocol}://${socketHost}`, 'vite-hmr')
|
|
32
32
|
const base = __BASE__ || '/'
|
|
33
|
+
const messageBuffer: string[] = []
|
|
33
34
|
|
|
34
35
|
function warnFailedFetch(err: Error, path: string | string[]) {
|
|
35
36
|
if (!err.message.match('fetch')) {
|
|
@@ -59,9 +60,10 @@ async function handleMessage(payload: HMRPayload) {
|
|
|
59
60
|
switch (payload.type) {
|
|
60
61
|
case 'connected':
|
|
61
62
|
console.log(`[vite] connected.`)
|
|
63
|
+
sendMessageBuffer()
|
|
62
64
|
// proxy(nginx, docker) hmr ws maybe caused timeout,
|
|
63
65
|
// so send ping package let ws keep alive.
|
|
64
|
-
setInterval(() => socket.send('ping'), __HMR_TIMEOUT__)
|
|
66
|
+
setInterval(() => socket.send('{"type":"ping"}'), __HMR_TIMEOUT__)
|
|
65
67
|
break
|
|
66
68
|
case 'update':
|
|
67
69
|
notifyListeners('vite:beforeUpdate', payload)
|
|
@@ -361,6 +363,13 @@ async function fetchUpdate({ path, acceptedPath, timestamp }: Update) {
|
|
|
361
363
|
}
|
|
362
364
|
}
|
|
363
365
|
|
|
366
|
+
function sendMessageBuffer() {
|
|
367
|
+
if (socket.readyState === 1) {
|
|
368
|
+
messageBuffer.forEach((msg) => socket.send(msg))
|
|
369
|
+
messageBuffer.length = 0
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
|
|
364
373
|
interface HotModule {
|
|
365
374
|
id: string
|
|
366
375
|
callbacks: HotCallback[]
|
|
@@ -478,6 +487,11 @@ export const createHotContext = (ownerPath: string) => {
|
|
|
478
487
|
}
|
|
479
488
|
addToMap(customListenersMap)
|
|
480
489
|
addToMap(newListeners)
|
|
490
|
+
},
|
|
491
|
+
|
|
492
|
+
send: (event: string, data?: any) => {
|
|
493
|
+
messageBuffer.push(JSON.stringify({ type: 'custom', event, data }))
|
|
494
|
+
sendMessageBuffer()
|
|
481
495
|
}
|
|
482
496
|
}
|
|
483
497
|
|