vite 3.0.8 → 3.1.0-beta.1
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/LICENSE.md +46 -116
- package/dist/client/client.mjs +9 -24
- package/dist/client/client.mjs.map +1 -1
- package/dist/node/chunks/{dep-74663fff.js → dep-3ffe6dd0.js} +24171 -23791
- package/dist/node/chunks/dep-4069c338.js +8079 -0
- package/dist/node/chunks/{dep-399ffe4b.js → dep-6cde6b83.js} +142 -154
- package/dist/node/cli.js +7 -6
- package/dist/node/constants.js +1 -1
- package/dist/node/index.d.ts +44 -30
- package/dist/node/index.js +3 -2
- package/dist/node-cjs/publicUtils.cjs +7 -2
- package/package.json +12 -12
- package/src/client/client.ts +28 -40
- package/types/chokidar.d.ts +1 -1
- package/types/http-proxy.d.ts +1 -1
- package/types/importGlob.d.ts +15 -5
- package/dist/node/chunks/dep-aabb0c58.js +0 -8816
package/dist/node/index.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ import type { LoadResult } from 'rollup';
|
|
|
21
21
|
import type { ModuleFormat } from 'rollup';
|
|
22
22
|
import type { ModuleInfo } from 'rollup';
|
|
23
23
|
import type * as net from 'node:net';
|
|
24
|
+
import type { ObjectHook } from 'rollup';
|
|
24
25
|
import type { OutgoingHttpHeaders } from 'node:http';
|
|
25
26
|
import type { OutputBundle } from 'rollup';
|
|
26
27
|
import type { OutputChunk } from 'rollup';
|
|
@@ -846,6 +847,8 @@ export declare type HMRPayload =
|
|
|
846
847
|
| ErrorPayload
|
|
847
848
|
| PrunePayload
|
|
848
849
|
|
|
850
|
+
export declare type HookHandler<T> = T extends ObjectHook<infer H> ? H : T;
|
|
851
|
+
|
|
849
852
|
export declare interface HtmlTagDescriptor {
|
|
850
853
|
tag: string;
|
|
851
854
|
attrs?: Record<string, string | boolean | undefined>;
|
|
@@ -894,7 +897,7 @@ export declare namespace HttpProxy {
|
|
|
894
897
|
* Used for proxying regular HTTP(S) requests
|
|
895
898
|
* @param req - Client request.
|
|
896
899
|
* @param res - Client response.
|
|
897
|
-
* @param options -
|
|
900
|
+
* @param options - Additional options.
|
|
898
901
|
*/
|
|
899
902
|
web(
|
|
900
903
|
req: http.IncomingMessage,
|
|
@@ -1088,7 +1091,9 @@ export declare namespace HttpProxy {
|
|
|
1088
1091
|
|
|
1089
1092
|
export declare interface ImportGlobEagerFunction {
|
|
1090
1093
|
/**
|
|
1091
|
-
*
|
|
1094
|
+
* Eagerly import a list of files with a glob pattern.
|
|
1095
|
+
*
|
|
1096
|
+
* Overload 1: No generic provided, infer the type from `as`
|
|
1092
1097
|
*/
|
|
1093
1098
|
<
|
|
1094
1099
|
As extends string,
|
|
@@ -1098,7 +1103,9 @@ export declare interface ImportGlobEagerFunction {
|
|
|
1098
1103
|
options?: Omit<ImportGlobOptions<boolean, As>, 'eager'>
|
|
1099
1104
|
): Record<string, T>
|
|
1100
1105
|
/**
|
|
1101
|
-
*
|
|
1106
|
+
* Eagerly import a list of files with a glob pattern.
|
|
1107
|
+
*
|
|
1108
|
+
* Overload 2: Module generic provided
|
|
1102
1109
|
*/
|
|
1103
1110
|
<M>(
|
|
1104
1111
|
glob: string | string[],
|
|
@@ -1108,7 +1115,9 @@ export declare interface ImportGlobEagerFunction {
|
|
|
1108
1115
|
|
|
1109
1116
|
export declare interface ImportGlobFunction {
|
|
1110
1117
|
/**
|
|
1111
|
-
*
|
|
1118
|
+
* Import a list of files with a glob pattern.
|
|
1119
|
+
*
|
|
1120
|
+
* Overload 1: No generic provided, infer the type from `eager` and `as`
|
|
1112
1121
|
*/
|
|
1113
1122
|
<
|
|
1114
1123
|
Eager extends boolean,
|
|
@@ -1121,14 +1130,18 @@ export declare interface ImportGlobFunction {
|
|
|
1121
1130
|
? Record<string, T>
|
|
1122
1131
|
: Record<string, () => Promise<T>>
|
|
1123
1132
|
/**
|
|
1124
|
-
*
|
|
1133
|
+
* Import a list of files with a glob pattern.
|
|
1134
|
+
*
|
|
1135
|
+
* Overload 2: Module generic provided, infer the type from `eager: false`
|
|
1125
1136
|
*/
|
|
1126
1137
|
<M>(
|
|
1127
1138
|
glob: string | string[],
|
|
1128
1139
|
options?: ImportGlobOptions<false, string>
|
|
1129
1140
|
): Record<string, () => Promise<M>>
|
|
1130
1141
|
/**
|
|
1131
|
-
*
|
|
1142
|
+
* Import a list of files with a glob pattern.
|
|
1143
|
+
*
|
|
1144
|
+
* Overload 3: Module generic provided, infer the type from `eager: true`
|
|
1132
1145
|
*/
|
|
1133
1146
|
<M>(
|
|
1134
1147
|
glob: string | string[],
|
|
@@ -1186,7 +1199,7 @@ export declare interface IndexHtmlTransformContext {
|
|
|
1186
1199
|
originalUrl?: string;
|
|
1187
1200
|
}
|
|
1188
1201
|
|
|
1189
|
-
export declare type IndexHtmlTransformHook = (html: string, ctx: IndexHtmlTransformContext) => IndexHtmlTransformResult | void | Promise<IndexHtmlTransformResult | void>;
|
|
1202
|
+
export declare type IndexHtmlTransformHook = (this: void, html: string, ctx: IndexHtmlTransformContext) => IndexHtmlTransformResult | void | Promise<IndexHtmlTransformResult | void>;
|
|
1190
1203
|
|
|
1191
1204
|
export declare type IndexHtmlTransformResult = string | HtmlTagDescriptor[] | {
|
|
1192
1205
|
html: string;
|
|
@@ -1484,7 +1497,7 @@ declare interface Plugin_2 extends Plugin_3 {
|
|
|
1484
1497
|
/**
|
|
1485
1498
|
* Apply the plugin only for serve or build, or on certain conditions.
|
|
1486
1499
|
*/
|
|
1487
|
-
apply?: 'serve' | 'build' | ((config: UserConfig, env: ConfigEnv) => boolean);
|
|
1500
|
+
apply?: 'serve' | 'build' | ((this: void, config: UserConfig, env: ConfigEnv) => boolean);
|
|
1488
1501
|
/**
|
|
1489
1502
|
* Modify vite config before it's resolved. The hook can either mutate the
|
|
1490
1503
|
* passed-in config directly, or return a partial config object that will be
|
|
@@ -1493,11 +1506,11 @@ declare interface Plugin_2 extends Plugin_3 {
|
|
|
1493
1506
|
* Note: User plugins are resolved before running this hook so injecting other
|
|
1494
1507
|
* plugins inside the `config` hook will have no effect.
|
|
1495
1508
|
*/
|
|
1496
|
-
config?: (config: UserConfig, env: ConfigEnv) => UserConfig | null | void | Promise<UserConfig | null | void
|
|
1509
|
+
config?: ObjectHook<(this: void, config: UserConfig, env: ConfigEnv) => UserConfig | null | void | Promise<UserConfig | null | void>>;
|
|
1497
1510
|
/**
|
|
1498
1511
|
* Use this hook to read and store the final resolved vite config.
|
|
1499
1512
|
*/
|
|
1500
|
-
configResolved?: (config: ResolvedConfig) => void | Promise<void
|
|
1513
|
+
configResolved?: ObjectHook<(this: void, config: ResolvedConfig) => void | Promise<void>>;
|
|
1501
1514
|
/**
|
|
1502
1515
|
* Configure the vite server. The hook receives the {@link ViteDevServer}
|
|
1503
1516
|
* instance. This can also be used to store a reference to the server
|
|
@@ -1507,7 +1520,7 @@ declare interface Plugin_2 extends Plugin_3 {
|
|
|
1507
1520
|
* can return a post hook that will be called after internal middlewares
|
|
1508
1521
|
* are applied. Hook can be async functions and will be called in series.
|
|
1509
1522
|
*/
|
|
1510
|
-
configureServer?: ServerHook
|
|
1523
|
+
configureServer?: ObjectHook<ServerHook>;
|
|
1511
1524
|
/**
|
|
1512
1525
|
* Configure the preview server. The hook receives the connect server and
|
|
1513
1526
|
* its underlying http server.
|
|
@@ -1516,7 +1529,7 @@ declare interface Plugin_2 extends Plugin_3 {
|
|
|
1516
1529
|
* return a post hook that will be called after other middlewares are
|
|
1517
1530
|
* applied. Hooks can be async functions and will be called in series.
|
|
1518
1531
|
*/
|
|
1519
|
-
configurePreviewServer?: PreviewServerHook
|
|
1532
|
+
configurePreviewServer?: ObjectHook<PreviewServerHook>;
|
|
1520
1533
|
/**
|
|
1521
1534
|
* Transform index.html.
|
|
1522
1535
|
* The hook receives the following arguments:
|
|
@@ -1548,22 +1561,22 @@ declare interface Plugin_2 extends Plugin_3 {
|
|
|
1548
1561
|
* - If the hook doesn't return a value, the hmr update will be performed as
|
|
1549
1562
|
* normal.
|
|
1550
1563
|
*/
|
|
1551
|
-
handleHotUpdate
|
|
1564
|
+
handleHotUpdate?: ObjectHook<(this: void, ctx: HmrContext) => Array<ModuleNode> | void | Promise<Array<ModuleNode> | void>>;
|
|
1552
1565
|
/**
|
|
1553
1566
|
* extend hooks with ssr flag
|
|
1554
1567
|
*/
|
|
1555
|
-
resolveId?: (this: PluginContext, source: string, importer: string | undefined, options: {
|
|
1568
|
+
resolveId?: ObjectHook<(this: PluginContext, source: string, importer: string | undefined, options: {
|
|
1556
1569
|
custom?: CustomPluginOptions;
|
|
1557
1570
|
ssr?: boolean;
|
|
1558
1571
|
/* Excluded from this release type: scan */
|
|
1559
1572
|
isEntry: boolean;
|
|
1560
|
-
}) => Promise<ResolveIdResult> | ResolveIdResult
|
|
1561
|
-
load?: (this: PluginContext, id: string, options?: {
|
|
1573
|
+
}) => Promise<ResolveIdResult> | ResolveIdResult>;
|
|
1574
|
+
load?: ObjectHook<(this: PluginContext, id: string, options?: {
|
|
1562
1575
|
ssr?: boolean;
|
|
1563
|
-
}) => Promise<LoadResult> | LoadResult
|
|
1564
|
-
transform?: (this: TransformPluginContext, code: string, id: string, options?: {
|
|
1576
|
+
}) => Promise<LoadResult> | LoadResult>;
|
|
1577
|
+
transform?: ObjectHook<(this: TransformPluginContext, code: string, id: string, options?: {
|
|
1565
1578
|
ssr?: boolean;
|
|
1566
|
-
}) => Promise<TransformResult_2> | TransformResult_2
|
|
1579
|
+
}) => Promise<TransformResult_2> | TransformResult_2>;
|
|
1567
1580
|
}
|
|
1568
1581
|
export { Plugin_2 as Plugin }
|
|
1569
1582
|
|
|
@@ -1588,6 +1601,11 @@ export declare interface PluginContainer {
|
|
|
1588
1601
|
close(): Promise<void>;
|
|
1589
1602
|
}
|
|
1590
1603
|
|
|
1604
|
+
export declare interface PluginHookUtils {
|
|
1605
|
+
getSortedPlugins: (hookName: keyof Plugin_2) => Plugin_2[];
|
|
1606
|
+
getSortedPluginHooks: <K extends keyof Plugin_2>(hookName: K) => NonNullable<HookHandler<Plugin_2[K]>>[];
|
|
1607
|
+
}
|
|
1608
|
+
|
|
1591
1609
|
export declare type PluginOption = Plugin_2 | false | null | undefined | PluginOption[] | Promise<Plugin_2 | false | null | undefined | PluginOption[]>;
|
|
1592
1610
|
|
|
1593
1611
|
/**
|
|
@@ -1609,8 +1627,6 @@ export declare interface PreviewServer {
|
|
|
1609
1627
|
httpServer: http.Server;
|
|
1610
1628
|
/**
|
|
1611
1629
|
* The resolved urls Vite prints on the CLI
|
|
1612
|
-
*
|
|
1613
|
-
* @experimental
|
|
1614
1630
|
*/
|
|
1615
1631
|
resolvedUrls: ResolvedServerUrls;
|
|
1616
1632
|
/**
|
|
@@ -1619,7 +1635,7 @@ export declare interface PreviewServer {
|
|
|
1619
1635
|
printUrls(): void;
|
|
1620
1636
|
}
|
|
1621
1637
|
|
|
1622
|
-
export declare type PreviewServerHook = (server: {
|
|
1638
|
+
export declare type PreviewServerHook = (this: void, server: {
|
|
1623
1639
|
middlewares: Connect.Server;
|
|
1624
1640
|
httpServer: http.Server;
|
|
1625
1641
|
}) => (() => void) | void | Promise<(() => void) | void>;
|
|
@@ -1694,7 +1710,7 @@ export declare type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | 'asse
|
|
|
1694
1710
|
worker: ResolveWorkerOptions;
|
|
1695
1711
|
appType: AppType;
|
|
1696
1712
|
experimental: ExperimentalOptions;
|
|
1697
|
-
}>;
|
|
1713
|
+
} & PluginHookUtils>;
|
|
1698
1714
|
|
|
1699
1715
|
export declare interface ResolvedPreviewOptions extends PreviewOptions {
|
|
1700
1716
|
}
|
|
@@ -1744,7 +1760,7 @@ export declare interface ResolverObject {
|
|
|
1744
1760
|
resolveId: ResolverFunction
|
|
1745
1761
|
}
|
|
1746
1762
|
|
|
1747
|
-
export declare interface ResolveWorkerOptions {
|
|
1763
|
+
export declare interface ResolveWorkerOptions extends PluginHookUtils {
|
|
1748
1764
|
format: 'es' | 'iife';
|
|
1749
1765
|
plugins: Plugin_2[];
|
|
1750
1766
|
rollupOptions: RollupOptions;
|
|
@@ -2015,7 +2031,7 @@ export declare interface SendOptions {
|
|
|
2015
2031
|
map?: SourceMap | null;
|
|
2016
2032
|
}
|
|
2017
2033
|
|
|
2018
|
-
export declare type ServerHook = (server: ViteDevServer) => (() => void) | void | Promise<(() => void) | void>;
|
|
2034
|
+
export declare type ServerHook = (this: void, server: ViteDevServer) => (() => void) | void | Promise<(() => void) | void>;
|
|
2019
2035
|
|
|
2020
2036
|
export declare interface ServerOptions extends CommonServerOptions {
|
|
2021
2037
|
/**
|
|
@@ -2550,8 +2566,6 @@ export declare interface ViteDevServer {
|
|
|
2550
2566
|
/**
|
|
2551
2567
|
* The resolved urls Vite prints on the CLI. null in middleware mode or
|
|
2552
2568
|
* before `server.listen` is called.
|
|
2553
|
-
*
|
|
2554
|
-
* @experimental
|
|
2555
2569
|
*/
|
|
2556
2570
|
resolvedUrls: ResolvedServerUrls | null;
|
|
2557
2571
|
/**
|
|
@@ -2566,7 +2580,7 @@ export declare interface ViteDevServer {
|
|
|
2566
2580
|
/**
|
|
2567
2581
|
* Transform module code into SSR format.
|
|
2568
2582
|
*/
|
|
2569
|
-
ssrTransform(code: string, inMap: SourceMap | null, url: string): Promise<TransformResult | null>;
|
|
2583
|
+
ssrTransform(code: string, inMap: SourceMap | null, url: string, originalCode?: string): Promise<TransformResult | null>;
|
|
2570
2584
|
/**
|
|
2571
2585
|
* Load a given URL as an instantiated module for SSR.
|
|
2572
2586
|
*/
|
|
@@ -2696,7 +2710,7 @@ export declare interface WatchOptions {
|
|
|
2696
2710
|
ignorePermissionErrors?: boolean
|
|
2697
2711
|
|
|
2698
2712
|
/**
|
|
2699
|
-
* `true` if `useFsEvents` and `usePolling` are `false
|
|
2713
|
+
* `true` if `useFsEvents` and `usePolling` are `false`. Automatically filters out artifacts
|
|
2700
2714
|
* that occur when using editors that use "atomic writes" instead of writing directly to the
|
|
2701
2715
|
* source file. If a file is re-added within 100 ms of being deleted, Chokidar emits a `change`
|
|
2702
2716
|
* event rather than `unlink` then `add`. If the default of 100 ms does not work well for you,
|
|
@@ -3254,7 +3268,7 @@ export declare interface WebSocketServer {
|
|
|
3254
3268
|
*/
|
|
3255
3269
|
clients: Set<WebSocketClient>;
|
|
3256
3270
|
/**
|
|
3257
|
-
*
|
|
3271
|
+
* Broadcast events to all clients
|
|
3258
3272
|
*/
|
|
3259
3273
|
send(payload: HMRPayload): void;
|
|
3260
3274
|
/**
|
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-3ffe6dd0.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';
|
|
@@ -26,13 +26,14 @@ import 'node:dns';
|
|
|
26
26
|
import 'resolve';
|
|
27
27
|
import 'crypto';
|
|
28
28
|
import 'buffer';
|
|
29
|
+
import 'node:buffer';
|
|
29
30
|
import 'module';
|
|
31
|
+
import 'worker_threads';
|
|
30
32
|
import 'zlib';
|
|
31
33
|
import 'https';
|
|
32
34
|
import 'tls';
|
|
33
35
|
import 'node:http';
|
|
34
36
|
import 'node:https';
|
|
35
|
-
import 'worker_threads';
|
|
36
37
|
import 'querystring';
|
|
37
38
|
import 'node:readline';
|
|
38
39
|
import 'node:child_process';
|
|
@@ -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.1.0-beta.1";
|
|
35
35
|
|
|
36
36
|
const VERSION = version;
|
|
37
37
|
const VITE_PACKAGE_DIR = path$3.resolve(
|
|
@@ -3434,7 +3434,12 @@ function lookupFile(dir, formats, options) {
|
|
|
3434
3434
|
for (const format of formats) {
|
|
3435
3435
|
const fullPath = path__default.join(dir, format);
|
|
3436
3436
|
if (fs__default.existsSync(fullPath) && fs__default.statSync(fullPath).isFile()) {
|
|
3437
|
-
|
|
3437
|
+
const result = options?.pathOnly
|
|
3438
|
+
? fullPath
|
|
3439
|
+
: fs__default.readFileSync(fullPath, 'utf-8');
|
|
3440
|
+
if (!options?.predicate || options.predicate(result)) {
|
|
3441
|
+
return result;
|
|
3442
|
+
}
|
|
3438
3443
|
}
|
|
3439
3444
|
}
|
|
3440
3445
|
const parentDir = path__default.dirname(dir);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.1.0-beta.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Evan You",
|
|
@@ -61,26 +61,25 @@
|
|
|
61
61
|
"esbuild": "^0.14.47",
|
|
62
62
|
"postcss": "^8.4.16",
|
|
63
63
|
"resolve": "^1.22.1",
|
|
64
|
-
"rollup": "
|
|
64
|
+
"rollup": "~2.78.0"
|
|
65
65
|
},
|
|
66
66
|
"optionalDependencies": {
|
|
67
67
|
"fsevents": "~2.3.2"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@ampproject/remapping": "^2.2.0",
|
|
71
|
-
"@babel/parser": "^7.18.
|
|
72
|
-
"@babel/types": "^7.18.
|
|
73
|
-
"@jridgewell/trace-mapping": "^0.3.
|
|
71
|
+
"@babel/parser": "^7.18.13",
|
|
72
|
+
"@babel/types": "^7.18.13",
|
|
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",
|
|
77
77
|
"@rollup/plugin-json": "^4.1.0",
|
|
78
78
|
"@rollup/plugin-node-resolve": "13.3.0",
|
|
79
|
-
"@rollup/plugin-typescript": "^8.
|
|
79
|
+
"@rollup/plugin-typescript": "^8.4.0",
|
|
80
80
|
"@rollup/pluginutils": "^4.2.1",
|
|
81
|
-
"@vue/compiler-dom": "^3.2.37",
|
|
82
81
|
"acorn": "^8.8.0",
|
|
83
|
-
"cac": "^6.7.
|
|
82
|
+
"cac": "^6.7.14",
|
|
84
83
|
"chokidar": "^3.5.3",
|
|
85
84
|
"connect": "^3.7.0",
|
|
86
85
|
"connect-history-api-fallback": "^2.0.0",
|
|
@@ -90,24 +89,25 @@
|
|
|
90
89
|
"debug": "^4.3.4",
|
|
91
90
|
"dotenv": "^14.3.2",
|
|
92
91
|
"dotenv-expand": "^5.1.0",
|
|
93
|
-
"es-module-lexer": "^0.
|
|
92
|
+
"es-module-lexer": "^1.0.3",
|
|
94
93
|
"estree-walker": "^3.0.1",
|
|
95
94
|
"etag": "^1.8.1",
|
|
96
95
|
"fast-glob": "^3.2.11",
|
|
97
96
|
"http-proxy": "^1.18.1",
|
|
98
97
|
"json5": "^2.2.1",
|
|
99
|
-
"launch-editor-middleware": "^2.
|
|
98
|
+
"launch-editor-middleware": "^2.6.0",
|
|
100
99
|
"magic-string": "^0.26.2",
|
|
101
100
|
"micromatch": "^4.0.5",
|
|
102
|
-
"mlly": "^0.5.
|
|
101
|
+
"mlly": "^0.5.14",
|
|
103
102
|
"mrmime": "^1.0.1",
|
|
104
103
|
"okie": "^1.0.1",
|
|
105
104
|
"open": "^8.4.0",
|
|
105
|
+
"parse5": "^7.0.0",
|
|
106
106
|
"periscopic": "^3.0.4",
|
|
107
107
|
"picocolors": "^1.0.0",
|
|
108
108
|
"postcss-import": "^14.1.0",
|
|
109
109
|
"postcss-load-config": "^4.0.1",
|
|
110
|
-
"postcss-modules": "^
|
|
110
|
+
"postcss-modules": "^5.0.0",
|
|
111
111
|
"resolve.exports": "^1.1.0",
|
|
112
112
|
"rollup-plugin-license": "^2.8.1",
|
|
113
113
|
"sirv": "^2.0.2",
|
package/src/client/client.ts
CHANGED
|
@@ -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(
|
|
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,9 +186,10 @@ 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
|
-
console.
|
|
192
|
+
console.debug(`[vite] css hot updated: ${searchUrl}`)
|
|
188
193
|
}
|
|
189
194
|
})
|
|
190
195
|
break
|
|
@@ -395,52 +400,35 @@ async function fetchUpdate({ path, acceptedPath, timestamp }: Update) {
|
|
|
395
400
|
const moduleMap = new Map<string, ModuleNamespace>()
|
|
396
401
|
const isSelfUpdate = path === acceptedPath
|
|
397
402
|
|
|
398
|
-
// make sure we only import each dep once
|
|
399
|
-
const modulesToUpdate = new Set<string>()
|
|
400
|
-
if (isSelfUpdate) {
|
|
401
|
-
// self update - only update self
|
|
402
|
-
modulesToUpdate.add(path)
|
|
403
|
-
} else {
|
|
404
|
-
// dep update
|
|
405
|
-
for (const { deps } of mod.callbacks) {
|
|
406
|
-
deps.forEach((dep) => {
|
|
407
|
-
if (acceptedPath === dep) {
|
|
408
|
-
modulesToUpdate.add(dep)
|
|
409
|
-
}
|
|
410
|
-
})
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
|
|
414
403
|
// determine the qualified callbacks before we re-import the modules
|
|
415
|
-
const qualifiedCallbacks = mod.callbacks.filter(({ deps }) =>
|
|
416
|
-
|
|
417
|
-
})
|
|
418
|
-
|
|
419
|
-
await Promise.all(
|
|
420
|
-
Array.from(modulesToUpdate).map(async (dep) => {
|
|
421
|
-
const disposer = disposeMap.get(dep)
|
|
422
|
-
if (disposer) await disposer(dataMap.get(dep))
|
|
423
|
-
const [path, query] = dep.split(`?`)
|
|
424
|
-
try {
|
|
425
|
-
const newMod: ModuleNamespace = await import(
|
|
426
|
-
/* @vite-ignore */
|
|
427
|
-
base +
|
|
428
|
-
path.slice(1) +
|
|
429
|
-
`?import&t=${timestamp}${query ? `&${query}` : ''}`
|
|
430
|
-
)
|
|
431
|
-
moduleMap.set(dep, newMod)
|
|
432
|
-
} catch (e) {
|
|
433
|
-
warnFailedFetch(e, dep)
|
|
434
|
-
}
|
|
435
|
-
})
|
|
404
|
+
const qualifiedCallbacks = mod.callbacks.filter(({ deps }) =>
|
|
405
|
+
deps.includes(acceptedPath)
|
|
436
406
|
)
|
|
437
407
|
|
|
408
|
+
if (isSelfUpdate || qualifiedCallbacks.length > 0) {
|
|
409
|
+
const dep = acceptedPath
|
|
410
|
+
const disposer = disposeMap.get(dep)
|
|
411
|
+
if (disposer) await disposer(dataMap.get(dep))
|
|
412
|
+
const [path, query] = dep.split(`?`)
|
|
413
|
+
try {
|
|
414
|
+
const newMod: ModuleNamespace = await import(
|
|
415
|
+
/* @vite-ignore */
|
|
416
|
+
base +
|
|
417
|
+
path.slice(1) +
|
|
418
|
+
`?import&t=${timestamp}${query ? `&${query}` : ''}`
|
|
419
|
+
)
|
|
420
|
+
moduleMap.set(dep, newMod)
|
|
421
|
+
} catch (e) {
|
|
422
|
+
warnFailedFetch(e, dep)
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
|
|
438
426
|
return () => {
|
|
439
427
|
for (const { deps, fn } of qualifiedCallbacks) {
|
|
440
428
|
fn(deps.map((dep) => moduleMap.get(dep)))
|
|
441
429
|
}
|
|
442
430
|
const loggedPath = isSelfUpdate ? path : `${acceptedPath} via ${path}`
|
|
443
|
-
console.
|
|
431
|
+
console.debug(`[vite] hot updated: ${loggedPath}`)
|
|
444
432
|
}
|
|
445
433
|
}
|
|
446
434
|
|
package/types/chokidar.d.ts
CHANGED
|
@@ -194,7 +194,7 @@ export interface WatchOptions {
|
|
|
194
194
|
ignorePermissionErrors?: boolean
|
|
195
195
|
|
|
196
196
|
/**
|
|
197
|
-
* `true` if `useFsEvents` and `usePolling` are `false
|
|
197
|
+
* `true` if `useFsEvents` and `usePolling` are `false`. Automatically filters out artifacts
|
|
198
198
|
* that occur when using editors that use "atomic writes" instead of writing directly to the
|
|
199
199
|
* source file. If a file is re-added within 100 ms of being deleted, Chokidar emits a `change`
|
|
200
200
|
* event rather than `unlink` then `add`. If the default of 100 ms does not work well for you,
|
package/types/http-proxy.d.ts
CHANGED
|
@@ -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 -
|
|
60
|
+
* @param options - Additional options.
|
|
61
61
|
*/
|
|
62
62
|
web(
|
|
63
63
|
req: http.IncomingMessage,
|
package/types/importGlob.d.ts
CHANGED
|
@@ -38,7 +38,9 @@ export interface KnownAsTypeMap {
|
|
|
38
38
|
|
|
39
39
|
export interface ImportGlobFunction {
|
|
40
40
|
/**
|
|
41
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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[],
|