vite 7.0.6 → 7.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.
@@ -1,9 +1,8 @@
1
- const VALID_ID_PREFIX = "/@id/", NULL_BYTE_PLACEHOLDER = "__x00__";
2
1
  let SOURCEMAPPING_URL = "sourceMa";
3
2
  SOURCEMAPPING_URL += "ppingURL";
4
- const ERR_OUTDATED_OPTIMIZED_DEP = "ERR_OUTDATED_OPTIMIZED_DEP", isWindows = typeof process < "u" && process.platform === "win32";
3
+ const isWindows = typeof process < "u" && process.platform === "win32";
5
4
  function unwrapId(id) {
6
- return id.startsWith(VALID_ID_PREFIX) ? id.slice(5).replace(NULL_BYTE_PLACEHOLDER, "\0") : id;
5
+ return id.startsWith("/@id/") ? id.slice(5).replace("__x00__", "\0") : id;
7
6
  }
8
7
  const windowsSlashRE = /\\/g;
9
8
  function slash(p) {
@@ -82,21 +81,21 @@ const isAbsolute = function(p) {
82
81
  }, dirname = function(p) {
83
82
  let segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
84
83
  return segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0]) && (segments[0] += "/"), segments.join("/") || (isAbsolute(p) ? "/" : ".");
85
- }, 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;
84
+ }, decodeBase64 = typeof atob < "u" ? atob : (str) => Buffer.from(str, "base64").toString("utf-8"), percentRegEx = /%/g, backslashRegEx = /\\/g, newlineRegEx = /\n/g, carriageReturnRegEx = /\r/g, tabRegEx = /\t/g, questionRegex = /\?/g, hashRegex = /#/g;
86
85
  function encodePathChars(filepath) {
87
86
  return filepath.indexOf("%") !== -1 && (filepath = filepath.replace(percentRegEx, "%25")), !isWindows && filepath.indexOf("\\") !== -1 && (filepath = filepath.replace(backslashRegEx, "%5C")), filepath.indexOf("\n") !== -1 && (filepath = filepath.replace(newlineRegEx, "%0A")), filepath.indexOf("\r") !== -1 && (filepath = filepath.replace(carriageReturnRegEx, "%0D")), filepath.indexOf(" ") !== -1 && (filepath = filepath.replace(tabRegEx, "%09")), filepath;
88
87
  }
89
88
  const posixDirname = dirname, posixResolve = resolve;
90
89
  function posixPathToFileHref(posixPath) {
91
90
  let resolved = posixResolve(posixPath), filePathLast = posixPath.charCodeAt(posixPath.length - 1);
92
- return (filePathLast === CHAR_FORWARD_SLASH || isWindows && filePathLast === CHAR_BACKWARD_SLASH) && resolved[resolved.length - 1] !== "/" && (resolved += "/"), resolved = encodePathChars(resolved), resolved.indexOf("?") !== -1 && (resolved = resolved.replace(questionRegex, "%3F")), resolved.indexOf("#") !== -1 && (resolved = resolved.replace(hashRegex, "%23")), new URL(`file://${resolved}`).href;
91
+ return (filePathLast === 47 || isWindows && filePathLast === 92) && resolved[resolved.length - 1] !== "/" && (resolved += "/"), resolved = encodePathChars(resolved), resolved.indexOf("?") !== -1 && (resolved = resolved.replace(questionRegex, "%3F")), resolved.indexOf("#") !== -1 && (resolved = resolved.replace(hashRegex, "%23")), new URL(`file://${resolved}`).href;
93
92
  }
