vue-ssr-lite 0.2.12 → 0.2.14
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.
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vite 7 `resolveRollupOptions` path-resolves a string `build.ssr` entry against
|
|
3
|
+
* the project root. Virtual ids such as `virtual:vue-ssr-lite/runtime` become
|
|
4
|
+
* filesystem paths like `<root>/virtual:vue-ssr-lite/runtime`, so plugin
|
|
5
|
+
* `resolveId` never matches and Rollup reports `UNRESOLVED_ENTRY`.
|
|
6
|
+
*
|
|
7
|
+
* Pass the virtual module through `rollupOptions.input` with `build.ssr: true`
|
|
8
|
+
* instead — that path is not filesystem-resolved.
|
|
9
|
+
*/
|
|
10
|
+
export declare const createSsrProductionViteBuildOptions: (root: string) => {
|
|
11
|
+
root: string;
|
|
12
|
+
build: {
|
|
13
|
+
ssr: true;
|
|
14
|
+
outDir: string;
|
|
15
|
+
emptyOutDir: boolean;
|
|
16
|
+
rollupOptions: {
|
|
17
|
+
input: string;
|
|
18
|
+
output: {
|
|
19
|
+
entryFileNames: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=SsrCliBuildOptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SsrCliBuildOptions.d.ts","sourceRoot":"","sources":["../../src/cli/SsrCliBuildOptions.ts"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AACH,eAAO,MAAM,mCAAmC,GAAI,MAAM,MAAM;;;;;;;;;;;;;CAW9D,CAAA"}
|
package/dist/cli.mjs
CHANGED
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { resolve as c } from "node:path";
|
|
3
3
|
import { pathToFileURL as f } from "node:url";
|
|
4
|
-
import {
|
|
4
|
+
import { S as m, r as w } from "./chunks/SsrHtmlRuntime-BJUxjM2F.mjs";
|
|
5
5
|
import { c as S } from "./chunks/SsrServerRuntime-BbWemkgs.mjs";
|
|
6
6
|
import { createServer as R } from "node:net";
|
|
7
|
-
const
|
|
7
|
+
const b = (r) => ({
|
|
8
|
+
root: r,
|
|
9
|
+
build: {
|
|
10
|
+
ssr: !0,
|
|
11
|
+
outDir: c(r, "dist/server"),
|
|
12
|
+
emptyOutDir: !0,
|
|
13
|
+
rollupOptions: {
|
|
14
|
+
input: m,
|
|
15
|
+
output: { entryFileNames: "SsrRuntime.js" }
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}), i = 1, a = 65535, h = (r) => {
|
|
8
19
|
const e = r?.trim();
|
|
9
20
|
if (!e) return;
|
|
10
21
|
if (!/^\d+$/.test(e))
|
|
@@ -13,7 +24,7 @@ const i = 1, a = 65535, b = (r) => {
|
|
|
13
24
|
if (!Number.isInteger(t) || t < i || t > a)
|
|
14
25
|
throw new Error(`HMR port must be an integer between ${i} and ${a}.`);
|
|
15
26
|
return t;
|
|
16
|
-
},
|
|
27
|
+
}, P = () => new Promise((r, e) => {
|
|
17
28
|
const t = R();
|
|
18
29
|
t.once("error", e), t.listen({ port: 0, exclusive: !0 }, () => {
|
|
19
30
|
const o = t.address();
|
|
@@ -25,10 +36,10 @@ const i = 1, a = 65535, b = (r) => {
|
|
|
25
36
|
s ? e(s) : r(o.port);
|
|
26
37
|
});
|
|
27
38
|
});
|
|
28
|
-
}),
|
|
39
|
+
}), T = async (r) => h(r) ?? P(), n = (r, e) => {
|
|
29
40
|
const t = r.indexOf(e);
|
|
30
41
|
return t >= 0 ? r[t + 1] : void 0;
|
|
31
|
-
},
|
|
42
|
+
}, g = async (r) => {
|
|
32
43
|
const e = r[0];
|
|
33
44
|
if (!["dev", "build", "start"].includes(e))
|
|
34
45
|
throw new Error(
|
|
@@ -45,8 +56,8 @@ const i = 1, a = 65535, b = (r) => {
|
|
|
45
56
|
),
|
|
46
57
|
hmrPort: n(r, "--hmr-port") || process.env.VUE_SSR_LITE_HMR_PORT
|
|
47
58
|
};
|
|
48
|
-
},
|
|
49
|
-
const t = e ? void 0 : await
|
|
59
|
+
}, I = async (r, e) => {
|
|
60
|
+
const t = e ? void 0 : await T(r.hmrPort), o = e ? void 0 : (await import("vite")).createServer, s = e ? void 0 : await o({
|
|
50
61
|
root: r.root,
|
|
51
62
|
server: {
|
|
52
63
|
middlewareMode: !0,
|
|
@@ -57,11 +68,11 @@ const i = 1, a = 65535, b = (r) => {
|
|
|
57
68
|
production: e,
|
|
58
69
|
root: r.root,
|
|
59
70
|
vite: s,
|
|
60
|
-
loadRuntime: e ? () => import(f(r.serverOutput).href) : () => s.ssrLoadModule(
|
|
71
|
+
loadRuntime: e ? () => import(f(r.serverOutput).href) : () => s.ssrLoadModule(m)
|
|
61
72
|
});
|
|
62
73
|
await l.listen();
|
|
63
74
|
let d = !1;
|
|
64
|
-
const
|
|
75
|
+
const u = async (p) => {
|
|
65
76
|
if (!d) {
|
|
66
77
|
d = !0;
|
|
67
78
|
try {
|
|
@@ -72,27 +83,17 @@ const i = 1, a = 65535, b = (r) => {
|
|
|
72
83
|
}
|
|
73
84
|
};
|
|
74
85
|
process.once("SIGINT", () => {
|
|
75
|
-
|
|
86
|
+
u("SIGINT");
|
|
76
87
|
}), process.once("SIGTERM", () => {
|
|
77
|
-
|
|
88
|
+
u("SIGTERM");
|
|
78
89
|
});
|
|
79
|
-
},
|
|
90
|
+
}, M = async (r) => {
|
|
80
91
|
const { build: e } = await import("vite");
|
|
81
|
-
await e({ root: r.root }), await e(
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
outDir: c(r.root, "dist/server"),
|
|
86
|
-
emptyOutDir: !0,
|
|
87
|
-
rollupOptions: {
|
|
88
|
-
output: { entryFileNames: "SsrRuntime.js" }
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
}, M = async () => {
|
|
93
|
-
const r = await T(process.argv.slice(2));
|
|
94
|
-
return r.command === "build" ? I(r) : g(r, r.command === "start");
|
|
92
|
+
await e({ root: r.root }), await e(b(r.root));
|
|
93
|
+
}, y = async () => {
|
|
94
|
+
const r = await g(process.argv.slice(2));
|
|
95
|
+
return r.command === "build" ? M(r) : I(r, r.command === "start");
|
|
95
96
|
};
|
|
96
|
-
|
|
97
|
+
y().catch((r) => {
|
|
97
98
|
console.error("fatal error", r), process.exitCode = 1;
|
|
98
99
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SsrVitePlugin.d.ts","sourceRoot":"","sources":["../../src/vite/SsrVitePlugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAiB,MAAM,MAAM,CAAA;AAEjD,OAAO,EAQL,KAAK,uBAAuB,EAE7B,MAAM,4BAA4B,CAAA;AAGnC,YAAY,EAAE,uBAAuB,EAAE,CAAA;AAEvC,MAAM,WAAW,oBAAoB;IACnC,sEAAsE;IACtE,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IACjB;;OAEG;IACH,aAAa,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAA;CACpC;
|
|
1
|
+
{"version":3,"file":"SsrVitePlugin.d.ts","sourceRoot":"","sources":["../../src/vite/SsrVitePlugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAiB,MAAM,MAAM,CAAA;AAEjD,OAAO,EAQL,KAAK,uBAAuB,EAE7B,MAAM,4BAA4B,CAAA;AAGnC,YAAY,EAAE,uBAAuB,EAAE,CAAA;AAEvC,MAAM,WAAW,oBAAoB;IACnC,sEAAsE;IACtE,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IACjB;;OAEG;IACH,aAAa,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAA;CACpC;AAgCD,eAAO,MAAM,UAAU,GAAI,UAAS,oBAAyB,KAAG,MAsJ/D,CAAA"}
|
package/dist/vite.mjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { resolve as d } from "node:path";
|
|
2
|
-
import { normalizePath as
|
|
3
|
-
import { r as
|
|
2
|
+
import { normalizePath as g } from "vite";
|
|
3
|
+
import { r as _, k as $, a as m, S, n as D, h as C, p as O, j as T } from "./chunks/SsrHtmlRuntime-BJUxjM2F.mjs";
|
|
4
4
|
const L = [
|
|
5
5
|
"@vue/server-renderer",
|
|
6
6
|
"vue",
|
|
7
7
|
"vue-router",
|
|
8
8
|
"vue-ssr-lite"
|
|
9
|
-
],
|
|
10
|
-
const
|
|
11
|
-
return
|
|
12
|
-
},
|
|
13
|
-
let
|
|
9
|
+
], I = `\0${S}`, p = `\0${m}`, f = "dist/client", U = (r) => r === S || r.endsWith(`/${S}`) || r.endsWith(`\\${S}`), b = /<script\b(?=[^>]*\btype\s*=\s*["']module["'])(?=[^>]*\bsrc\s*=\s*["'][^"']+["'])[^>]*>\s*<\/script>/gi, N = (r, n) => {
|
|
10
|
+
const i = g(r);
|
|
11
|
+
return n && i === g(n) ? !0 : /\/ssr\.config\.(ts|mts|js|mjs)$/.test(i);
|
|
12
|
+
}, P = (r = {}) => {
|
|
13
|
+
let n = d(r.root || process.cwd()), i = "", o = null, E = f;
|
|
14
14
|
const c = /* @__PURE__ */ new Map(), w = () => {
|
|
15
15
|
c.clear();
|
|
16
16
|
for (const t of o?.applications ?? [])
|
|
@@ -22,90 +22,93 @@ const L = [
|
|
|
22
22
|
o = null, c.clear(), E = f;
|
|
23
23
|
}, u = async () => {
|
|
24
24
|
if (o) return o;
|
|
25
|
-
|
|
26
|
-
const t = await D(
|
|
27
|
-
return o =
|
|
28
|
-
},
|
|
29
|
-
const e = t.moduleGraph.getModuleById(
|
|
25
|
+
i = await _(n, r.config);
|
|
26
|
+
const t = await D(n, i);
|
|
27
|
+
return o = C(t), E = t.server?.clientOutDir || f, w(), o;
|
|
28
|
+
}, R = (t) => {
|
|
29
|
+
const e = t.moduleGraph.getModuleById(I);
|
|
30
30
|
e && t.moduleGraph.invalidateModule(e);
|
|
31
31
|
for (const l of o?.applications ?? []) {
|
|
32
|
-
const
|
|
33
|
-
|
|
32
|
+
const s = `${p}${l.id}`, a = t.moduleGraph.getModuleById(s);
|
|
33
|
+
a && t.moduleGraph.invalidateModule(a);
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
36
|
return {
|
|
37
37
|
name: "vue-ssr-lite",
|
|
38
38
|
enforce: "pre",
|
|
39
|
+
// Keep one plugin instance across client/SSR environment config clones so
|
|
40
|
+
// virtual-module state stays consistent during production builds.
|
|
41
|
+
sharedDuringBuild: !0,
|
|
39
42
|
async config(t, e) {
|
|
40
|
-
|
|
41
|
-
const l = await u(),
|
|
42
|
-
l.applications.map((
|
|
43
|
-
|
|
44
|
-
d(
|
|
43
|
+
n = d(r.root || t.root || process.cwd());
|
|
44
|
+
const l = await u(), s = Object.fromEntries(
|
|
45
|
+
l.applications.map((h) => [
|
|
46
|
+
h.id,
|
|
47
|
+
d(n, h.template)
|
|
45
48
|
])
|
|
46
|
-
),
|
|
49
|
+
), a = t.build?.outDir || E || f;
|
|
47
50
|
return {
|
|
48
51
|
resolve: {
|
|
49
|
-
dedupe: [.../* @__PURE__ */ new Set([...L, ...
|
|
52
|
+
dedupe: [.../* @__PURE__ */ new Set([...L, ...r.dedupe ?? []])]
|
|
50
53
|
},
|
|
51
54
|
ssr: {
|
|
52
55
|
external: ["vue-ssr-lite"],
|
|
53
|
-
noExternal: [...new Set(
|
|
56
|
+
noExternal: [...new Set(r.ssrNoExternal ?? [])]
|
|
54
57
|
},
|
|
55
58
|
build: e.isSsrBuild ? void 0 : {
|
|
56
59
|
manifest: !0,
|
|
57
|
-
outDir:
|
|
58
|
-
rollupOptions: { input:
|
|
60
|
+
outDir: a,
|
|
61
|
+
rollupOptions: { input: s }
|
|
59
62
|
}
|
|
60
63
|
};
|
|
61
64
|
},
|
|
62
65
|
configResolved(t) {
|
|
63
|
-
|
|
66
|
+
n = t.root;
|
|
64
67
|
},
|
|
65
68
|
configureServer(t) {
|
|
66
69
|
u().then(() => {
|
|
67
|
-
|
|
70
|
+
i && t.watcher.add(i);
|
|
68
71
|
});
|
|
69
72
|
},
|
|
70
73
|
async handleHotUpdate({ file: t, server: e }) {
|
|
71
|
-
if (
|
|
72
|
-
return
|
|
74
|
+
if (N(t, i))
|
|
75
|
+
return R(e), y(), await u(), i && e.watcher.add(i), R(e), e.ws.send({ type: "full-reload" }), [];
|
|
73
76
|
},
|
|
74
77
|
resolveId(t) {
|
|
75
|
-
if (t
|
|
78
|
+
if (U(t)) return I;
|
|
76
79
|
if (c.has(t))
|
|
77
80
|
return `${p}${t.slice(m.length)}`;
|
|
78
81
|
},
|
|
79
82
|
async load(t) {
|
|
80
|
-
if (t ===
|
|
81
|
-
const
|
|
82
|
-
return
|
|
83
|
+
if (t === I) {
|
|
84
|
+
const s = await u(), a = i || await _(n, r.config);
|
|
85
|
+
return $(n, a, s.applications);
|
|
83
86
|
}
|
|
84
87
|
if (!t.startsWith(p)) return;
|
|
85
88
|
const e = t.slice(p.length), l = o?.applications.find(
|
|
86
|
-
({ id:
|
|
89
|
+
({ id: s }) => s === e
|
|
87
90
|
);
|
|
88
91
|
if (l)
|
|
89
|
-
return T(
|
|
92
|
+
return T(n, l);
|
|
90
93
|
},
|
|
91
94
|
transformIndexHtml: {
|
|
92
95
|
order: "pre",
|
|
93
96
|
handler(t, e) {
|
|
94
|
-
const l =
|
|
95
|
-
(M) => l ===
|
|
97
|
+
const l = g(e.filename), s = o?.applications.find(
|
|
98
|
+
(M) => l === g(d(n, M.template))
|
|
96
99
|
);
|
|
97
|
-
if (!
|
|
98
|
-
const
|
|
100
|
+
if (!s) return t;
|
|
101
|
+
const a = `${m}${s.id}`, v = O(
|
|
99
102
|
t,
|
|
100
|
-
|
|
101
|
-
).replace(
|
|
102
|
-
return v.includes(`import ${JSON.stringify(
|
|
103
|
+
s.mountSelector || "#app"
|
|
104
|
+
).replace(b, "");
|
|
105
|
+
return v.includes(`import ${JSON.stringify(a)}`) ? v : {
|
|
103
106
|
html: v,
|
|
104
107
|
tags: [
|
|
105
108
|
{
|
|
106
109
|
tag: "script",
|
|
107
110
|
attrs: { type: "module" },
|
|
108
|
-
children: `import ${JSON.stringify(
|
|
111
|
+
children: `import ${JSON.stringify(a)}`,
|
|
109
112
|
injectTo: "body"
|
|
110
113
|
}
|
|
111
114
|
]
|
|
@@ -115,5 +118,5 @@ const L = [
|
|
|
115
118
|
};
|
|
116
119
|
};
|
|
117
120
|
export {
|
|
118
|
-
|
|
121
|
+
P as vueSsrLite
|
|
119
122
|
};
|