@nuxt/vite-builder-nightly 4.3.0-29465977.c4f46c64 → 4.3.0-29466372.7f503428
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/dist/index.d.mts +23 -21
- package/dist/index.mjs +1956 -2335
- package/dist/vite-node-entry.d.mts +4 -3
- package/dist/vite-node-entry.mjs +77 -82
- package/dist/vite-node.d.mts +29 -27
- package/dist/vite-node.mjs +216 -233
- package/package.json +8 -11
- package/dist/index.d.ts +0 -23
- package/dist/vite-node-entry.d.ts +0 -5
- package/dist/vite-node.d.ts +0 -34
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { NuxtSSRContext } from
|
|
1
|
+
import { NuxtSSRContext } from "nuxt/app";
|
|
2
2
|
|
|
3
|
+
//#region src/vite-node-entry.d.ts
|
|
3
4
|
declare const _default: (ssrContext: NuxtSSRContext) => Promise<any>;
|
|
4
|
-
|
|
5
|
-
export { _default as default };
|
|
5
|
+
//#endregion
|
|
6
|
+
export { _default as default };
|
package/dist/vite-node-entry.mjs
CHANGED
|
@@ -1,91 +1,86 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { createError } from
|
|
4
|
-
import { ViteNodeRunner } from
|
|
5
|
-
import { consola } from
|
|
6
|
-
import {
|
|
1
|
+
import { performance } from "node:perf_hooks";
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
import { createError } from "h3";
|
|
4
|
+
import { ViteNodeRunner } from "vite-node/client";
|
|
5
|
+
import { consola } from "consola";
|
|
6
|
+
import { viteNodeFetch, viteNodeOptions } from "#vite-node";
|
|
7
7
|
|
|
8
|
+
//#region src/vite-node-entry.ts
|
|
8
9
|
const runner = createRunner();
|
|
9
10
|
let render;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return result;
|
|
11
|
+
var vite_node_entry_default = async (ssrContext) => {
|
|
12
|
+
process.server = true;
|
|
13
|
+
import.meta.server = true;
|
|
14
|
+
const invalidates = await viteNodeFetch.getInvalidates();
|
|
15
|
+
const updates = runner.moduleCache.invalidateDepTree(invalidates);
|
|
16
|
+
const start = performance.now();
|
|
17
|
+
render = updates.has(viteNodeOptions.entryPath) || !render ? (await runner.executeFile(viteNodeOptions.entryPath)).default : render;
|
|
18
|
+
if (updates.size) {
|
|
19
|
+
const time = Math.round((performance.now() - start) * 1e3) / 1e3;
|
|
20
|
+
consola.success(`Vite server hmr ${updates.size} files`, time ? `in ${time}ms` : "");
|
|
21
|
+
}
|
|
22
|
+
return await render(ssrContext);
|
|
23
23
|
};
|
|
24
24
|
function createRunner() {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
throw _err;
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
});
|
|
25
|
+
return new ViteNodeRunner({
|
|
26
|
+
root: viteNodeOptions.root,
|
|
27
|
+
base: viteNodeOptions.base,
|
|
28
|
+
async resolveId(id, importer) {
|
|
29
|
+
return await viteNodeFetch.resolveId(id, importer);
|
|
30
|
+
},
|
|
31
|
+
async fetchModule(id) {
|
|
32
|
+
id = id.replace(/\/\//g, "/");
|
|
33
|
+
return await viteNodeFetch.fetchModule(id).catch((err) => {
|
|
34
|
+
const errorData = err?.data?.data;
|
|
35
|
+
if (!errorData) throw err;
|
|
36
|
+
let _err;
|
|
37
|
+
try {
|
|
38
|
+
const { message, stack } = formatViteError(errorData, id);
|
|
39
|
+
_err = createError({
|
|
40
|
+
statusText: "Vite Error",
|
|
41
|
+
message,
|
|
42
|
+
stack
|
|
43
|
+
});
|
|
44
|
+
} catch (formatError) {
|
|
45
|
+
consola.warn("Internal nuxt error while formatting vite-node error. Please report this!", formatError);
|
|
46
|
+
const message = `[vite-node] [TransformError] ${errorData?.message || "-"}`;
|
|
47
|
+
consola.error(message, errorData);
|
|
48
|
+
throw createError({
|
|
49
|
+
statusText: "Vite Error",
|
|
50
|
+
message,
|
|
51
|
+
stack: `${message}\nat ${id}\n` + (errorData?.stack || "")
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
throw _err;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
});
|
|
63
58
|
}
|
|
64
59
|
function formatViteError(errorData, id) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
};
|
|
60
|
+
const errorCode = errorData.name || errorData.reasonCode || errorData.code;
|
|
61
|
+
const frame = errorData.frame || errorData.source || errorData.pluginCode;
|
|
62
|
+
const getLocId = (locObj = {}) => locObj.file || locObj.id || locObj.url || id || "";
|
|
63
|
+
const getLocPos = (locObj = {}) => locObj.line ? `${locObj.line}:${locObj.column || 0}` : "";
|
|
64
|
+
const locId = getLocId(errorData.loc) || getLocId(errorData.location) || getLocId(errorData.input) || getLocId(errorData);
|
|
65
|
+
const locPos = getLocPos(errorData.loc) || getLocPos(errorData.location) || getLocPos(errorData.input) || getLocPos(errorData);
|
|
66
|
+
const loc = locId.replace(process.cwd(), ".") + (locPos ? `:${locPos}` : "");
|
|
67
|
+
const message = [
|
|
68
|
+
"[vite-node]",
|
|
69
|
+
errorData.plugin && `[plugin:${errorData.plugin}]`,
|
|
70
|
+
errorCode && `[${errorCode}]`,
|
|
71
|
+
loc,
|
|
72
|
+
errorData.reason && `: ${errorData.reason}`,
|
|
73
|
+
frame && `<br><pre>${frame.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">")}</pre><br>`
|
|
74
|
+
].filter(Boolean).join(" ");
|
|
75
|
+
return {
|
|
76
|
+
message,
|
|
77
|
+
stack: [
|
|
78
|
+
message,
|
|
79
|
+
`at ${loc}`,
|
|
80
|
+
errorData.stack
|
|
81
|
+
].filter(Boolean).join("\n")
|
|
82
|
+
};
|
|
89
83
|
}
|
|
90
84
|
|
|
91
|
-
|
|
85
|
+
//#endregion
|
|
86
|
+
export { vite_node_entry_default as default };
|
package/dist/vite-node.d.mts
CHANGED
|
@@ -1,34 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { PluginContainer } from "vite";
|
|
2
|
+
import { Socket } from "node:net";
|
|
3
|
+
import { Manifest } from "vue-bundle-renderer";
|
|
4
|
+
import { FetchResult } from "vite-node";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
//#region src/plugins/vite-node.d.ts
|
|
7
|
+
type ResolveIdResponse = Awaited<ReturnType<PluginContainer["resolveId"]>>;
|
|
7
8
|
interface ViteNodeFetch {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
/** Gets the client manifest. */
|
|
10
|
+
getManifest(): Promise<Manifest>;
|
|
11
|
+
/** Gets the list of invalidated files. */
|
|
12
|
+
getInvalidates(): Promise<string[]>;
|
|
13
|
+
/** Resolves a module ID. */
|
|
14
|
+
resolveId(id: string, importer?: string): Promise<ResolveIdResponse | null>;
|
|
15
|
+
/** Fetches a module. */
|
|
16
|
+
fetchModule(moduleId: string): Promise<FetchResult>;
|
|
17
|
+
/** Ensures the IPC socket is connected. */
|
|
18
|
+
ensureConnected(): Promise<Socket>;
|
|
18
19
|
}
|
|
19
20
|
type ViteNodeServerOptions = {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
baseURL: string;
|
|
22
|
+
socketPath: string;
|
|
23
|
+
root: string;
|
|
24
|
+
entryPath: string;
|
|
25
|
+
base: string;
|
|
26
|
+
maxRetryAttempts?: number;
|
|
27
|
+
baseRetryDelay?: number;
|
|
28
|
+
maxRetryDelay?: number;
|
|
29
|
+
requestTimeout?: number;
|
|
29
30
|
};
|
|
30
|
-
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/vite-node.d.ts
|
|
31
33
|
declare const viteNodeOptions: ViteNodeServerOptions;
|
|
32
34
|
declare const viteNodeFetch: ViteNodeFetch;
|
|
33
|
-
|
|
34
|
-
export { viteNodeFetch, viteNodeOptions };
|
|
35
|
+
//#endregion
|
|
36
|
+
export { viteNodeFetch, viteNodeOptions };
|