vite 4.4.9 → 5.0.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/client.d.ts +5 -5
- package/dist/client/client.mjs +6 -7
- package/dist/client/client.mjs.map +1 -1
- package/dist/node/chunks/{dep-73522cdf.js → dep-6db0c752.js} +1 -1
- package/dist/node/chunks/{dep-e0331088.js → dep-c457d7ce.js} +1 -1
- package/dist/node/chunks/{dep-df561101.js → dep-e31699fa.js} +358 -224
- package/dist/node/cli.js +30 -10
- package/dist/node/index.d.ts +41 -18
- package/dist/node/index.js +3 -2
- package/dist/node-cjs/publicUtils.cjs +1275 -12
- package/package.json +22 -20
- package/types/importGlob.d.ts +0 -24
- package/types/importMeta.d.ts +0 -4
package/dist/node/cli.js
CHANGED
|
@@ -2,7 +2,7 @@ import path from 'node:path';
|
|
|
2
2
|
import fs from 'node:fs';
|
|
3
3
|
import { performance } from 'node:perf_hooks';
|
|
4
4
|
import { EventEmitter } from 'events';
|
|
5
|
-
import { C as colors,
|
|
5
|
+
import { C as colors, x as createLogger, h as resolveConfig } from './chunks/dep-e31699fa.js';
|
|
6
6
|
import { VERSION } from './constants.js';
|
|
7
7
|
import 'node:fs/promises';
|
|
8
8
|
import 'node:url';
|
|
@@ -714,9 +714,29 @@ function cleanOptions(options) {
|
|
|
714
714
|
}
|
|
715
715
|
return ret;
|
|
716
716
|
}
|
|
717
|
+
/**
|
|
718
|
+
* host may be a number (like 0), should convert to string
|
|
719
|
+
*/
|
|
720
|
+
const convertHost = (v) => {
|
|
721
|
+
if (typeof v === 'number') {
|
|
722
|
+
return String(v);
|
|
723
|
+
}
|
|
724
|
+
return v;
|
|
725
|
+
};
|
|
726
|
+
/**
|
|
727
|
+
* base may be a number (like 0), should convert to empty string
|
|
728
|
+
*/
|
|
729
|
+
const convertBase = (v) => {
|
|
730
|
+
if (v === 0) {
|
|
731
|
+
return '';
|
|
732
|
+
}
|
|
733
|
+
return v;
|
|
734
|
+
};
|
|
717
735
|
cli
|
|
718
736
|
.option('-c, --config <file>', `[string] use specified config file`)
|
|
719
|
-
.option('--base <path>', `[string] public base path (default: /)
|
|
737
|
+
.option('--base <path>', `[string] public base path (default: /)`, {
|
|
738
|
+
type: [convertBase],
|
|
739
|
+
})
|
|
720
740
|
.option('-l, --logLevel <level>', `[string] info | warn | error | silent`)
|
|
721
741
|
.option('--clearScreen', `[boolean] allow/disable clear screen when logging`)
|
|
722
742
|
.option('-d, --debug [feat]', `[string | boolean] show debug logs`)
|
|
@@ -727,7 +747,7 @@ cli
|
|
|
727
747
|
.command('[root]', 'start dev server') // default command
|
|
728
748
|
.alias('serve') // the command is called 'serve' in Vite's API
|
|
729
749
|
.alias('dev') // alias to align with the script name
|
|
730
|
-
.option('--host [host]', `[string] specify hostname
|
|
750
|
+
.option('--host [host]', `[string] specify hostname`, { type: [convertHost] })
|
|
731
751
|
.option('--port <port>', `[number] specify port`)
|
|
732
752
|
.option('--https', `[boolean] use TLS + HTTP/2`)
|
|
733
753
|
.option('--open [path]', `[boolean | string] open browser on startup`)
|
|
@@ -738,7 +758,7 @@ cli
|
|
|
738
758
|
filterDuplicateOptions(options);
|
|
739
759
|
// output structure is preserved even after bundling so require()
|
|
740
760
|
// is ok here
|
|
741
|
-
const { createServer } = await import('./chunks/dep-
|
|
761
|
+
const { createServer } = await import('./chunks/dep-e31699fa.js').then(function (n) { return n.H; });
|
|
742
762
|
try {
|
|
743
763
|
const server = await createServer({
|
|
744
764
|
root,
|
|
@@ -761,7 +781,7 @@ cli
|
|
|
761
781
|
: '';
|
|
762
782
|
info(`\n ${colors.green(`${colors.bold('VITE')} v${VERSION}`)} ${startupDurationString}\n`, { clear: !server.config.logger.hasWarned });
|
|
763
783
|
server.printUrls();
|
|
764
|
-
|
|
784
|
+
server.bindCLIShortcuts({
|
|
765
785
|
print: true,
|
|
766
786
|
customShortcuts: [
|
|
767
787
|
profileSession && {
|
|
@@ -816,7 +836,7 @@ cli
|
|
|
816
836
|
.option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
|
|
817
837
|
.action(async (root, options) => {
|
|
818
838
|
filterDuplicateOptions(options);
|
|
819
|
-
const { build } = await import('./chunks/dep-
|
|
839
|
+
const { build } = await import('./chunks/dep-e31699fa.js').then(function (n) { return n.G; });
|
|
820
840
|
const buildOptions = cleanOptions(options);
|
|
821
841
|
try {
|
|
822
842
|
await build({
|
|
@@ -844,7 +864,7 @@ cli
|
|
|
844
864
|
.option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
|
|
845
865
|
.action(async (root, options) => {
|
|
846
866
|
filterDuplicateOptions(options);
|
|
847
|
-
const { optimizeDeps } = await import('./chunks/dep-
|
|
867
|
+
const { optimizeDeps } = await import('./chunks/dep-e31699fa.js').then(function (n) { return n.F; });
|
|
848
868
|
try {
|
|
849
869
|
const config = await resolveConfig({
|
|
850
870
|
root,
|
|
@@ -863,7 +883,7 @@ cli
|
|
|
863
883
|
// preview
|
|
864
884
|
cli
|
|
865
885
|
.command('preview [root]', 'locally preview production build')
|
|
866
|
-
.option('--host [host]', `[string] specify hostname
|
|
886
|
+
.option('--host [host]', `[string] specify hostname`, { type: [convertHost] })
|
|
867
887
|
.option('--port <port>', `[number] specify port`)
|
|
868
888
|
.option('--strictPort', `[boolean] exit if specified port is already in use`)
|
|
869
889
|
.option('--https', `[boolean] use TLS + HTTP/2`)
|
|
@@ -871,7 +891,7 @@ cli
|
|
|
871
891
|
.option('--outDir <dir>', `[string] output directory (default: dist)`)
|
|
872
892
|
.action(async (root, options) => {
|
|
873
893
|
filterDuplicateOptions(options);
|
|
874
|
-
const { preview } = await import('./chunks/dep-
|
|
894
|
+
const { preview } = await import('./chunks/dep-e31699fa.js').then(function (n) { return n.I; });
|
|
875
895
|
try {
|
|
876
896
|
const server = await preview({
|
|
877
897
|
root,
|
|
@@ -891,7 +911,7 @@ cli
|
|
|
891
911
|
},
|
|
892
912
|
});
|
|
893
913
|
server.printUrls();
|
|
894
|
-
|
|
914
|
+
server.bindCLIShortcuts({ print: true });
|
|
895
915
|
}
|
|
896
916
|
catch (e) {
|
|
897
917
|
createLogger(options.logLevel).error(colors.red(`error when starting preview server:\n${e.stack}`), { error: e });
|
package/dist/node/index.d.ts
CHANGED
|
@@ -23,7 +23,6 @@ import { GeneralImportGlobOptions } from "../../types/importGlob.js";
|
|
|
23
23
|
import type { GetManualChunk } from 'rollup';
|
|
24
24
|
import { HMRPayload } from "../../types/hmrPayload.js";
|
|
25
25
|
import * as http from 'node:http';
|
|
26
|
-
import { ImportGlobEagerFunction } from "../../types/importGlob.js";
|
|
27
26
|
import { ImportGlobFunction } from "../../types/importGlob.js";
|
|
28
27
|
import { ImportGlobOptions } from "../../types/importGlob.js";
|
|
29
28
|
import type { IncomingMessage } from 'node:http';
|
|
@@ -120,6 +119,14 @@ export declare interface AwaitWriteFinishOptions {
|
|
|
120
119
|
pollInterval?: number
|
|
121
120
|
}
|
|
122
121
|
|
|
122
|
+
export declare type BindCLIShortcutsOptions<Server = ViteDevServer | PreviewServer> = {
|
|
123
|
+
/**
|
|
124
|
+
* Print a one line hint to the terminal.
|
|
125
|
+
*/
|
|
126
|
+
print?: boolean;
|
|
127
|
+
customShortcuts?: (CLIShortcut<Server> | undefined | null)[];
|
|
128
|
+
};
|
|
129
|
+
|
|
123
130
|
/**
|
|
124
131
|
* Bundles the app for production.
|
|
125
132
|
* Returns a Promise containing the build result.
|
|
@@ -174,7 +181,7 @@ export declare interface BuildOptions {
|
|
|
174
181
|
assetsDir?: string;
|
|
175
182
|
/**
|
|
176
183
|
* Static asset files smaller than this number (in bytes) will be inlined as
|
|
177
|
-
* base64 strings. Default limit is `4096` (
|
|
184
|
+
* base64 strings. Default limit is `4096` (4 KiB). Set to `0` to disable.
|
|
178
185
|
* @default 4096
|
|
179
186
|
*/
|
|
180
187
|
assetsInlineLimit?: number;
|
|
@@ -246,7 +253,6 @@ export declare interface BuildOptions {
|
|
|
246
253
|
/**
|
|
247
254
|
* Copy the public directory to outDir on write.
|
|
248
255
|
* @default true
|
|
249
|
-
* @experimental
|
|
250
256
|
*/
|
|
251
257
|
copyPublicDir?: boolean;
|
|
252
258
|
/**
|
|
@@ -301,7 +307,7 @@ export declare interface BuildOptions {
|
|
|
301
307
|
*/
|
|
302
308
|
reportCompressedSize?: boolean;
|
|
303
309
|
/**
|
|
304
|
-
* Adjust chunk size warning limit (in
|
|
310
|
+
* Adjust chunk size warning limit (in kB).
|
|
305
311
|
* @default 500
|
|
306
312
|
*/
|
|
307
313
|
chunkSizeWarningLimit?: number;
|
|
@@ -315,6 +321,12 @@ export declare interface BuildOptions {
|
|
|
315
321
|
|
|
316
322
|
export { ChunkMetadata }
|
|
317
323
|
|
|
324
|
+
export declare type CLIShortcut<Server = ViteDevServer | PreviewServer> = {
|
|
325
|
+
key: string;
|
|
326
|
+
description: string;
|
|
327
|
+
action(server: Server): void | Promise<void>;
|
|
328
|
+
};
|
|
329
|
+
|
|
318
330
|
export declare interface CommonServerOptions {
|
|
319
331
|
/**
|
|
320
332
|
* Specify server port. Note if the port is already being used, Vite will
|
|
@@ -1181,8 +1193,6 @@ export declare namespace HttpProxy {
|
|
|
1181
1193
|
}
|
|
1182
1194
|
}
|
|
1183
1195
|
|
|
1184
|
-
export { ImportGlobEagerFunction }
|
|
1185
|
-
|
|
1186
1196
|
export { ImportGlobFunction }
|
|
1187
1197
|
|
|
1188
1198
|
export { ImportGlobOptions }
|
|
@@ -1592,7 +1602,7 @@ declare interface Plugin_2 extends Plugin_3 {
|
|
|
1592
1602
|
*/
|
|
1593
1603
|
configureServer?: ObjectHook<ServerHook>;
|
|
1594
1604
|
/**
|
|
1595
|
-
* Configure the preview server. The hook receives the {@link
|
|
1605
|
+
* Configure the preview server. The hook receives the {@link PreviewServer}
|
|
1596
1606
|
* instance. This can also be used to store a reference to the server
|
|
1597
1607
|
* for use in other hooks.
|
|
1598
1608
|
*
|
|
@@ -1669,7 +1679,9 @@ export declare interface PluginContainer {
|
|
|
1669
1679
|
ssr?: boolean;
|
|
1670
1680
|
}): Promise<{
|
|
1671
1681
|
code: string;
|
|
1672
|
-
map: SourceMap |
|
|
1682
|
+
map: SourceMap | {
|
|
1683
|
+
mappings: '';
|
|
1684
|
+
} | null;
|
|
1673
1685
|
}>;
|
|
1674
1686
|
load(id: string, options?: {
|
|
1675
1687
|
ssr?: boolean;
|
|
@@ -1704,11 +1716,7 @@ export declare function preview(inlineConfig?: InlineConfig): Promise<PreviewSer
|
|
|
1704
1716
|
export declare interface PreviewOptions extends CommonServerOptions {
|
|
1705
1717
|
}
|
|
1706
1718
|
|
|
1707
|
-
export declare interface PreviewServer
|
|
1708
|
-
resolvedUrls: ResolvedServerUrls;
|
|
1709
|
-
}
|
|
1710
|
-
|
|
1711
|
-
export declare interface PreviewServerForHook {
|
|
1719
|
+
export declare interface PreviewServer {
|
|
1712
1720
|
/**
|
|
1713
1721
|
* The resolved vite config object
|
|
1714
1722
|
*/
|
|
@@ -1727,16 +1735,21 @@ export declare interface PreviewServerForHook {
|
|
|
1727
1735
|
*/
|
|
1728
1736
|
httpServer: http.Server;
|
|
1729
1737
|
/**
|
|
1730
|
-
* The resolved urls Vite prints on the CLI
|
|
1738
|
+
* The resolved urls Vite prints on the CLI.
|
|
1739
|
+
* null before server is listening.
|
|
1731
1740
|
*/
|
|
1732
1741
|
resolvedUrls: ResolvedServerUrls | null;
|
|
1733
1742
|
/**
|
|
1734
1743
|
* Print server urls
|
|
1735
1744
|
*/
|
|
1736
1745
|
printUrls(): void;
|
|
1746
|
+
/**
|
|
1747
|
+
* Bind CLI shortcuts
|
|
1748
|
+
*/
|
|
1749
|
+
bindCLIShortcuts(options?: BindCLIShortcutsOptions<PreviewServer>): void;
|
|
1737
1750
|
}
|
|
1738
1751
|
|
|
1739
|
-
export declare type PreviewServerHook = (this: void, server:
|
|
1752
|
+
export declare type PreviewServerHook = (this: void, server: PreviewServer) => (() => void) | void | Promise<(() => void) | void>;
|
|
1740
1753
|
|
|
1741
1754
|
export declare interface ProxyOptions extends HttpProxy.ServerOptions {
|
|
1742
1755
|
/**
|
|
@@ -2170,7 +2183,9 @@ export declare interface SendOptions {
|
|
|
2170
2183
|
etag?: string;
|
|
2171
2184
|
cacheControl?: string;
|
|
2172
2185
|
headers?: OutgoingHttpHeaders;
|
|
2173
|
-
map?: SourceMap |
|
|
2186
|
+
map?: SourceMap | {
|
|
2187
|
+
mappings: '';
|
|
2188
|
+
} | null;
|
|
2174
2189
|
}
|
|
2175
2190
|
|
|
2176
2191
|
export declare type ServerHook = (this: void, server: ViteDevServer) => (() => void) | void | Promise<(() => void) | void>;
|
|
@@ -2507,7 +2522,9 @@ export declare interface TransformOptions {
|
|
|
2507
2522
|
|
|
2508
2523
|
export declare interface TransformResult {
|
|
2509
2524
|
code: string;
|
|
2510
|
-
map: SourceMap |
|
|
2525
|
+
map: SourceMap | {
|
|
2526
|
+
mappings: '';
|
|
2527
|
+
} | null;
|
|
2511
2528
|
etag?: string;
|
|
2512
2529
|
deps?: string[];
|
|
2513
2530
|
dynamicDeps?: string[];
|
|
@@ -2737,7 +2754,9 @@ export declare interface ViteDevServer {
|
|
|
2737
2754
|
/**
|
|
2738
2755
|
* Transform module code into SSR format.
|
|
2739
2756
|
*/
|
|
2740
|
-
ssrTransform(code: string, inMap: SourceMap |
|
|
2757
|
+
ssrTransform(code: string, inMap: SourceMap | {
|
|
2758
|
+
mappings: '';
|
|
2759
|
+
} | null, url: string, originalCode?: string): Promise<TransformResult | null>;
|
|
2741
2760
|
/**
|
|
2742
2761
|
* Load a given URL as an instantiated module for SSR.
|
|
2743
2762
|
*/
|
|
@@ -2769,6 +2788,10 @@ export declare interface ViteDevServer {
|
|
|
2769
2788
|
* Print server urls
|
|
2770
2789
|
*/
|
|
2771
2790
|
printUrls(): void;
|
|
2791
|
+
/**
|
|
2792
|
+
* Bind CLI shortcuts
|
|
2793
|
+
*/
|
|
2794
|
+
bindCLIShortcuts(options?: BindCLIShortcutsOptions<ViteDevServer>): void;
|
|
2772
2795
|
/**
|
|
2773
2796
|
* Restart the server.
|
|
2774
2797
|
*
|
package/dist/node/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as isInNodeModules } from './chunks/dep-
|
|
2
|
-
export { b as build, e as buildErrorMessage, v as createFilter, x as createLogger, c as createServer, g as defineConfig, f as formatPostcssSourceMap, k as getDepOptimizationConfig, m as isDepsOptimizerEnabled, z as isFileServingAllowed, l as loadConfigFromFile, A as loadEnv, u as mergeAlias, q as mergeConfig, n as normalizePath, o as optimizeDeps, a as preprocessCSS, p as preview, j as resolveBaseUrl, h as resolveConfig, B as resolveEnvPrefix, d as resolvePackageData, r as resolvePackageEntry, y as searchForWorkspaceRoot, w as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-
|
|
1
|
+
import { i as isInNodeModules } from './chunks/dep-e31699fa.js';
|
|
2
|
+
export { b as build, e as buildErrorMessage, v as createFilter, x as createLogger, c as createServer, g as defineConfig, f as formatPostcssSourceMap, k as getDepOptimizationConfig, m as isDepsOptimizerEnabled, z as isFileServingAllowed, l as loadConfigFromFile, A as loadEnv, u as mergeAlias, q as mergeConfig, n as normalizePath, o as optimizeDeps, a as preprocessCSS, p as preview, j as resolveBaseUrl, h as resolveConfig, B as resolveEnvPrefix, d as resolvePackageData, r as resolvePackageEntry, y as searchForWorkspaceRoot, w as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-e31699fa.js';
|
|
3
3
|
export { VERSION as version } from './constants.js';
|
|
4
4
|
export { version as esbuildVersion } from 'esbuild';
|
|
5
5
|
export { VERSION as rollupVersion } from 'rollup';
|
|
@@ -57,6 +57,7 @@ const isCSSRequest = (request) => CSS_LANGS_RE.test(request);
|
|
|
57
57
|
// The cache needs to be reset on buildStart for watch mode to work correctly
|
|
58
58
|
// Don't use this manualChunks strategy for ssr, lib mode, and 'umd' or 'iife'
|
|
59
59
|
class SplitVendorChunkCache {
|
|
60
|
+
cache;
|
|
60
61
|
constructor() {
|
|
61
62
|
this.cache = new Map();
|
|
62
63
|
}
|