@nuxt/vite-builder-nightly 4.4.0-29544347.e1dade21 → 4.4.0-29545012.63619020
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/fix-stacktrace.d.mts +6 -0
- package/dist/fix-stacktrace.mjs +11 -0
- package/dist/index.mjs +41 -14
- package/dist/vite-node-entry.mjs +1 -62
- package/dist/vite-node-runner.d.mts +6 -0
- package/dist/vite-node-runner.mjs +66 -0
- package/package.json +6 -5
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
var fix_stacktrace_default = (nitroApp) => {
|
|
2
|
+
let runner;
|
|
3
|
+
nitroApp.hooks.hook("error", async (error) => {
|
|
4
|
+
if (!error?.stack) return;
|
|
5
|
+
try {
|
|
6
|
+
runner ||= await import("#internal/nuxt/vite-node-runner").then((m) => m.default);
|
|
7
|
+
runner.ssrFixStacktrace(error);
|
|
8
|
+
} catch {}
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
export { fix_stacktrace_default as default };
|
package/dist/index.mjs
CHANGED
|
@@ -472,12 +472,14 @@ function sendError(socket, id, error) {
|
|
|
472
472
|
});
|
|
473
473
|
}
|
|
474
474
|
async function writeDevServer(nuxt) {
|
|
475
|
+
const runnerResolvedPath = resolveModulePath("#vite-node-runner", { from: import.meta.url });
|
|
475
476
|
const serverResolvedPath = resolveModulePath("#vite-node-entry", { from: import.meta.url });
|
|
476
477
|
const fetchResolvedPath = resolveModulePath("#vite-node", { from: import.meta.url });
|
|
477
478
|
const serverDist = join(nuxt.options.buildDir, "dist/server");
|
|
478
479
|
await mkdir(serverDist, { recursive: true });
|
|
479
480
|
await Promise.all([
|
|
480
481
|
writeFile(join(serverDist, "server.mjs"), `export { default } from ${JSON.stringify(pathToFileURL(serverResolvedPath).href)}`),
|
|
482
|
+
writeFile(join(serverDist, "runner.mjs"), `export { default } from ${JSON.stringify(pathToFileURL(runnerResolvedPath).href)}`),
|
|
481
483
|
writeFile(join(serverDist, "client.precomputed.mjs"), `export default undefined`),
|
|
482
484
|
writeFile(join(serverDist, "client.manifest.mjs"), `
|
|
483
485
|
import { viteNodeFetch } from ${JSON.stringify(pathToFileURL(fetchResolvedPath))}
|
|
@@ -1507,13 +1509,22 @@ function SSRStylesPlugin(nuxt) {
|
|
|
1507
1509
|
if (!chunk) continue;
|
|
1508
1510
|
if (chunk.isEntry && chunk.src) entryIds.add(chunk.src);
|
|
1509
1511
|
else chunk.css &&= [];
|
|
1512
|
+
if (chunk.imports && chunk.src) {
|
|
1513
|
+
const componentBaseName = filename(chunk.src);
|
|
1514
|
+
for (const imp of chunk.imports) {
|
|
1515
|
+
const imported = manifest[imp];
|
|
1516
|
+
if (imported?.css?.length && !imported.isEntry && !imported.src) {
|
|
1517
|
+
if (imported.css.every((css) => css.startsWith(componentBaseName + "."))) imported.css = [];
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
}
|
|
1510
1521
|
}
|
|
1511
1522
|
nitro.options.virtual["#internal/nuxt/entry-ids.mjs"] = () => `export default ${JSON.stringify(Array.from(entryIds))}`;
|
|
1512
1523
|
nitro.options._config.virtual ||= {};
|
|
1513
1524
|
nitro.options._config.virtual["#internal/nuxt/entry-ids.mjs"] = nitro.options.virtual["#internal/nuxt/entry-ids.mjs"];
|
|
1514
1525
|
});
|
|
1515
1526
|
const cssMap = {};
|
|
1516
|
-
const
|
|
1527
|
+
const emittedFileRefs = {};
|
|
1517
1528
|
const options = {
|
|
1518
1529
|
shouldInline: nuxt.options.features.inlineStyles,
|
|
1519
1530
|
globalCSS: nuxt.options.css
|
|
@@ -1678,12 +1689,16 @@ function SSRStylesPlugin(nuxt) {
|
|
|
1678
1689
|
continue;
|
|
1679
1690
|
}
|
|
1680
1691
|
emittedIds.add(file);
|
|
1681
|
-
const
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1692
|
+
const resolvedInlineId = res.id;
|
|
1693
|
+
let ref = emittedFileRefs[resolvedInlineId];
|
|
1694
|
+
if (!ref) {
|
|
1695
|
+
ref = this.emitFile({
|
|
1696
|
+
type: "chunk",
|
|
1697
|
+
name: `${idFilename}-styles-${++styleCtr}.mjs`,
|
|
1698
|
+
id: fileInline
|
|
1699
|
+
});
|
|
1700
|
+
emittedFileRefs[resolvedInlineId] = ref;
|
|
1701
|
+
}
|
|
1687
1702
|
idMap.files.push(ref);
|
|
1688
1703
|
}
|
|
1689
1704
|
if (!SUPPORTED_FILES_RE.test(pathname)) return;
|
|
@@ -1692,7 +1707,8 @@ function SSRStylesPlugin(nuxt) {
|
|
|
1692
1707
|
const resolved = await this.resolve(i.specifier, id);
|
|
1693
1708
|
if (!resolved) continue;
|
|
1694
1709
|
const resolvedIdInline = resolved.id + "?inline&used";
|
|
1695
|
-
|
|
1710
|
+
const res = await this.resolve(resolvedIdInline);
|
|
1711
|
+
if (!res) {
|
|
1696
1712
|
if (!warnCache.has(resolved.id)) {
|
|
1697
1713
|
warnCache.add(resolved.id);
|
|
1698
1714
|
this.warn(`[nuxt] Cannot extract styles for \`${i.specifier}\`. Its styles will not be inlined when server-rendering.`);
|
|
@@ -1700,12 +1716,16 @@ function SSRStylesPlugin(nuxt) {
|
|
|
1700
1716
|
continue;
|
|
1701
1717
|
}
|
|
1702
1718
|
if (emittedIds.has(resolved.id)) continue;
|
|
1703
|
-
const
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1719
|
+
const resolvedInlineId = res.id;
|
|
1720
|
+
let ref = emittedFileRefs[resolvedInlineId];
|
|
1721
|
+
if (!ref) {
|
|
1722
|
+
ref = this.emitFile({
|
|
1723
|
+
type: "chunk",
|
|
1724
|
+
name: `${idFilename}-styles-${++styleCtr}.mjs`,
|
|
1725
|
+
id: resolvedIdInline
|
|
1726
|
+
});
|
|
1727
|
+
emittedFileRefs[resolvedInlineId] = ref;
|
|
1728
|
+
}
|
|
1709
1729
|
idMap.files.push(ref);
|
|
1710
1730
|
}
|
|
1711
1731
|
}
|
|
@@ -1983,6 +2003,13 @@ const bundle = async (nuxt) => {
|
|
|
1983
2003
|
const useAsyncEntry = nuxt.options.experimental.asyncEntry || nuxt.options.dev;
|
|
1984
2004
|
const entry = await resolvePath(resolve(nuxt.options.appDir, useAsyncEntry ? "entry.async" : "entry"));
|
|
1985
2005
|
nuxt.options.modulesDir.push(distDir);
|
|
2006
|
+
if (nuxt.options.dev) {
|
|
2007
|
+
const nitro = useNitro();
|
|
2008
|
+
nitro.options.virtual["#internal/nitro/ssr-stacktrace"] = `export { default } from ${JSON.stringify(resolve(distDir, "fix-stacktrace"))}`;
|
|
2009
|
+
nitro.options.plugins.push("#internal/nitro/ssr-stacktrace");
|
|
2010
|
+
nitro.options.alias["#vite-node"] = resolve(distDir, "vite-node");
|
|
2011
|
+
nitro.options.virtual["#internal/nuxt/vite-node-runner"] = () => `export { default } from ${JSON.stringify(resolve(distDir, "vite-node-runner"))}`;
|
|
2012
|
+
}
|
|
1986
2013
|
let allowDirs = [
|
|
1987
2014
|
nuxt.options.appDir,
|
|
1988
2015
|
nuxt.options.workspaceDir,
|
package/dist/vite-node-entry.mjs
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { performance } from "node:perf_hooks";
|
|
2
2
|
import process from "node:process";
|
|
3
|
-
import { ViteNodeRunner } from "vite-node/client";
|
|
4
3
|
import { consola } from "consola";
|
|
5
4
|
import { viteNodeFetch, viteNodeOptions } from "#vite-node";
|
|
6
|
-
|
|
5
|
+
import runner from "#vite-node-runner";
|
|
7
6
|
let render;
|
|
8
7
|
var vite_node_entry_default = async (ssrContext) => {
|
|
9
8
|
process.server = true;
|
|
@@ -18,64 +17,4 @@ var vite_node_entry_default = async (ssrContext) => {
|
|
|
18
17
|
}
|
|
19
18
|
return await render(ssrContext);
|
|
20
19
|
};
|
|
21
|
-
function createRunner() {
|
|
22
|
-
return new ViteNodeRunner({
|
|
23
|
-
root: viteNodeOptions.root,
|
|
24
|
-
base: viteNodeOptions.base,
|
|
25
|
-
async resolveId(id, importer) {
|
|
26
|
-
return await viteNodeFetch.resolveId(id, importer);
|
|
27
|
-
},
|
|
28
|
-
async fetchModule(id) {
|
|
29
|
-
id = id.replace(/\/\//g, "/");
|
|
30
|
-
return await viteNodeFetch.fetchModule(id).catch((err) => {
|
|
31
|
-
const errorData = err?.data?.data;
|
|
32
|
-
if (!errorData) throw err;
|
|
33
|
-
let _err;
|
|
34
|
-
try {
|
|
35
|
-
const { message, stack } = formatViteError(errorData, id);
|
|
36
|
-
_err = {
|
|
37
|
-
statusText: "Vite Error",
|
|
38
|
-
message,
|
|
39
|
-
stack
|
|
40
|
-
};
|
|
41
|
-
} catch (formatError) {
|
|
42
|
-
consola.warn("Internal nuxt error while formatting vite-node error. Please report this!", formatError);
|
|
43
|
-
const message = `[vite-node] [TransformError] ${errorData?.message || "-"}`;
|
|
44
|
-
consola.error(message, errorData);
|
|
45
|
-
throw {
|
|
46
|
-
statusText: "Vite Error",
|
|
47
|
-
message,
|
|
48
|
-
stack: `${message}\nat ${id}\n` + (errorData?.stack || "")
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
throw _err;
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
function formatViteError(errorData, id) {
|
|
57
|
-
const errorCode = errorData.name || errorData.reasonCode || errorData.code;
|
|
58
|
-
const frame = errorData.frame || errorData.source || errorData.pluginCode;
|
|
59
|
-
const getLocId = (locObj = {}) => locObj.file || locObj.id || locObj.url || id || "";
|
|
60
|
-
const getLocPos = (locObj = {}) => locObj.line ? `${locObj.line}:${locObj.column || 0}` : "";
|
|
61
|
-
const locId = getLocId(errorData.loc) || getLocId(errorData.location) || getLocId(errorData.input) || getLocId(errorData);
|
|
62
|
-
const locPos = getLocPos(errorData.loc) || getLocPos(errorData.location) || getLocPos(errorData.input) || getLocPos(errorData);
|
|
63
|
-
const loc = locId.replace(process.cwd(), ".") + (locPos ? `:${locPos}` : "");
|
|
64
|
-
const message = [
|
|
65
|
-
"[vite-node]",
|
|
66
|
-
errorData.plugin && `[plugin:${errorData.plugin}]`,
|
|
67
|
-
errorCode && `[${errorCode}]`,
|
|
68
|
-
loc,
|
|
69
|
-
errorData.reason && `: ${errorData.reason}`,
|
|
70
|
-
frame && `<br><pre>${frame.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">")}</pre><br>`
|
|
71
|
-
].filter(Boolean).join(" ");
|
|
72
|
-
return {
|
|
73
|
-
message,
|
|
74
|
-
stack: [
|
|
75
|
-
message,
|
|
76
|
-
`at ${loc}`,
|
|
77
|
-
errorData.stack
|
|
78
|
-
].filter(Boolean).join("\n")
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
20
|
export { vite_node_entry_default as default };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import process from "node:process";
|
|
2
|
+
import { consola } from "consola";
|
|
3
|
+
import { viteNodeFetch, viteNodeOptions } from "#vite-node";
|
|
4
|
+
import { ViteNodeRunner } from "vite-node/client";
|
|
5
|
+
const runner = createRunner();
|
|
6
|
+
function createRunner() {
|
|
7
|
+
return new ViteNodeRunner({
|
|
8
|
+
root: viteNodeOptions.root,
|
|
9
|
+
base: viteNodeOptions.base,
|
|
10
|
+
async resolveId(id, importer) {
|
|
11
|
+
return await viteNodeFetch.resolveId(id, importer);
|
|
12
|
+
},
|
|
13
|
+
async fetchModule(id) {
|
|
14
|
+
id = id.replace(/\/\//g, "/");
|
|
15
|
+
return await viteNodeFetch.fetchModule(id).catch((err) => {
|
|
16
|
+
const errorData = err?.data?.data;
|
|
17
|
+
if (!errorData) throw err;
|
|
18
|
+
let _err;
|
|
19
|
+
try {
|
|
20
|
+
const { message, stack } = formatViteError(errorData, id);
|
|
21
|
+
_err = {
|
|
22
|
+
statusText: "Vite Error",
|
|
23
|
+
message,
|
|
24
|
+
stack
|
|
25
|
+
};
|
|
26
|
+
} catch (formatError) {
|
|
27
|
+
consola.warn("Internal nuxt error while formatting vite-node error. Please report this!", formatError);
|
|
28
|
+
const message = `[vite-node] [TransformError] ${errorData?.message || "-"}`;
|
|
29
|
+
consola.error(message, errorData);
|
|
30
|
+
throw {
|
|
31
|
+
statusText: "Vite Error",
|
|
32
|
+
message,
|
|
33
|
+
stack: `${message}\nat ${id}\n` + (errorData?.stack || "")
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
throw _err;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function formatViteError(errorData, id) {
|
|
42
|
+
const errorCode = errorData.name || errorData.reasonCode || errorData.code;
|
|
43
|
+
const frame = errorData.frame || errorData.source || errorData.pluginCode;
|
|
44
|
+
const getLocId = (locObj = {}) => locObj.file || locObj.id || locObj.url || id || "";
|
|
45
|
+
const getLocPos = (locObj = {}) => locObj.line ? `${locObj.line}:${locObj.column || 0}` : "";
|
|
46
|
+
const locId = getLocId(errorData.loc) || getLocId(errorData.location) || getLocId(errorData.input) || getLocId(errorData);
|
|
47
|
+
const locPos = getLocPos(errorData.loc) || getLocPos(errorData.location) || getLocPos(errorData.input) || getLocPos(errorData);
|
|
48
|
+
const loc = locId.replace(process.cwd(), ".") + (locPos ? `:${locPos}` : "");
|
|
49
|
+
const message = [
|
|
50
|
+
"[vite-node]",
|
|
51
|
+
errorData.plugin && `[plugin:${errorData.plugin}]`,
|
|
52
|
+
errorCode && `[${errorCode}]`,
|
|
53
|
+
loc,
|
|
54
|
+
errorData.reason && `: ${errorData.reason}`,
|
|
55
|
+
frame && `<br><pre>${frame.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">")}</pre><br>`
|
|
56
|
+
].filter(Boolean).join(" ");
|
|
57
|
+
return {
|
|
58
|
+
message,
|
|
59
|
+
stack: [
|
|
60
|
+
message,
|
|
61
|
+
`at ${loc}`,
|
|
62
|
+
errorData.stack
|
|
63
|
+
].filter(Boolean).join("\n")
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
export { runner as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxt/vite-builder-nightly",
|
|
3
|
-
"version": "4.4.0-
|
|
3
|
+
"version": "4.4.0-29545012.63619020",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/nuxt/nuxt.git",
|
|
@@ -16,13 +16,14 @@
|
|
|
16
16
|
},
|
|
17
17
|
"imports": {
|
|
18
18
|
"#vite-node": "./dist/vite-node.mjs",
|
|
19
|
-
"#vite-node-entry": "./dist/vite-node-entry.mjs"
|
|
19
|
+
"#vite-node-entry": "./dist/vite-node-entry.mjs",
|
|
20
|
+
"#vite-node-runner": "./dist/vite-node-runner.mjs"
|
|
20
21
|
},
|
|
21
22
|
"files": [
|
|
22
23
|
"dist"
|
|
23
24
|
],
|
|
24
25
|
"devDependencies": {
|
|
25
|
-
"@nuxt/schema": "npm:@nuxt/schema-nightly@4.4.0-
|
|
26
|
+
"@nuxt/schema": "npm:@nuxt/schema-nightly@4.4.0-29545012.63619020",
|
|
26
27
|
"h3": "1.15.5",
|
|
27
28
|
"h3-next": "npm:h3@2.0.1-rc.14",
|
|
28
29
|
"nitropack": "2.13.1",
|
|
@@ -32,7 +33,7 @@
|
|
|
32
33
|
"vue": "3.5.29"
|
|
33
34
|
},
|
|
34
35
|
"dependencies": {
|
|
35
|
-
"@nuxt/kit": "npm:@nuxt/kit-nightly@4.4.0-
|
|
36
|
+
"@nuxt/kit": "npm:@nuxt/kit-nightly@4.4.0-29545012.63619020",
|
|
36
37
|
"@rollup/plugin-replace": "^6.0.3",
|
|
37
38
|
"@vitejs/plugin-vue": "^6.0.4",
|
|
38
39
|
"@vitejs/plugin-vue-jsx": "^5.1.4",
|
|
@@ -63,7 +64,7 @@
|
|
|
63
64
|
"vue-bundle-renderer": "^2.2.0"
|
|
64
65
|
},
|
|
65
66
|
"peerDependencies": {
|
|
66
|
-
"nuxt": "npm:nuxt-nightly@4.4.0-
|
|
67
|
+
"nuxt": "npm:nuxt-nightly@4.4.0-29545012.63619020",
|
|
67
68
|
"rolldown": "^1.0.0-beta.38",
|
|
68
69
|
"vue": "^3.3.4"
|
|
69
70
|
},
|