vite 8.0.5 → 8.0.6

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,5 +1,5 @@
1
1
  import "@vite/env";
2
- //#region \0@oxc-project+runtime@0.122.0/helpers/typeof.js
2
+ //#region \0@oxc-project+runtime@0.123.0/helpers/typeof.js
3
3
  function _typeof(o) {
4
4
  "@babel/helpers - typeof";
5
5
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -9,7 +9,7 @@ function _typeof(o) {
9
9
  }, _typeof(o);
10
10
  }
11
11
  //#endregion
12
- //#region \0@oxc-project+runtime@0.122.0/helpers/toPrimitive.js
12
+ //#region \0@oxc-project+runtime@0.123.0/helpers/toPrimitive.js
13
13
  function toPrimitive(t, r) {
14
14
  if ("object" != _typeof(t) || !t) return t;
15
15
  var e = t[Symbol.toPrimitive];
@@ -21,13 +21,13 @@ function toPrimitive(t, r) {
21
21
  return ("string" === r ? String : Number)(t);
22
22
  }
23
23
  //#endregion
24
- //#region \0@oxc-project+runtime@0.122.0/helpers/toPropertyKey.js
24
+ //#region \0@oxc-project+runtime@0.123.0/helpers/toPropertyKey.js
25
25
  function toPropertyKey(t) {
26
26
  var i = toPrimitive(t, "string");
27
27
  return "symbol" == _typeof(i) ? i : i + "";
28
28
  }
29
29
  //#endregion
30
- //#region \0@oxc-project+runtime@0.122.0/helpers/defineProperty.js
30
+ //#region \0@oxc-project+runtime@0.123.0/helpers/defineProperty.js
31
31
  function _defineProperty(e, r, t) {
32
32
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
33
33
  value: t,
@@ -2063,9 +2063,11 @@ function unique(arr) {
2063
2063
  * Even if defaultResultOrder is `ipv4first`, `dns.lookup` result maybe same.
2064
2064
  * For example, when IPv6 is not supported on that machine/network.
2065
2065
  */
2066
- async function getLocalhostAddressIfDiffersFromDNS() {
2067
- const [nodeResult, dnsResult] = await Promise.all([promises.lookup("localhost"), promises.lookup("localhost", { verbatim: true })]);
2068
- return nodeResult.family === dnsResult.family && nodeResult.address === dnsResult.address ? void 0 : nodeResult.address;
2066
+ function getLocalhostAddressIfDiffersFromDNS() {
2067
+ if (promises.getDefaultResultOrder() === "verbatim") return;
2068
+ return Promise.all([promises.lookup("localhost"), promises.lookup("localhost", { verbatim: true })]).then(([nodeResult, dnsResult]) => {
2069
+ return nodeResult.family === dnsResult.family && nodeResult.address === dnsResult.address ? void 0 : nodeResult.address;
2070
+ });
2069
2071
  }
2070
2072
  function diffDnsOrderChange(oldUrls, newUrls) {
2071
2073
  return !(oldUrls === newUrls || oldUrls && newUrls && arrayEqual(oldUrls.local, newUrls.local) && arrayEqual(oldUrls.network, newUrls.network));
@@ -2540,6 +2542,10 @@ function formatAndTruncateFileList(files) {
2540
2542
  truncated
2541
2543
  };
2542
2544
  }
2545
+ const hashbangRE = /^#!.*\n/;
2546
+ function getFileStartIndex(code) {
2547
+ return hashbangRE.exec(code)?.[0].length ?? 0;
2548
+ }
2543
2549
  //#endregion
2544
2550
  //#region src/node/plugin.ts
2545
2551
  async function resolveEnvironmentPlugins(environment) {
@@ -11071,7 +11077,6 @@ const ssrDynamicImportKey = `__vite_ssr_dynamic_import__`;
11071
11077
  const ssrExportAllKey = `__vite_ssr_exportAll__`;
11072
11078
  const ssrExportNameKey = `__vite_ssr_exportName__`;
11073
11079
  const ssrImportMetaKey = `__vite_ssr_import_meta__`;
11074
- const hashbangRE = /^#!.*\n/;
11075
11080
  async function ssrTransform(code, inMap, url, originalCode, options) {
11076
11081
  if (options?.json?.stringify && isJSONRequest(url)) return ssrTransformJSON(code, inMap);
11077
11082
  return ssrTransformScript(code, inMap, url, originalCode);
@@ -11108,7 +11113,7 @@ async function ssrTransformScript(code, inMap, url, originalCode) {
11108
11113
  const dynamicDeps = /* @__PURE__ */ new Set();
11109
11114
  const idToImportMap = /* @__PURE__ */ new Map();
11110
11115
  const declaredConst = /* @__PURE__ */ new Set();
11111
- const fileStartIndex = hashbangRE.exec(code)?.[0].length ?? 0;
11116
+ const fileStartIndex = getFileStartIndex(code);
11112
11117
  let hoistIndex = fileStartIndex;
11113
11118
  function defineImport(index, importNode, metadata) {
11114
11119
  const source = importNode.source.value;
@@ -21419,6 +21424,7 @@ const makeScssWorker = (environment, resolvers, _maxWorkers) => {
21419
21424
  const scssProcessor = (maxWorkers) => {
21420
21425
  let worker;
21421
21426
  let failedSassEmbedded;
21427
+ const normalizedErrors = /* @__PURE__ */ new WeakSet();
21422
21428
  return {
21423
21429
  close() {
21424
21430
  worker?.stop();
@@ -21454,13 +21460,16 @@ const scssProcessor = (maxWorkers) => {
21454
21460
  deps
21455
21461
  };
21456
21462
  } catch (e) {
21457
- e.message = `[sass] ${e.message}`;
21458
- e.id = e.file;
21459
- e.frame = e.formatted;
21460
- if (e.span?.start) {
21461
- e.line = e.span.start.line + 1;
21462
- e.column = e.span.start.column + 1;
21463
- e.frame = e.message;
21463
+ if (!normalizedErrors.has(e)) {
21464
+ e.message = `[sass] ${e.message}`;
21465
+ e.id = e.file;
21466
+ e.frame = e.formatted;
21467
+ if (e.span?.start) {
21468
+ e.line = e.span.start.line + 1;
21469
+ e.column = e.span.start.column + 1;
21470
+ e.frame = e.message;
21471
+ }
21472
+ normalizedErrors.add(e);
21464
21473
  }
21465
21474
  return {
21466
21475
  code: "",
@@ -27806,8 +27815,10 @@ function interopNamedImports(str, importSpecifier, rewrittenUrl, importIndex, im
27806
27815
  if (dynamicIndex > -1) str.overwrite(expStart, expEnd, `import('${rewrittenUrl}').then(m => (${interopHelperStr})(m.default, ${!!config.legacy?.inconsistentCjsInterop ? 0 : 1}))` + getLineBreaks(exp), { contentOnly: true });
27807
27816
  else {
27808
27817
  const rewritten = transformCjsImport(exp, rewrittenUrl, source.slice(start, end), importIndex, importer, isNodeMode, config);
27809
- if (rewritten) str.overwrite(expStart, expEnd, rewritten + getLineBreaks(exp), { contentOnly: true });
27810
- else str.overwrite(start, end, rewrittenUrl + getLineBreaks(source.slice(start, end)), { contentOnly: true });
27818
+ if (rewritten) {
27819
+ str.overwrite(expStart, expEnd, rewritten.importLine + getLineBreaks(exp), { contentOnly: true });
27820
+ if (rewritten.hoistedAssignments) str.appendLeft(getFileStartIndex(source), rewritten.hoistedAssignments + ";");
27821
+ } else str.overwrite(start, end, rewrittenUrl + getLineBreaks(source.slice(start, end)), { contentOnly: true });
27811
27822
  }
27812
27823
  }
27813
27824
  function getLineBreaks(str) {
@@ -27830,7 +27841,7 @@ function transformCjsImport(importExp, url, rawUrl, importIndex, importer, isNod
27830
27841
  const node = parseAst(importExp).body[0];
27831
27842
  if (config.command === "serve" && node.type === "ExportAllDeclaration" && !node.exported) config.logger.warn(import_picocolors.default.yellow(`\nUnable to interop \`${importExp}\` in ${importer}, this may lose module exports. Please export "${rawUrl}" as ESM or use named exports instead, e.g. \`export { A, B } from "${rawUrl}"\``));
27832
27843
  else if (node.type === "ImportDeclaration" || node.type === "ExportNamedDeclaration") {
27833
- if (!node.specifiers.length) return `import "${url}"`;
27844
+ if (!node.specifiers.length) return { importLine: `import "${url}"` };
27834
27845
  const importNames = [];
27835
27846
  const exportNames = [];
27836
27847
  let defaultExports = "";
@@ -27867,7 +27878,8 @@ function transformCjsImport(importExp, url, rawUrl, importIndex, importer, isNod
27867
27878
  }
27868
27879
  }
27869
27880
  const cjsModuleName = makeLegalIdentifier(`__vite__cjsImport${importIndex}_${rawUrl}`);
27870
- const lines = [`import ${cjsModuleName} from "${url}"`];
27881
+ const importLine = `import ${cjsModuleName} from "${url}"`;
27882
+ const lines = [];
27871
27883
  importNames.forEach(({ importedName, localName }) => {
27872
27884
  if (importedName === "*") lines.push(`const ${localName} = (${interopHelperStr})(${cjsModuleName}, ${+isNodeMode})`);
27873
27885
  else if (importedName === "default") if (isNodeMode) lines.push(`const ${localName} = ${cjsModuleName}`);
@@ -27876,7 +27888,10 @@ function transformCjsImport(importExp, url, rawUrl, importIndex, importer, isNod
27876
27888
  });
27877
27889
  if (defaultExports) lines.push(`export default ${defaultExports}`);
27878
27890
  if (exportNames.length) lines.push(`export { ${exportNames.join(", ")} }`);
27879
- return lines.join("; ");
27891
+ return {
27892
+ importLine,
27893
+ hoistedAssignments: lines.join("; ")
27894
+ };
27880
27895
  }
27881
27896
  }
27882
27897
  function getIdentifierNameOrLiteralValue(node) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "8.0.5",
3
+ "version": "8.0.6",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",
@@ -63,7 +63,7 @@
63
63
  "lightningcss": "^1.32.0",
64
64
  "picomatch": "^4.0.4",
65
65
  "postcss": "^8.5.8",
66
- "rolldown": "1.0.0-rc.12",
66
+ "rolldown": "1.0.0-rc.13",
67
67
  "tinyglobby": "^0.2.15"
68
68
  },
69
69
  "optionalDependencies": {
@@ -186,7 +186,7 @@
186
186
  "build-types-check": "tsc --project tsconfig.check.json",
187
187
  "typecheck": "tsc && tsc -p src/node && tsc -p src/module-runner && tsc -p src/shared && tsc -p src/node/__tests_dts__ && tsc -p src/module-runner/__tests_dts__",
188
188
  "lint": "eslint --cache --ext .ts src/**",
189
- "format": "prettier --write --cache --parser typescript \"src/**/*.ts\"",
189
+ "format": "oxfmt",
190
190
  "generate-target": "tsx scripts/generateTarget.ts"
191
191
  }
192
192
  }