vite 6.0.0-alpha.16 → 6.0.0-alpha.18
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 +1 -59
- package/dist/client/client.mjs.map +1 -1
- package/dist/node/chunks/{dep-C0ketC3j.js → dep-70g8Z1cd.js} +3 -3
- package/dist/node/chunks/{dep-5iBxKK6m.js → dep-DXWVQosX.js} +10239 -15176
- package/dist/node/chunks/{dep-C1KLoAiP.js → dep-DlhHXrzk.js} +1 -1
- package/dist/node/cli.js +5 -5
- package/dist/node/index.d.ts +119 -91
- package/dist/node/index.js +2 -2
- package/dist/node/module-runner.d.ts +20 -9
- package/dist/node/module-runner.js +37 -52
- package/dist/node-cjs/publicUtils.cjs +2 -19
- package/package.json +9 -11
- package/types/customEvent.d.ts +2 -1
- package/types/{hmrPayload.d.ts → hotPayload.d.ts} +3 -1
@@ -51,24 +51,22 @@ function normalizeString(path, allowAboveRoot) {
|
|
51
51
|
char = "/";
|
52
52
|
}
|
53
53
|
if (char === "/") {
|
54
|
-
if (!(lastSlash === index - 1 || dots === 1))
|
55
|
-
if (
|
56
|
-
if (res.length
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
continue;
|
64
|
-
}
|
54
|
+
if (!(lastSlash === index - 1 || dots === 1)) if (dots === 2) {
|
55
|
+
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
56
|
+
if (res.length > 2) {
|
57
|
+
const lastSlashIndex = res.lastIndexOf("/");
|
58
|
+
lastSlashIndex === -1 ? (res = "", lastSegmentLength = 0) : (res = res.slice(0, lastSlashIndex), lastSegmentLength = res.length - 1 - res.lastIndexOf("/")), lastSlash = index, dots = 0;
|
59
|
+
continue;
|
60
|
+
} else if (res.length > 0) {
|
61
|
+
res = "", lastSegmentLength = 0, lastSlash = index, dots = 0;
|
62
|
+
continue;
|
65
63
|
}
|
66
|
-
|
67
|
-
|
68
|
-
|
64
|
+
}
|
65
|
+
allowAboveRoot && (res += res.length > 0 ? "/.." : "..", lastSegmentLength = 2);
|
66
|
+
} else
|
67
|
+
res.length > 0 ? res += `/${path.slice(lastSlash + 1, index)}` : res = path.slice(lastSlash + 1, index), lastSegmentLength = index - lastSlash - 1;
|
69
68
|
lastSlash = index, dots = 0;
|
70
|
-
} else
|
71
|
-
char === "." && dots !== -1 ? ++dots : dots = -1;
|
69
|
+
} else char === "." && dots !== -1 ? ++dots : dots = -1;
|
72
70
|
}
|
73
71
|
return res;
|
74
72
|
}
|
@@ -77,15 +75,7 @@ const isAbsolute = function(p) {
|
|
77
75
|
}, dirname = function(p) {
|
78
76
|
const segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
|
79
77
|
return segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0]) && (segments[0] += "/"), segments.join("/") || (isAbsolute(p) ? "/" : ".");
|
80
|
-
}, decodeBase64 = typeof atob < "u" ? atob : (str) => Buffer.from(str, "base64").toString("utf-8"), CHAR_FORWARD_SLASH = 47, CHAR_BACKWARD_SLASH = 92, percentRegEx = /%/g, backslashRegEx = /\\/g, newlineRegEx = /\n/g, carriageReturnRegEx = /\r/g, tabRegEx = /\t/g, questionRegex = /\?/g, hashRegex = /#/g
|
81
|
-
function parseUrl(url) {
|
82
|
-
const idQuery = url.split("?")[1];
|
83
|
-
let timestamp = 0;
|
84
|
-
return {
|
85
|
-
query: idQuery ? ("?" + idQuery).replace(timestampRegex, (substring, tsString, nextItem) => (timestamp = Number(tsString), substring[0] === "?" && nextItem === "&" ? "?" : "")) : "",
|
86
|
-
timestamp
|
87
|
-
};
|
88
|
-
}
|
78
|
+
}, decodeBase64 = typeof atob < "u" ? atob : (str) => Buffer.from(str, "base64").toString("utf-8"), CHAR_FORWARD_SLASH = 47, CHAR_BACKWARD_SLASH = 92, percentRegEx = /%/g, backslashRegEx = /\\/g, newlineRegEx = /\n/g, carriageReturnRegEx = /\r/g, tabRegEx = /\t/g, questionRegex = /\?/g, hashRegex = /#/g;
|
89
79
|
function encodePathChars(filepath) {
|
90
80
|
return filepath.indexOf("%") !== -1 && (filepath = filepath.replace(percentRegEx, "%25")), !isWindows && filepath.indexOf("\\") !== -1 && (filepath = filepath.replace(backslashRegEx, "%5C")), filepath.indexOf(`
|
91
81
|
`) !== -1 && (filepath = filepath.replace(newlineRegEx, "%0A")), filepath.indexOf("\r") !== -1 && (filepath = filepath.replace(carriageReturnRegEx, "%0D")), filepath.indexOf(" ") !== -1 && (filepath = filepath.replace(tabRegEx, "%09")), filepath;
|
@@ -503,11 +493,11 @@ class HMRClient {
|
|
503
493
|
}
|
504
494
|
}
|
505
495
|
function analyzeImportedModDifference(mod, rawId, moduleType, metadata) {
|
506
|
-
if (!metadata?.isDynamicImport &&
|
496
|
+
if (!metadata?.isDynamicImport && metadata?.importedNames?.length) {
|
507
497
|
const missingBindings = metadata.importedNames.filter((s) => !(s in mod));
|
508
498
|
if (missingBindings.length) {
|
509
499
|
const lastBinding = missingBindings[missingBindings.length - 1];
|
510
|
-
throw new SyntaxError(`[vite] Named export '${lastBinding}' not found. The requested module '${rawId}' is a CommonJS module, which may not support all module.exports as named exports.
|
500
|
+
throw moduleType === "module" ? new SyntaxError(`[vite] The requested module '${rawId}' does not provide an export named '${lastBinding}'`) : new SyntaxError(`[vite] Named export '${lastBinding}' not found. The requested module '${rawId}' is a CommonJS module, which may not support all module.exports as named exports.
|
511
501
|
CommonJS modules can always be imported via the default export, for example using:
|
512
502
|
|
513
503
|
import pkg from '${rawId}';
|
@@ -516,15 +506,6 @@ const {${missingBindings.join(", ")}} = pkg;
|
|
516
506
|
}
|
517
507
|
}
|
518
508
|
}
|
519
|
-
function proxyGuardOnlyEsm(mod, rawId, metadata) {
|
520
|
-
return metadata?.importedNames?.length ? new Proxy(mod, {
|
521
|
-
get(mod2, prop) {
|
522
|
-
if (prop !== "then" && !(prop in mod2))
|
523
|
-
throw new SyntaxError(`[vite] The requested module '${rawId}' does not provide an export named '${prop.toString()}'`);
|
524
|
-
return mod2[prop];
|
525
|
-
}
|
526
|
-
}) : mod;
|
527
|
-
}
|
528
509
|
const ssrModuleExportsKey = "__vite_ssr_exports__", ssrImportKey = "__vite_ssr_import__", ssrDynamicImportKey = "__vite_ssr_dynamic_import__", ssrExportAllKey = "__vite_ssr_exportAll__", ssrImportMetaKey = "__vite_ssr_import_meta__", noop = () => {
|
529
510
|
}, silentConsole = {
|
530
511
|
debug: noop,
|
@@ -535,9 +516,9 @@ const ssrModuleExportsKey = "__vite_ssr_exports__", ssrImportKey = "__vite_ssr_i
|
|
535
516
|
};
|
536
517
|
function createHMRHandler(runner) {
|
537
518
|
const queue = new Queue();
|
538
|
-
return (payload) => queue.enqueue(() =>
|
519
|
+
return (payload) => queue.enqueue(() => handleHotPayload(runner, payload));
|
539
520
|
}
|
540
|
-
async function
|
521
|
+
async function handleHotPayload(runner, payload) {
|
541
522
|
const hmrClient = runner.hmrClient;
|
542
523
|
if (!(!hmrClient || runner.isDestroyed()))
|
543
524
|
switch (payload.type) {
|
@@ -765,8 +746,7 @@ function CallSiteToString() {
|
|
765
746
|
typeName === "[object Object]" && (typeName = "null");
|
766
747
|
const methodName = this.getMethodName();
|
767
748
|
functionName ? (typeName && functionName.indexOf(typeName) !== 0 && (line += `${typeName}.`), line += functionName, methodName && functionName.indexOf(`.${methodName}`) !== functionName.length - methodName.length - 1 && (line += ` [as ${methodName}]`)) : line += `${typeName}.${methodName || "<anonymous>"}`;
|
768
|
-
} else
|
769
|
-
isConstructor ? line += `new ${functionName || "<anonymous>"}` : functionName ? line += functionName : (line += fileLocation, addSuffix = !1);
|
749
|
+
} else isConstructor ? line += `new ${functionName || "<anonymous>"}` : functionName ? line += functionName : (line += fileLocation, addSuffix = !1);
|
770
750
|
return addSuffix && (line += ` (${fileLocation})`), line;
|
771
751
|
}
|
772
752
|
function cloneCallSite(frame) {
|
@@ -852,10 +832,7 @@ class ModuleRunner {
|
|
852
832
|
resetSourceMapSupport;
|
853
833
|
destroyed = !1;
|
854
834
|
constructor(options, evaluator, debug) {
|
855
|
-
this.options = options, this.evaluator = evaluator, this.debug = debug, this.moduleCache = options.moduleCache ?? new ModuleCacheMap(options.root), this.transport = options.transport, typeof options.hmr == "object" && (this.hmrClient = new HMRClient(options.hmr.logger === !1 ? silentConsole : options.hmr.logger || hmrLogger, options.hmr.connection, ({ acceptedPath,
|
856
|
-
const [acceptedPathWithoutQuery, query] = acceptedPath.split("?"), url = acceptedPathWithoutQuery + `?${explicitImportRequired ? "import&" : ""}t=${timestamp}${query ? `&${query}` : ""}`;
|
857
|
-
return this.import(url);
|
858
|
-
}), options.hmr.connection.onUpdate(createHMRHandler(this))), options.sourcemapInterceptor !== !1 && (this.resetSourceMapSupport = enableSourceMapSupport(this));
|
835
|
+
this.options = options, this.evaluator = evaluator, this.debug = debug, this.moduleCache = options.moduleCache ?? new ModuleCacheMap(options.root), this.transport = options.transport, typeof options.hmr == "object" && (this.hmrClient = new HMRClient(options.hmr.logger === !1 ? silentConsole : options.hmr.logger || hmrLogger, options.hmr.connection, ({ acceptedPath }) => this.import(acceptedPath)), options.hmr.connection.onUpdate(createHMRHandler(this))), options.sourcemapInterceptor !== !1 && (this.resetSourceMapSupport = enableSourceMapSupport(this));
|
859
836
|
}
|
860
837
|
/**
|
861
838
|
* URL to execute. Accepts file path, server path or id relative to the root.
|
@@ -898,7 +875,7 @@ class ModuleRunner {
|
|
898
875
|
if (!("externalize" in fetchResult))
|
899
876
|
return exports;
|
900
877
|
const { id, type } = fetchResult;
|
901
|
-
return type !== "module" && type !== "commonjs"
|
878
|
+
return type !== "module" && type !== "commonjs" || analyzeImportedModDifference(exports, id, type, metadata), exports;
|
902
879
|
}
|
903
880
|
async cachedRequest(id, mod, callstack = [], metadata) {
|
904
881
|
const meta = mod.meta, moduleId = meta.id, { imports, importers } = mod, importee = callstack[callstack.length - 1];
|
@@ -924,15 +901,23 @@ ${getStack()}`);
|
|
924
901
|
async cachedModule(url, importer) {
|
925
902
|
if (this.destroyed)
|
926
903
|
throw new Error("Vite module runner has been destroyed.");
|
904
|
+
this.debug?.("[module runner] fetching", url);
|
927
905
|
const normalized = this.urlToIdMap.get(url);
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
906
|
+
let cachedModule = normalized && this.moduleCache.getByModuleId(normalized);
|
907
|
+
cachedModule || (cachedModule = this.moduleCache.getByModuleId(url));
|
908
|
+
const isCached = !!(typeof cachedModule == "object" && cachedModule.meta), fetchedModule = (
|
909
|
+
// fast return for established externalized pattern
|
910
|
+
url.startsWith("data:") ? { externalize: url, type: "builtin" } : await this.transport.fetchModule(url, importer, {
|
911
|
+
cached: isCached
|
912
|
+
})
|
913
|
+
);
|
914
|
+
if ("cache" in fetchedModule) {
|
915
|
+
if (!cachedModule || !cachedModule.meta)
|
916
|
+
throw new Error(`Module "${url}" was mistakenly invalidated during fetch phase.`);
|
917
|
+
return cachedModule;
|
932
918
|
}
|
933
|
-
|
934
|
-
|
935
|
-
if (mod.timestamp != null && timestamp > 0 && mod.timestamp < timestamp && this.moduleCache.invalidateModule(mod), fetchedModule.id = moduleId, mod.meta = fetchedModule, mod.timestamp = timestamp, file) {
|
919
|
+
const idQuery = url.split("?")[1], query = idQuery ? `?${idQuery}` : "", file = "file" in fetchedModule ? fetchedModule.file : void 0, fileId = file ? `${file}${query}` : url, moduleId = this.moduleCache.normalize(fileId), mod = this.moduleCache.getByModuleId(moduleId);
|
920
|
+
if ("invalidate" in fetchedModule && fetchedModule.invalidate && this.moduleCache.invalidateModule(mod), fetchedModule.id = moduleId, mod.meta = fetchedModule, file) {
|
936
921
|
const fileModules = this.fileToIdMap.get(file) || [];
|
937
922
|
fileModules.push(moduleId), this.fileToIdMap.set(file, fileModules);
|
938
923
|
}
|
@@ -1127,11 +1127,11 @@ function requireNode () {
|
|
1127
1127
|
}
|
1128
1128
|
|
1129
1129
|
/**
|
1130
|
-
* Invokes `util.
|
1130
|
+
* Invokes `util.formatWithOptions()` with the specified arguments and writes to stderr.
|
1131
1131
|
*/
|
1132
1132
|
|
1133
1133
|
function log(...args) {
|
1134
|
-
return process.stderr.write(util.
|
1134
|
+
return process.stderr.write(util.formatWithOptions(exports.inspectOpts, ...args) + '\n');
|
1135
1135
|
}
|
1136
1136
|
|
1137
1137
|
/**
|
@@ -3591,22 +3591,6 @@ function normalizeSingleAlias({ find, replacement, customResolver, }) {
|
|
3591
3591
|
}
|
3592
3592
|
return alias;
|
3593
3593
|
}
|
3594
|
-
/**
|
3595
|
-
* Creates a function that hides the complexities of a WeakMap with an initial value
|
3596
|
-
* to implement object metadata. Used by plugins to implement cross hooks per
|
3597
|
-
* environment metadata
|
3598
|
-
*/
|
3599
|
-
function createWeakData(initial) {
|
3600
|
-
const cache = new WeakMap();
|
3601
|
-
return function (key) {
|
3602
|
-
let data = cache.get(key);
|
3603
|
-
if (!data) {
|
3604
|
-
data = initial(key);
|
3605
|
-
cache.set(key, data);
|
3606
|
-
}
|
3607
|
-
return data;
|
3608
|
-
};
|
3609
|
-
}
|
3610
3594
|
|
3611
3595
|
// This file will be built for both ESM and CJS. Avoid relying on other modules as possible.
|
3612
3596
|
// copy from constants.ts
|
@@ -6255,7 +6239,6 @@ function resolveEnvPrefix({ envPrefix = 'VITE_', }) {
|
|
6255
6239
|
exports.esbuildVersion = esbuild.version;
|
6256
6240
|
exports.createFilter = createFilter;
|
6257
6241
|
exports.createLogger = createLogger;
|
6258
|
-
exports.createWeakData = createWeakData;
|
6259
6242
|
exports.isCSSRequest = isCSSRequest;
|
6260
6243
|
exports.isFileLoadingAllowed = isFileLoadingAllowed;
|
6261
6244
|
exports.isFileServingAllowed = isFileServingAllowed;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "vite",
|
3
|
-
"version": "6.0.0-alpha.
|
3
|
+
"version": "6.0.0-alpha.18",
|
4
4
|
"type": "module",
|
5
5
|
"license": "MIT",
|
6
6
|
"author": "Evan You",
|
@@ -72,7 +72,7 @@
|
|
72
72
|
"funding": "https://github.com/vitejs/vite?sponsor=1",
|
73
73
|
"//": "READ CONTRIBUTING.md to understand what to put under deps vs. devDeps!",
|
74
74
|
"dependencies": {
|
75
|
-
"esbuild": "^0.
|
75
|
+
"esbuild": "^0.21.3",
|
76
76
|
"postcss": "^8.4.38",
|
77
77
|
"rollup": "^4.13.0"
|
78
78
|
},
|
@@ -81,11 +81,11 @@
|
|
81
81
|
},
|
82
82
|
"devDependencies": {
|
83
83
|
"@ampproject/remapping": "^2.3.0",
|
84
|
-
"@babel/parser": "^7.24.
|
84
|
+
"@babel/parser": "^7.24.6",
|
85
85
|
"@jridgewell/trace-mapping": "^0.3.25",
|
86
86
|
"@polka/compression": "^1.0.0-next.25",
|
87
87
|
"@rollup/plugin-alias": "^5.1.0",
|
88
|
-
"@rollup/plugin-commonjs": "^25.0.
|
88
|
+
"@rollup/plugin-commonjs": "^25.0.8",
|
89
89
|
"@rollup/plugin-dynamic-import-vars": "^2.1.2",
|
90
90
|
"@rollup/plugin-json": "^6.1.0",
|
91
91
|
"@rollup/plugin-node-resolve": "15.2.3",
|
@@ -93,8 +93,6 @@
|
|
93
93
|
"@rollup/pluginutils": "^5.1.0",
|
94
94
|
"@types/escape-html": "^1.0.4",
|
95
95
|
"@types/pnpapi": "^0.0.5",
|
96
|
-
"acorn": "^8.11.3",
|
97
|
-
"acorn-walk": "^8.3.2",
|
98
96
|
"artichokie": "^0.2.1",
|
99
97
|
"cac": "^6.7.14",
|
100
98
|
"chokidar": "^3.6.0",
|
@@ -102,7 +100,7 @@
|
|
102
100
|
"convert-source-map": "^2.0.0",
|
103
101
|
"cors": "^2.8.5",
|
104
102
|
"cross-spawn": "^7.0.3",
|
105
|
-
"debug": "^4.3.
|
103
|
+
"debug": "^4.3.5",
|
106
104
|
"dep-types": "link:./src/types",
|
107
105
|
"dotenv": "^16.4.5",
|
108
106
|
"dotenv-expand": "^11.0.6",
|
@@ -113,9 +111,9 @@
|
|
113
111
|
"fast-glob": "^3.3.2",
|
114
112
|
"http-proxy": "^1.18.1",
|
115
113
|
"launch-editor-middleware": "^2.6.1",
|
116
|
-
"lightningcss": "^1.25.
|
114
|
+
"lightningcss": "^1.25.1",
|
117
115
|
"magic-string": "^0.30.10",
|
118
|
-
"micromatch": "^4.0.
|
116
|
+
"micromatch": "^4.0.7",
|
119
117
|
"mlly": "^1.7.0",
|
120
118
|
"mrmime": "^2.0.0",
|
121
119
|
"open": "^8.4.2",
|
@@ -131,12 +129,12 @@
|
|
131
129
|
"rollup-plugin-dts": "^6.1.1",
|
132
130
|
"rollup-plugin-esbuild": "^6.1.1",
|
133
131
|
"rollup-plugin-license": "^3.4.0",
|
134
|
-
"sass": "^1.77.
|
132
|
+
"sass": "^1.77.4",
|
135
133
|
"sirv": "^2.0.4",
|
136
134
|
"source-map-support": "^0.5.21",
|
137
135
|
"strip-ansi": "^7.1.0",
|
138
136
|
"strip-literal": "^2.1.0",
|
139
|
-
"tsconfck": "^3.0
|
137
|
+
"tsconfck": "^3.1.0",
|
140
138
|
"tslib": "^2.6.2",
|
141
139
|
"types": "link:./types",
|
142
140
|
"ufo": "^1.5.3",
|
package/types/customEvent.d.ts
CHANGED
@@ -3,7 +3,7 @@ import type {
|
|
3
3
|
FullReloadPayload,
|
4
4
|
PrunePayload,
|
5
5
|
UpdatePayload,
|
6
|
-
} from './
|
6
|
+
} from './hotPayload'
|
7
7
|
|
8
8
|
export interface CustomEventMap {
|
9
9
|
'vite:beforeUpdate': UpdatePayload
|
@@ -23,6 +23,7 @@ export interface WebSocketConnectionPayload {
|
|
23
23
|
* This might be removed in the future if we didn't find reasonable use cases.
|
24
24
|
* If you find this useful, please open an issue with details so we can discuss and make it stable API.
|
25
25
|
*/
|
26
|
+
// eslint-disable-next-line n/no-unsupported-features/node-builtins
|
26
27
|
webSocket: WebSocket
|
27
28
|
}
|
28
29
|
|