94
93
  function toWindowsPath(path) {
95
94
  return path.replace(/\//g, "\\");
96
95
  }
97
- const comma = 44, chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", intToChar = new Uint8Array(64), charToInt = new Uint8Array(128);
96
+ const intToChar = new Uint8Array(64), charToInt = new Uint8Array(128);
98
97
  for (let i = 0; i < 64; i++) {
99
- let c = chars.charCodeAt(i);
98
+ let c = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charCodeAt(i);
100
99
  intToChar[i] = c, charToInt[c] = i;
101
100
  }
102
101
  function decodeInteger(reader, relative) {
@@ -109,7 +108,7 @@ function decodeInteger(reader, relative) {
109
108
  return value >>>= 1, shouldNegate && (value = -2147483648 | -value), relative + value;
110
109
  }
111
110
  function hasMoreVlq(reader, max) {
112
- return reader.pos >= max ? !1 : reader.peek() !== comma;
111
+ return reader.pos >= max ? !1 : reader.peek() !== 44;
113
112
  }
114
113
  var StringReader = class {
115
114
  constructor(buffer) {
@@ -465,9 +464,9 @@ const {${missingBindings.join(", ")}} = pkg;
465
464
  }
466
465
  }
467
466
  }
468
- let urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", nanoid = (size = 21) => {
467
+ let nanoid = (size = 21) => {
469
468
  let id = "", i = size | 0;
470
- for (; i--;) id += urlAlphabet[Math.random() * 64 | 0];
469
+ for (; i--;) id += "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[Math.random() * 64 | 0];
471
470
  return id;
472
471
  };
473
472
  function reviveInvokeError(e) {
@@ -675,7 +674,7 @@ function createHMRHandlerForRunner(runner) {
675
674
  for (let url of clearEntrypointUrls) try {
676
675
  await runner.import(url);
677
676
  } catch (err) {
678
- err.code !== ERR_OUTDATED_OPTIMIZED_DEP && hmrClient.logger.error(`An error happened during full reload\n${err.message}\n${err.stack}`);
677
+ err.code !== "ERR_OUTDATED_OPTIMIZED_DEP" && hmrClient.logger.error(`An error happened during full reload\n${err.message}\n${err.stack}`);
679
678
  }
680
679
  break;
681
680
  }
@@ -857,8 +856,8 @@ function wrapCallSite(frame, state) {
857
856
  }), frame.isNative()) return state.curPosition = null, frame;
858
857
  let source = frame.getFileName() || frame.getScriptNameOrSourceURL();
