@nuxt/vite-builder-nightly 4.4.3-29608489.ff42fe25 → 4.4.3-29618876.1bd346ee

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.
@@ -14,55 +14,42 @@ function createRunner() {
14
14
  fetchModule(id) {
15
15
  id = id.replace(/\/\//g, "/");
16
16
  return viteNodeFetch.fetchModule(id).catch((err) => {
17
- const errorData = err?.data?.data;
17
+ const errorData = err?.data;
18
18
  if (!errorData) throw err;
19
- let _err;
19
+ let built;
20
20
  try {
21
- const { message, stack } = formatViteError(errorData, id);
22
- _err = {
23
- statusText: "Vite Error",
24
- message,
25
- stack
26
- };
27
- } catch (formatError) {
28
- consola.warn("Internal nuxt error while formatting vite-node error. Please report this!", formatError);
21
+ built = buildViteError(errorData, id);
22
+ } catch (buildErr) {
23
+ consola.warn("Internal nuxt error while formatting vite-node error. Please report this!", buildErr);
29
24
  const message = `[vite-node] [TransformError] ${errorData?.message || "-"}`;
30
25
  consola.error(message, errorData);
31
- throw {
26
+ built = Object.assign(new Error(message), {
32
27
  statusText: "Vite Error",
33
- message,
28
+ statusMessage: "Vite Error",
34
29
  stack: `${message}\nat ${id}\n` + (errorData?.stack || "")
35
- };
30
+ });
36
31
  }
37
- throw _err;
32
+ throw built;
38
33
  });
39
34
  }
40
35
  });
41
36
  }
42
- function formatViteError(errorData, id) {
43
- const errorCode = errorData.name || errorData.reasonCode || errorData.code;
44
- const frame = errorData.frame || errorData.source || errorData.pluginCode;
45
- const getLocId = (locObj = {}) => locObj.file || locObj.id || locObj.url || id || "";
46
- const getLocPos = (locObj = {}) => locObj.line ? `${locObj.line}:${locObj.column || 0}` : "";
47
- const locId = getLocId(errorData.loc) || getLocId(errorData.location) || getLocId(errorData.input) || getLocId(errorData);
48
- const locPos = getLocPos(errorData.loc) || getLocPos(errorData.location) || getLocPos(errorData.input) || getLocPos(errorData);
49
- const loc = locId.replace(process.cwd(), ".") + (locPos ? `:${locPos}` : "");
50
- const message = [
51
- "[vite-node]",
52
- errorData.plugin && `[plugin:${errorData.plugin}]`,
53
- errorCode && `[${errorCode}]`,
54
- loc,
55
- errorData.reason && `: ${errorData.reason}`,
56
- frame && `<br><pre>${frame.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;")}</pre><br>`
57
- ].filter(Boolean).join(" ");
58
- return {
59
- message,
60
- stack: [
61
- message,
62
- `at ${loc}`,
63
- errorData.stack
64
- ].filter(Boolean).join("\n")
65
- };
37
+ function buildViteError(errorData, id) {
38
+ const loc = (errorData.id || id || "").replace(process.cwd(), ".");
39
+ const rawMessage = errorData.message || "";
40
+ const [headRaw, ...frameTail] = rawMessage.split(/\r?\n\s*\n/);
41
+ const reason = ((headRaw || "").split(/\r?\n/)[0] ?? "").replace(/^\[@?[\w.\-/:]+\]\s*/, "").trim();
42
+ const messageFrame = frameTail.length ? frameTail.join("\n\n").trim() : "";
43
+ const message = reason ? `${loc} — ${reason}` : rawMessage || loc;
44
+ const error = Object.assign(new Error(message), {
45
+ name: "ViteError",
46
+ statusText: "Vite Error",
47
+ statusMessage: "Vite Error",
48
+ code: errorData.code,
49
+ hint: errorData.frame || messageFrame || void 0
50
+ });
51
+ if (errorData.stack) error.stack = errorData.stack;
52
+ return error;
66
53
  }
67
54
  //#endregion
68
55
  export { runner as default };
@@ -104,9 +104,10 @@ function connectSocket() {
104
104
  const { resolve: resolveRequest, reject: rejectRequest } = requestHandlers;
105
105
  if (response.type === "error") {
106
106
  const err = new Error(response.error.message);
107
- err.stack = response.error.stack;
107
+ if (response.error.stack) err.stack = response.error.stack;
108
108
  err.data = response.error.data;
109
109
  err.statusCode = err.status = response.error.status || response.error.statusCode;
110
+ err._fromServer = true;
110
111
  rejectRequest(err);
111
112
  } else resolveRequest(response.data);
112
113
  pendingRequests.delete(response.id);
@@ -195,6 +196,7 @@ async function sendRequest(type, payload) {
195
196
  });
196
197
  } catch (error) {
197
198
  lastError = error;
199
+ if (error && typeof error === "object" && "_fromServer" in error) break;
198
200
  if (requestAttempt < MAX_RETRY_ATTEMPTS) {
199
201
  const delay = calculateRetryDelay(requestAttempt);
200
202
  await new Promise((resolve) => setTimeout(resolve, delay));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxt/vite-builder-nightly",
3
- "version": "4.4.3-29608489.ff42fe25",
3
+ "version": "4.4.3-29618876.1bd346ee",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/nuxt/nuxt.git",
@@ -23,7 +23,7 @@
23
23
  "dist"
24
24
  ],
25
25
  "dependencies": {
26
- "@nuxt/kit": "npm:@nuxt/kit-nightly@4.4.3-29608489.ff42fe25",
26
+ "@nuxt/kit": "npm:@nuxt/kit-nightly@4.4.3-29618876.1bd346ee",
27
27
  "@rollup/plugin-replace": "^6.0.3",
28
28
  "@vitejs/plugin-vue": "^6.0.5",
29
29
  "@vitejs/plugin-vue-jsx": "^5.1.5",
@@ -55,7 +55,7 @@
55
55
  "devDependencies": {
56
56
  "@babel/plugin-proposal-decorators": "7.29.0",
57
57
  "@babel/plugin-syntax-jsx": "7.28.6",
58
- "@nuxt/schema": "npm:@nuxt/schema-nightly@4.4.3-29608489.ff42fe25",
58
+ "@nuxt/schema": "npm:@nuxt/schema-nightly@4.4.3-29618876.1bd346ee",
59
59
  "h3": "1.15.6",
60
60
  "h3-next": "npm:h3@2.0.1-rc.18",
61
61
  "nitropack": "2.13.1",
@@ -68,7 +68,7 @@
68
68
  "peerDependencies": {
69
69
  "@babel/plugin-proposal-decorators": "^7.25.0",
70
70
  "@babel/plugin-syntax-jsx": "^7.25.0",
71
- "nuxt": "npm:nuxt-nightly@4.4.3-29608489.ff42fe25",
71
+ "nuxt": "npm:nuxt-nightly@4.4.3-29618876.1bd346ee",
72
72
  "rolldown": "^1.0.0-beta.38",
73
73
  "rollup-plugin-visualizer": "^6.0.0 || ^7.0.1",
74
74
  "vue": "^3.3.4"