vite 3.0.0-beta.9 → 3.0.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.
- package/dist/client/client.mjs +23 -3
- package/dist/client/client.mjs.map +1 -1
- package/dist/node/chunks/{dep-58325dc2.js → dep-1513d487.js} +334 -239
- package/dist/node/chunks/{dep-235df460.js → dep-3f457808.js} +1 -1
- package/dist/node/chunks/{dep-21ac9d2b.js → dep-f07a4e2f.js} +1 -1
- package/dist/node/cli.js +5 -5
- package/dist/node/constants.js +1 -1
- package/dist/node/index.d.ts +24 -5
- package/dist/node/index.js +1 -1
- package/dist/node-cjs/publicUtils.cjs +1 -1
- package/package.json +6 -6
- package/src/client/client.ts +22 -3
- package/src/client/overlay.ts +4 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as getAugmentedNamespace, B as getDefaultExportFromCjs } from './dep-
|
|
1
|
+
import { A as getAugmentedNamespace, B as getDefaultExportFromCjs } from './dep-1513d487.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-
|
|
3
|
+
import { y as picocolors, u as createLogger, e as resolveConfig } from './chunks/dep-1513d487.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-
|
|
697
|
+
const { createServer } = await import('./chunks/dep-1513d487.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-
|
|
744
|
+
const { build } = await import('./chunks/dep-1513d487.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-
|
|
768
|
+
const { optimizeDeps } = await import('./chunks/dep-1513d487.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-
|
|
791
|
+
const { preview } = await import('./chunks/dep-1513d487.js').then(function (n) { return n.F; });
|
|
792
792
|
try {
|
|
793
793
|
const server = await preview({
|
|
794
794
|
root,
|
package/dist/node/constants.js
CHANGED
package/dist/node/index.d.ts
CHANGED
|
@@ -552,8 +552,8 @@ export declare interface DepOptimizationConfig {
|
|
|
552
552
|
/**
|
|
553
553
|
* Disables dependencies optimizations, true disables the optimizer during
|
|
554
554
|
* build and dev. Pass 'build' or 'dev' to only disable the optimizer in
|
|
555
|
-
* one of the modes. Deps optimization is enabled by default in
|
|
556
|
-
* @default
|
|
555
|
+
* one of the modes. Deps optimization is enabled by default in dev only.
|
|
556
|
+
* @default 'build'
|
|
557
557
|
* @experimental
|
|
558
558
|
*/
|
|
559
559
|
disabled?: boolean | 'build' | 'dev';
|
|
@@ -1410,7 +1410,8 @@ export declare interface OptimizedDepInfo {
|
|
|
1410
1410
|
}
|
|
1411
1411
|
|
|
1412
1412
|
/**
|
|
1413
|
-
*
|
|
1413
|
+
* Scan and optimize dependencies within a project.
|
|
1414
|
+
* Used by Vite CLI when running `vite optimize`.
|
|
1414
1415
|
*/
|
|
1415
1416
|
export declare function optimizeDeps(config: ResolvedConfig, force?: boolean | undefined, asCommand?: boolean): Promise<DepOptimizationMetadata>;
|
|
1416
1417
|
|
|
@@ -1598,10 +1599,16 @@ export declare interface PreviewServer {
|
|
|
1598
1599
|
* native Node http server instance
|
|
1599
1600
|
*/
|
|
1600
1601
|
httpServer: http.Server;
|
|
1602
|
+
/**
|
|
1603
|
+
* The resolved urls Vite prints on the
|
|
1604
|
+
*
|
|
1605
|
+
* @experimental
|
|
1606
|
+
*/
|
|
1607
|
+
resolvedUrls: ResolvedServerUrls;
|
|
1601
1608
|
/**
|
|
1602
1609
|
* Print server urls
|
|
1603
1610
|
*/
|
|
1604
|
-
printUrls
|
|
1611
|
+
printUrls(): void;
|
|
1605
1612
|
}
|
|
1606
1613
|
|
|
1607
1614
|
export declare type PreviewServerHook = (server: {
|
|
@@ -1689,6 +1696,11 @@ export declare interface ResolvedServerOptions extends ServerOptions {
|
|
|
1689
1696
|
middlewareMode: boolean;
|
|
1690
1697
|
}
|
|
1691
1698
|
|
|
1699
|
+
export declare interface ResolvedServerUrls {
|
|
1700
|
+
local: string[];
|
|
1701
|
+
network: string[];
|
|
1702
|
+
}
|
|
1703
|
+
|
|
1692
1704
|
export declare interface ResolvedSSROptions extends SSROptions {
|
|
1693
1705
|
target: SSRTarget;
|
|
1694
1706
|
format: SSRFormat;
|
|
@@ -2436,6 +2448,13 @@ export declare interface ViteDevServer {
|
|
|
2436
2448
|
* and hmr state.
|
|
2437
2449
|
*/
|
|
2438
2450
|
moduleGraph: ModuleGraph;
|
|
2451
|
+
/**
|
|
2452
|
+
* The resolved urls Vite prints on the CLI. null in middleware mode or
|
|
2453
|
+
* before `server.listen` is called.
|
|
2454
|
+
*
|
|
2455
|
+
* @experimental
|
|
2456
|
+
*/
|
|
2457
|
+
resolvedUrls: ResolvedServerUrls | null;
|
|
2439
2458
|
/**
|
|
2440
2459
|
* Programmatically resolve, load and transform a URL and get the result
|
|
2441
2460
|
* without going through the http request pipeline.
|
|
@@ -2474,7 +2493,7 @@ export declare interface ViteDevServer {
|
|
|
2474
2493
|
/**
|
|
2475
2494
|
* Print server urls
|
|
2476
2495
|
*/
|
|
2477
|
-
printUrls():
|
|
2496
|
+
printUrls(): void;
|
|
2478
2497
|
/**
|
|
2479
2498
|
* Restart the server.
|
|
2480
2499
|
*
|
package/dist/node/index.js
CHANGED
|
@@ -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-
|
|
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-1513d487.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.
|
|
34
|
+
var version = "3.0.2";
|
|
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.
|
|
3
|
+
"version": "3.0.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Evan You",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"types"
|
|
33
33
|
],
|
|
34
34
|
"engines": {
|
|
35
|
-
"node": "
|
|
35
|
+
"node": "^14.18.0 || >=16.0.0"
|
|
36
36
|
},
|
|
37
37
|
"repository": {
|
|
38
38
|
"type": "git",
|
|
@@ -68,8 +68,8 @@
|
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@ampproject/remapping": "^2.2.0",
|
|
71
|
-
"@babel/parser": "^7.18.
|
|
72
|
-
"@babel/types": "^7.18.
|
|
71
|
+
"@babel/parser": "^7.18.9",
|
|
72
|
+
"@babel/types": "^7.18.9",
|
|
73
73
|
"@jridgewell/trace-mapping": "^0.3.14",
|
|
74
74
|
"@rollup/plugin-alias": "^3.1.9",
|
|
75
75
|
"@rollup/plugin-commonjs": "^22.0.1",
|
|
@@ -118,8 +118,8 @@
|
|
|
118
118
|
"tsconfck": "^2.0.1",
|
|
119
119
|
"tslib": "^2.4.0",
|
|
120
120
|
"types": "link:./types",
|
|
121
|
-
"ufo": "^0.8.
|
|
122
|
-
"ws": "^8.8.
|
|
121
|
+
"ufo": "^0.8.5",
|
|
122
|
+
"ws": "^8.8.1"
|
|
123
123
|
},
|
|
124
124
|
"peerDependencies": {
|
|
125
125
|
"less": "*",
|
package/src/client/client.ts
CHANGED
|
@@ -7,6 +7,7 @@ import '@vite/env'
|
|
|
7
7
|
|
|
8
8
|
// injected by the hmr plugin when served
|
|
9
9
|
declare const __BASE__: string
|
|
10
|
+
declare const __SERVER_HOST__: string
|
|
10
11
|
declare const __HMR_PROTOCOL__: string | null
|
|
11
12
|
declare const __HMR_HOSTNAME__: string | null
|
|
12
13
|
declare const __HMR_PORT__: number | null
|
|
@@ -20,6 +21,7 @@ console.debug('[vite] connecting...')
|
|
|
20
21
|
const importMetaUrl = new URL(import.meta.url)
|
|
21
22
|
|
|
22
23
|
// use server configuration, then fallback to inference
|
|
24
|
+
const serverHost = __SERVER_HOST__
|
|
23
25
|
const socketProtocol =
|
|
24
26
|
__HMR_PROTOCOL__ || (location.protocol === 'https:' ? 'wss' : 'ws')
|
|
25
27
|
const hmrPort = __HMR_PORT__
|
|
@@ -38,7 +40,19 @@ try {
|
|
|
38
40
|
fallback = () => {
|
|
39
41
|
// fallback to connecting directly to the hmr server
|
|
40
42
|
// for servers which does not support proxying websocket
|
|
41
|
-
socket = setupWebSocket(socketProtocol, directSocketHost)
|
|
43
|
+
socket = setupWebSocket(socketProtocol, directSocketHost, () => {
|
|
44
|
+
const currentScriptHostURL = new URL(import.meta.url)
|
|
45
|
+
const currentScriptHost =
|
|
46
|
+
currentScriptHostURL.host +
|
|
47
|
+
currentScriptHostURL.pathname.replace(/@vite\/client$/, '')
|
|
48
|
+
console.error(
|
|
49
|
+
'[vite] failed to connect to websocket.\n' +
|
|
50
|
+
'your current setup:\n' +
|
|
51
|
+
` (browser) ${currentScriptHost} <--[HTTP]--> ${serverHost} (server)\n` +
|
|
52
|
+
` (browser) ${socketHost} <--[WebSocket (failing)]--> ${directSocketHost} (server)\n` +
|
|
53
|
+
'Check out your Vite / network configuration and https://vitejs.dev/config/server-options.html#server-hmr .'
|
|
54
|
+
)
|
|
55
|
+
})
|
|
42
56
|
socket.addEventListener(
|
|
43
57
|
'open',
|
|
44
58
|
() => {
|
|
@@ -120,7 +134,11 @@ async function handleMessage(payload: HMRPayload) {
|
|
|
120
134
|
sendMessageBuffer()
|
|
121
135
|
// proxy(nginx, docker) hmr ws maybe caused timeout,
|
|
122
136
|
// so send ping package let ws keep alive.
|
|
123
|
-
setInterval(() =>
|
|
137
|
+
setInterval(() => {
|
|
138
|
+
if (socket.readyState === socket.OPEN) {
|
|
139
|
+
socket.send('{"type":"ping"}')
|
|
140
|
+
}
|
|
141
|
+
}, __HMR_TIMEOUT__)
|
|
124
142
|
break
|
|
125
143
|
case 'update':
|
|
126
144
|
notifyListeners('vite:beforeUpdate', payload)
|
|
@@ -280,7 +298,8 @@ async function waitForSuccessfulPing(hostAndPath: string, ms = 1000) {
|
|
|
280
298
|
try {
|
|
281
299
|
// A fetch on a websocket URL will return a successful promise with status 400,
|
|
282
300
|
// but will reject a networking error.
|
|
283
|
-
|
|
301
|
+
// 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' })
|
|
284
303
|
break
|
|
285
304
|
} catch (e) {
|
|
286
305
|
// wait ms before attempting to ping again
|
package/src/client/overlay.ts
CHANGED
|
@@ -115,6 +115,9 @@ code {
|
|
|
115
115
|
const fileRE = /(?:[a-zA-Z]:\\|\/).*?:\d+:\d+/g
|
|
116
116
|
const codeframeRE = /^(?:>?\s+\d+\s+\|.*|\s+\|\s*\^.*)\r?\n/gm
|
|
117
117
|
|
|
118
|
+
// Allow `ErrorOverlay` to extend `HTMLElement` even in environments where
|
|
119
|
+
// `HTMLElement` was not originally defined.
|
|
120
|
+
const { HTMLElement = class {} } = globalThis
|
|
118
121
|
export class ErrorOverlay extends HTMLElement {
|
|
119
122
|
root: ShadowRoot
|
|
120
123
|
|
|
@@ -184,6 +187,7 @@ export class ErrorOverlay extends HTMLElement {
|
|
|
184
187
|
}
|
|
185
188
|
|
|
186
189
|
export const overlayId = 'vite-error-overlay'
|
|
190
|
+
const { customElements } = globalThis // Ensure `customElements` is defined before the next line.
|
|
187
191
|
if (customElements && !customElements.get(overlayId)) {
|
|
188
192
|
customElements.define(overlayId, ErrorOverlay)
|
|
189
193
|
}
|