859
858
  if (source) {
860
- let line = frame.getLineNumber(), column = frame.getColumnNumber() - 1, headerLength = 62;
861
- line === 1 && column > headerLength && !frame.isEval() && (column -= headerLength);
859
+ let line = frame.getLineNumber(), column = frame.getColumnNumber() - 1;
860
+ line === 1 && column > 62 && !frame.isEval() && (column -= 62);
862
861
  let position = mapSourcePosition({
863
862
  name: null,
864
863
  source,
@@ -911,12 +910,74 @@ var ESModulesEvaluator = class {
911
910
  runExternalModule(filepath) {
912
911
  return import(filepath);
913
912
  }
914
- }, ModuleRunner = class {
913
+ };
914
+ const customizationHookNamespace = "vite-module-runner:import-meta-resolve/v1/", customizationHooksModule = `
915
+
916
+ export async function resolve(specifier, context, nextResolve) {
917
+ if (specifier.startsWith(${JSON.stringify(customizationHookNamespace)})) {
918
+ const data = specifier.slice(${JSON.stringify(customizationHookNamespace)}.length)
919
+ const [parsedSpecifier, parsedImporter] = JSON.parse(data)
920
+ specifier = parsedSpecifier
921
+ context.parentURL = parsedImporter
922
+ }
923
+
924
+ return nextResolve(specifier, context)
925
+ }
926
+
927
+ `;
928
+ async function createImportMetaResolver() {
929
+ let module;
930
+ try {
931
+ module = (await import("node:module")).Module;
932
+ } catch {
933
+ return;
934
+ }
935
+ if (module?.register) {
936
+ try {
937
+ let hookModuleContent = `data:text/javascript,${encodeURI(customizationHooksModule)}`;
938
+ module.register(hookModuleContent);
939
+ } catch (e) {
940
+ if ("code" in e && e.code === "ERR_NETWORK_IMPORT_DISALLOWED") return;
941
+ throw e;
942
+ }
943
+ return (specifier, importer) => import.meta.resolve(`${customizationHookNamespace}${JSON.stringify([specifier, importer])}`);
944
+ }
945
+ }
946
+ const envProxy = new Proxy({}, { get(_, p) {
947
+ throw Error(`[module runner] Dynamic access of "import.meta.env" is not supported. Please, use "import.meta.env.${String(p)}" instead.`);
948
+ } });
949
+ function createDefaultImportMeta(modulePath) {
950
+ let href = posixPathToFileHref(modulePath), filename = modulePath, dirname$1 = posixDirname(modulePath);
951
+ return {
952
+ filename: isWindows ? toWindowsPath(filename) : filename,
953
+ dirname: isWindows ? toWindowsPath(dirname$1) : dirname$1,
954
+ url: href,
955
+ env: envProxy,
956
+ resolve(_id, _parent) {
957
+ throw Error("[module runner] \"import.meta.resolve\" is not supported.");
958
+ },
959
+ glob() {
960
+ throw Error("[module runner] \"import.meta.glob\" is statically replaced during file transformation. Make sure to reference it by the full name.");
961
+ }
962
+ };
963
+ }
964
+ let importMetaResolverCache;
965
+ async function createNodeImportMeta(modulePath) {
966
+ let defaultMeta = createDefaultImportMeta(modulePath), href = defaultMeta.url;
967
+ importMetaResolverCache ??= createImportMetaResolver();
968
+ let importMetaResolver = await importMetaResolverCache;
969
+ return {
970
+ ...defaultMeta,
971
+ main: !1,
972
+ resolve(id, parent) {
973
+ let resolver = importMetaResolver ?? defaultMeta.resolve;
974
+ return resolver(id, parent ?? href);
975
+ }
976
+ };
977
+ }
978
+ var ModuleRunner = class {
915
979
  evaluatedModules;
916
980
  hmrClient;
917
- envProxy = new Proxy({}, { get(_, p) {
918
- throw Error(`[module runner] Dynamic access of "import.meta.env" is not supported. Please, use "import.meta.env.${String(p)}" instead.`);
919
- } });
920
981
  transport;
921
982
  resetSourceMapSupport;
922
983
  concurrentModuleNodePromises = /* @__PURE__ */ new Map();
@@ -1024,18 +1085,7 @@ var ESModulesEvaluator = class {
1024
1085
  let importer = callstack[callstack.length - 2];
1025
1086
  throw Error(`[module runner] Failed to load "${url}"${importer ? ` imported from ${importer}` : ""}`);
1026
1087
  }
1027
- let modulePath = cleanUrl(file || moduleId), href = posixPathToFileHref(modulePath), filename = modulePath, dirname$1 = posixDirname(modulePath), meta = {
1028
- filename: isWindows ? toWindowsPath(filename) : filename,
1029
- dirname: isWindows ? toWindowsPath(dirname$1) : dirname$1,
1030
- url: href,
1031
- env: this.envProxy,
1032
- resolve(_id, _parent) {
1033
- throw Error("[module runner] \"import.meta.resolve\" is not supported.");
1034
- },
1035
- glob() {
1036
- throw Error("[module runner] \"import.meta.glob\" is statically replaced during file transformation. Make sure to reference it by the full name.");
1037
- }
1038
- }, exports = Object.create(null);
1088
+ let createImportMeta = this.options.createImportMeta ?? createDefaultImportMeta, modulePath = cleanUrl(file || moduleId), href = posixPathToFileHref(modulePath), meta = await createImportMeta(modulePath), exports = Object.create(null);
1039
1089
  Object.defineProperty(exports, Symbol.toStringTag, {
1040
1090
  value: "Module",
1041
1091
  enumerable: !1,
@@ -1078,4 +1128,4 @@ function exportAll(exports, sourceModule) {
1078
1128
  } catch {}
1079
1129
  }
1080
1130
  }
1081
- export { ESModulesEvaluator, EvaluatedModules, ModuleRunner, createWebSocketModuleRunnerTransport, normalizeModuleId, ssrDynamicImportKey, ssrExportAllKey, ssrExportNameKey, ssrImportKey, ssrImportMetaKey, ssrModuleExportsKey };
1131
+ export { ESModulesEvaluator, EvaluatedModules, ModuleRunner, createDefaultImportMeta, createNodeImportMeta, createWebSocketModuleRunnerTransport, normalizeModuleId, ssrDynamicImportKey, ssrExportAllKey, ssrExportNameKey, ssrImportKey, ssrImportMetaKey, ssrModuleExportsKey };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "7.0.6",
3
+ "version": "7.1.0-beta.1",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",
@@ -72,7 +72,7 @@
72
72
  "fdir": "^6.4.6",
73
73
  "picomatch": "^4.0.3",
74
74
  "postcss": "^8.5.6",
75
- "rollup": "^4.40.0",
75
+ "rollup": "^4.43.0",
76
76
  "tinyglobby": "^0.2.14"
77
77
  },
78
78
  "optionalDependencies": {
@@ -84,6 +84,7 @@
84
84
  "@jridgewell/trace-mapping": "^0.3.29",
85
85
  "@oxc-project/types": "0.77.0",
86
86
  "@polka/compression": "^1.0.0-next.25",
87
+ "@rolldown/pluginutils": "^1.0.0-beta.31",
87
88
  "@rollup/plugin-alias": "^5.1.1",
88
89
  "@rollup/plugin-commonjs": "^28.0.6",
89
90
  "@rollup/plugin-dynamic-import-vars": "2.1.4",
@@ -91,7 +92,7 @@
91
92
  "@types/escape-html": "^1.0.4",
92
93
  "@types/pnpapi": "^0.0.5",
93
94
  "artichokie": "^0.3.2",
94
- "baseline-browser-mapping": "^2.5.5",
95
+ "baseline-browser-mapping": "^2.5.7",
95
96
  "cac": "^6.7.14",
96
97
  "chokidar": "^3.6.0",
97
98
  "connect": "^3.7.0",
@@ -100,22 +101,22 @@
100
101
  "cross-spawn": "^7.0.6",
101
102
  "debug": "^4.4.1",
102
103
  "dep-types": "link:./src/types",
103
- "dotenv": "^17.2.0",
104
+ "dotenv": "^17.2.1",
104
105
  "dotenv-expand": "^12.0.2",
105
106
  "es-module-lexer": "^1.7.0",
106
107
  "escape-html": "^1.0.3",
107
108
  "estree-walker": "^3.0.3",
108
109
  "etag": "^1.8.1",
109
110
  "host-validation-middleware": "^0.1.1",
110
- "http-proxy": "^1.18.1",
111
- "launch-editor-middleware": "^2.10.0",
111
+ "http-proxy-3": "^1.20.10",
112
+ "launch-editor-middleware": "^2.11.0",
112
113
  "lightningcss": "^1.30.1",
113
114
  "magic-string": "^0.30.17",
114
115
  "mlly": "^1.7.4",
115
116
  "mrmime": "^2.0.1",
116
117
  "nanoid": "^5.1.5",
117
118
  "open": "^10.2.0",
118
- "parse5": "^7.3.0",
119
+ "parse5": "^8.0.0",
119
120
  "pathe": "^2.0.3",
120
121
  "periscopic": "^4.0.2",
121
122
  "picocolors": "^1.1.1",
@@ -124,8 +125,8 @@
124
125
  "postcss-modules": "^6.0.1",
125
126
  "premove": "^4.0.0",
126
127
  "resolve.exports": "^2.0.3",
127
- "rolldown": "^1.0.0-beta.29",
128
- "rolldown-plugin-dts": "^0.14.1",
128
+ "rolldown": "^1.0.0-beta.31",
129
+ "rolldown-plugin-dts": "^0.15.3",
129
130
  "rollup-plugin-license": "^3.6.0",
130
131
  "sass": "^1.89.2",
131
132
  "sass-embedded": "^1.89.2",
@@ -15,8 +15,6 @@ export interface CustomPluginOptionsVite {
15
15
  * ```js
16
16
  * cssScopeTo: ['/src/App.vue', 'default']
17
17
  * ```
18
- *
19
- * @experimental
20
18
  */
21
19
  cssScopeTo?: readonly [importerId: string, exportName: string | undefined]
22
20
 
@@ -1,95 +0,0 @@
1
- (*
2
- Copyright (c) 2015-present, Facebook, Inc.
3
-
4
- This source code is licensed under the MIT license found in the
5
- LICENSE file at
6
- https://github.com/facebookincubator/create-react-app/blob/master/LICENSE
7
- *)
8
-
9
- property targetTab: null
10
- property targetTabIndex: -1
11
- property targetWindow: null
12
- property theProgram: "Google Chrome"
13
-
14
- on run argv
15
- set theURL to item 1 of argv
16
-
17
- -- Allow requested program to be optional,
18
- -- default to Google Chrome
19
- if (count of argv) > 1 then
20
- set theProgram to item 2 of argv
21
- end if
22
-
23
- using terms from application "Google Chrome"
24
- tell application theProgram
25
-
26
- if (count every window) = 0 then
27
- make new window
28
- end if
29
-
30
- -- 1: Looking for tab running debugger
31
- -- then, Reload debugging tab if found
32
- -- then return
33
- set found to my lookupTabWithUrl(theURL)
34
- if found then
35
- set targetWindow's active tab index to targetTabIndex
36
- tell targetTab to reload
37
- tell targetWindow to activate
38
- set index of targetWindow to 1
39
- return
40
- end if
41
-
42
- -- 2: Looking for Empty tab
43
- -- In case debugging tab was not found
44
- -- We try to find an empty tab instead
45
- set found to my lookupTabWithUrl("chrome://newtab/")
46
- if found then
47
- set targetWindow's active tab index to targetTabIndex
48
- set URL of targetTab to theURL
49
- tell targetWindow to activate
50
- return
51
- end if
52
-
53
- -- 3: Create new tab
54
- -- both debugging and empty tab were not found
55
- -- make a new tab with url
56
- tell window 1
57
- activate
58
- make new tab with properties {URL:theURL}
59
- end tell
60
- end tell
61
- end using terms from
62
- end run
63
-
64
- -- Function:
65
- -- Lookup tab with given url
66
- -- if found, store tab, index, and window in properties
67
- -- (properties were declared on top of file)
68
- on lookupTabWithUrl(lookupUrl)
69
- using terms from application "Google Chrome"
70
- tell application theProgram
71
- -- Find a tab with the given url
72
- set found to false
73
- set theTabIndex to -1
74
- repeat with theWindow in every window
75
- set theTabIndex to 0
76
- repeat with theTab in every tab of theWindow
77
- set theTabIndex to theTabIndex + 1
78
- if (theTab's URL as string) contains lookupUrl then
79
- -- assign tab, tab index, and window to properties
80
- set targetTab to theTab
81
- set targetTabIndex to theTabIndex
82
- set targetWindow to theWindow
83
- set found to true
84
- exit repeat
85
- end if
86
- end repeat
87
-
88
- if found then
89
- exit repeat
90
- end if
91
- end repeat
92
- end tell
93
- end using terms from
94
- return found
95
- end lookupTabWithUrl