@withl5e/l5e 1.1.0-alpha.0 → 1.1.0-alpha.2
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/README.md +29 -0
- package/dist/index.js +2 -2
- package/dist/island/compact-runtime.js +98 -0
- package/dist/island/compact-runtime.js.map +1 -0
- package/dist/island/runtime.js +7 -3
- package/dist/island/runtime.js.map +1 -1
- package/dist/{server-CvsOU9cg.js → server-C35BtVu8.js} +311 -127
- package/dist/server-C35BtVu8.js.map +1 -0
- package/dist/server.js +1 -1
- package/dist/{vite-plugin-D9qTnleZ.js → vite-plugin-BOuzxmb2.js} +184 -138
- package/dist/vite-plugin-BOuzxmb2.js.map +1 -0
- package/dist/vite-plugin.js +1 -1
- package/package.json +7 -1
- package/src/core/bundler.ts +93 -10
- package/src/core/chunking.ts +113 -6
- package/src/core/script-bundle-policy.ts +99 -2
- package/src/core/server.ts +190 -8
- package/src/core/vite-plugin.ts +35 -5
- package/src/island/compact-runtime.ts +158 -0
- package/src/island/runtime.ts +22 -8
- package/dist/server-CvsOU9cg.js.map +0 -1
- package/dist/vite-plugin-D9qTnleZ.js.map +0 -1
|
@@ -13,94 +13,136 @@ function _(e) {
|
|
|
13
13
|
return n[0].startsWith("@") ? n.slice(0, 2).join("/") : n[0];
|
|
14
14
|
}
|
|
15
15
|
function v(e = {}) {
|
|
16
|
-
let t = e.shared || [], n =
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
n.
|
|
16
|
+
let t = e.shared || [], n = e.islandRuntime;
|
|
17
|
+
if (n && !n.packages?.length && !n.modules?.length) throw Error("[l5e chunking] islandRuntime needs packages or modules.");
|
|
18
|
+
if (e.mode === "compact" && t.length > 1) throw Error("[l5e chunking] Compact mode accepts one canonical shared group.");
|
|
19
|
+
let r = /* @__PURE__ */ new Set();
|
|
20
|
+
for (let n of t) {
|
|
21
|
+
if (!/^[a-zA-Z0-9][a-zA-Z0-9_-]*$/.test(n.name) || r.has(n.name)) throw Error(`[l5e chunking] Invalid or duplicate shared group: ${n.name}`);
|
|
22
|
+
if (!n.packages?.length && !n.modules?.length) throw Error(`[l5e chunking] Group ${n.name} needs packages or modules.`);
|
|
23
|
+
if (n.maxSize !== void 0 && (!Number.isFinite(n.maxSize) || n.maxSize <= 0)) throw Error(`[l5e chunking] Invalid maxSize for ${n.name}`);
|
|
24
|
+
if (e.mode === "compact" && n.maxSize !== void 0) throw Error(`[l5e chunking] Compact mode cannot use maxSize for ${n.name}; it would split the canonical shared file.`);
|
|
25
|
+
r.add(n.name);
|
|
22
26
|
}
|
|
23
|
-
let
|
|
27
|
+
let i = "", a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Set(), u = (e) => _(e) ? `npm:${h(e).split("/node_modules/").at(-1)}` : h(c.relative(i, e));
|
|
24
28
|
return {
|
|
25
|
-
async resolve(e,
|
|
26
|
-
|
|
29
|
+
async resolve(e, r) {
|
|
30
|
+
i = e, a.clear(), o = /* @__PURE__ */ new Set(), s.clear(), l.clear();
|
|
27
31
|
for (let e of t) {
|
|
28
32
|
let t = /* @__PURE__ */ new Set();
|
|
29
|
-
for (let
|
|
30
|
-
let a = await n
|
|
31
|
-
if (!a) throw Error(`[l5e chunking] Cannot resolve ${
|
|
33
|
+
for (let n of e.modules || []) {
|
|
34
|
+
let a = await r(n, c.join(i, "index.html"));
|
|
35
|
+
if (!a) throw Error(`[l5e chunking] Cannot resolve ${n} in ${e.name}`);
|
|
32
36
|
t.add(a);
|
|
33
37
|
}
|
|
34
|
-
|
|
38
|
+
a.set(e, t);
|
|
39
|
+
}
|
|
40
|
+
if (n) for (let e of n.modules || []) {
|
|
41
|
+
let t = await r(e, c.join(i, "index.html"));
|
|
42
|
+
if (!t) throw Error(`[l5e chunking] Cannot resolve ${e} in islandRuntime`);
|
|
43
|
+
o.add(t);
|
|
35
44
|
}
|
|
36
45
|
},
|
|
37
|
-
analyze(
|
|
38
|
-
|
|
39
|
-
let
|
|
40
|
-
|
|
41
|
-
let
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
46
|
+
analyze(r) {
|
|
47
|
+
s.clear();
|
|
48
|
+
let i = new Map(r.map((e) => [e.id, e]));
|
|
49
|
+
if (e.mode === "compact") {
|
|
50
|
+
let e = /* @__PURE__ */ new Map();
|
|
51
|
+
for (let t of r.filter((e) => e.isEntry)) {
|
|
52
|
+
let n = (r, a) => {
|
|
53
|
+
let o = e.get(r) || /* @__PURE__ */ new Map(), s = o.get(t.id);
|
|
54
|
+
if (s === !1 || s === a) return;
|
|
55
|
+
o.set(t.id, a), e.set(r, o);
|
|
56
|
+
let c = i.get(r);
|
|
57
|
+
c && (c.importedIds.forEach((e) => n(e, a)), c.dynamicallyImportedIds.forEach((e) => n(e, !0)));
|
|
58
|
+
};
|
|
59
|
+
n(t.id, !1);
|
|
60
|
+
}
|
|
61
|
+
let t = r.find((e) => e.isEntry && h(e.id).endsWith("/src/client.global.ts"));
|
|
62
|
+
if (t) {
|
|
63
|
+
for (let [n, r] of e) if (!/\.css(?:\?|$)/.test(h(n)) && r.get(t.id) === !0 && [...r.keys()].some((e) => e !== t.id)) throw Error(`[l5e chunking] Compact mode cannot bridge a dynamic-only global overlap: ${u(n)}. Import it statically from global or place state behind an explicit shared root.`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
let c = r.filter((e) => e.isEntry || e.dynamicImporters.length > 0), d = /* @__PURE__ */ new Map();
|
|
67
|
+
for (let e of c) {
|
|
68
|
+
let t = /* @__PURE__ */ new Set(), n = (r) => {
|
|
69
|
+
if (t.has(r)) return;
|
|
70
|
+
t.add(r);
|
|
71
|
+
let a = i.get(r);
|
|
45
72
|
if (!a) return;
|
|
46
|
-
let o =
|
|
47
|
-
o.add(e.id),
|
|
73
|
+
let o = d.get(r) || /* @__PURE__ */ new Set();
|
|
74
|
+
o.add(e.id), d.set(r, o), a.importedIds.forEach(n);
|
|
48
75
|
};
|
|
49
|
-
|
|
76
|
+
n(e.id);
|
|
50
77
|
}
|
|
51
|
-
let
|
|
52
|
-
for (let
|
|
53
|
-
let
|
|
54
|
-
|
|
55
|
-
let
|
|
56
|
-
if (
|
|
57
|
-
|
|
78
|
+
let f = (e) => i.get(e).isEntry ? h(e).endsWith("/src/client.global.ts") ? 0 : h(e).includes("virtual:l5e-compact-renderer") || /\/react\//.test(h(e)) && !_(e) ? 2 : 1 : 3, p = /* @__PURE__ */ new Set();
|
|
79
|
+
for (let i of r) {
|
|
80
|
+
let r = [...d.get(i.id) || []].sort(), c = r.map(u).sort(), m = t.filter((e) => a.get(e)?.has(i.id) || e.packages?.includes(_(i.id) || "")).sort((e, t) => (t.priority || 0) - (e.priority || 0));
|
|
81
|
+
m.forEach((e) => p.add(e)), m.length > 1 && l.add(`${u(i.id)} matches ${m.map((e) => e.name).join(", ")}; using ${m[0].name}.`);
|
|
82
|
+
let v = null, y = "Private dependency stays with its entry or dynamic import.", b = _(i.id), x = o.has(i.id) || n?.packages?.includes(b || "") === !0;
|
|
83
|
+
if (e.mode === "compact" && h(i.id).includes("virtual:l5e-compact-renderer")) v = "lazy-react-runtime", y = "Renderer joins the canonical React runtime activation.";
|
|
84
|
+
else if (e.mode === "compact" && !i.isEntry && (b === "react" || b === "react-dom" || b === "scheduler") && r.length > 0 && r.every((e) => f(e) >= 2)) v = "lazy-react-runtime", y = "Canonical React runtime is fetched when the first island activates.";
|
|
85
|
+
else if (!i.isEntry && r.length && m.length) {
|
|
86
|
+
let t = Math.min(...r.map(f)), n = t === 3 ? `lazy-${g(JSON.stringify(c))}` : [
|
|
58
87
|
"global",
|
|
59
88
|
"page",
|
|
60
89
|
"island"
|
|
61
90
|
][t];
|
|
62
|
-
|
|
63
|
-
} else !
|
|
64
|
-
|
|
65
|
-
group:
|
|
66
|
-
rule:
|
|
67
|
-
consumers:
|
|
68
|
-
reason:
|
|
91
|
+
v = e.mode === "compact" ? "shared" : `shared-${m[0].name}-${n}`, y = `Configured group ${m[0].name}; activation ${n}.`;
|
|
92
|
+
} else e.mode === "compact" && !i.isEntry && x ? (v = "lazy-react-runtime", y = "Configured canonical island runtime is fetched with the first island consumer.") : e.mode === "compact" && !i.isEntry && r.some((e) => f(e) === 0) && r.some((e) => f(e) > 0) ? (v = "global-owner", y = "Static global/page overlap is exported by the canonical global artifact.") : e.mode !== "compact" && !i.isEntry && r.length > 1 && (v = `shared-auto-${g(JSON.stringify(c))}`, y = "Shared by the same static consumers; preserves dynamic import roots.");
|
|
93
|
+
s.set(i.id, {
|
|
94
|
+
group: v,
|
|
95
|
+
rule: m[0]?.name,
|
|
96
|
+
consumers: c,
|
|
97
|
+
reason: y
|
|
69
98
|
});
|
|
70
99
|
}
|
|
71
|
-
for (let e of t)
|
|
72
|
-
return [...
|
|
100
|
+
for (let e of t) p.has(e) || l.add(`Group ${e.name} matched no modules in this client build.`);
|
|
101
|
+
return [...l];
|
|
73
102
|
},
|
|
74
103
|
groups() {
|
|
75
|
-
return [
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
104
|
+
return [
|
|
105
|
+
...t.map((t) => ({
|
|
106
|
+
name: (e) => {
|
|
107
|
+
let n = s.get(e);
|
|
108
|
+
return n?.rule === t.name ? n.group : null;
|
|
109
|
+
},
|
|
110
|
+
maxSize: t.maxSize,
|
|
111
|
+
includeDependenciesRecursively: e.mode === "compact"
|
|
112
|
+
})),
|
|
113
|
+
{
|
|
114
|
+
name: (e) => s.get(e)?.group === "lazy-react-runtime" ? "lazy-react-runtime" : null,
|
|
115
|
+
includeDependenciesRecursively: !0
|
|
79
116
|
},
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
117
|
+
{
|
|
118
|
+
name: (e) => {
|
|
119
|
+
let t = s.get(e)?.group;
|
|
120
|
+
return t === "lazy-react-runtime" ? null : t || null;
|
|
121
|
+
},
|
|
122
|
+
includeDependenciesRecursively: !1
|
|
123
|
+
}
|
|
124
|
+
];
|
|
86
125
|
},
|
|
87
|
-
report(
|
|
126
|
+
report(t) {
|
|
88
127
|
return {
|
|
89
|
-
version:
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
128
|
+
version: 2,
|
|
129
|
+
mode: e.mode || "default",
|
|
130
|
+
warnings: [...l],
|
|
131
|
+
chunks: Object.values(t).flatMap((t) => {
|
|
132
|
+
if (t.type !== "chunk") return [];
|
|
133
|
+
let n = t.facadeModuleId ? u(t.facadeModuleId) : null, r = n === "src/client.global.ts" ? "global" : n && /(?:^|\/)react\//.test(n) ? "island" : t.isEntry || t.isDynamicEntry ? "page" : "shared";
|
|
94
134
|
return [{
|
|
95
|
-
file:
|
|
96
|
-
kind:
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
135
|
+
file: t.fileName,
|
|
136
|
+
kind: r,
|
|
137
|
+
canonicalShared: e.mode === "compact" && t.name === "shared",
|
|
138
|
+
canonicalGlobal: e.mode === "compact" && t.name === "global-owner",
|
|
139
|
+
source: n,
|
|
140
|
+
bytes: Buffer.byteLength(t.code),
|
|
141
|
+
imports: t.imports,
|
|
142
|
+
dynamicImports: t.dynamicImports,
|
|
143
|
+
modules: Object.keys(t.modules).map((e) => ({
|
|
144
|
+
id: u(e),
|
|
145
|
+
...s.get(e)
|
|
104
146
|
}))
|
|
105
147
|
}];
|
|
106
148
|
})
|
|
@@ -110,7 +152,7 @@ function v(e = {}) {
|
|
|
110
152
|
}
|
|
111
153
|
//#endregion
|
|
112
154
|
//#region src/core/vite-plugin.ts
|
|
113
|
-
var y = "virtual:l5e-views", b = "virtual:l5e-route", x = "virtual:l5e-ssr-entry", S = "virtual:l5e-global-loader", C = "virtual:l5e-island-strategies", w = "virtual:l5e-islands", T = "virtual:l5e-
|
|
155
|
+
var y = "virtual:l5e-views", b = "virtual:l5e-route", x = "virtual:l5e-ssr-entry", S = "virtual:l5e-global-loader", C = "virtual:l5e-island-strategies", w = "virtual:l5e-islands", T = "virtual:l5e-compact-renderer", E = "virtual:l5e-actions", D = "virtual:l5e-middleware", O = /* @__PURE__ */ new Set([
|
|
114
156
|
"MODE",
|
|
115
157
|
"BASE_URL",
|
|
116
158
|
"PROD",
|
|
@@ -118,30 +160,30 @@ var y = "virtual:l5e-views", b = "virtual:l5e-route", x = "virtual:l5e-ssr-entry
|
|
|
118
160
|
"SSR",
|
|
119
161
|
"LEGACY"
|
|
120
162
|
]);
|
|
121
|
-
function
|
|
163
|
+
function k(e, t = []) {
|
|
122
164
|
let n = i(e);
|
|
123
165
|
for (let r of n) {
|
|
124
166
|
let n = f(e, r);
|
|
125
167
|
if (o(n).isDirectory()) {
|
|
126
168
|
if (r === "node_modules" || r === "dist" || r === ".git") continue;
|
|
127
|
-
|
|
169
|
+
k(n, t);
|
|
128
170
|
} else (r.endsWith(".tsx") || r.endsWith(".ts")) && t.push(n);
|
|
129
171
|
}
|
|
130
172
|
return t;
|
|
131
173
|
}
|
|
132
|
-
function
|
|
174
|
+
function A(e) {
|
|
133
175
|
let t = 0;
|
|
134
176
|
for (let n = 0; n < e.length; n++) t = (t << 5) - t + e.charCodeAt(n), t &= t;
|
|
135
177
|
return Math.abs(t).toString(16).slice(0, 4);
|
|
136
178
|
}
|
|
137
|
-
function
|
|
179
|
+
function j(e) {
|
|
138
180
|
let t = e.split("/"), n = t[t.length - 1];
|
|
139
181
|
return n = n.replace(/\.(tsx?|jsx?)$/, ""), n;
|
|
140
182
|
}
|
|
141
|
-
function
|
|
142
|
-
return `${
|
|
183
|
+
function M(e) {
|
|
184
|
+
return `${j(e)}_${A(e)}`;
|
|
143
185
|
}
|
|
144
|
-
function
|
|
186
|
+
function N(e, n) {
|
|
145
187
|
let r = e.replace(/^\//, ""), i = m(n, r);
|
|
146
188
|
for (let e of [
|
|
147
189
|
".tsx",
|
|
@@ -151,7 +193,7 @@ function M(e, n) {
|
|
|
151
193
|
]) if (t(i + e)) return r + e;
|
|
152
194
|
return t(i) ? r : null;
|
|
153
195
|
}
|
|
154
|
-
function
|
|
196
|
+
function P(e, t) {
|
|
155
197
|
let n = r(e, "utf-8"), i = [], a = /<ClientIsland\s[^>]*?from\s*=\s*"([^"]+)"/g, o = /* @__PURE__ */ new Set(), s;
|
|
156
198
|
for (; (s = a.exec(n)) !== null;) {
|
|
157
199
|
let n = s[1], r;
|
|
@@ -161,14 +203,14 @@ function N(e, t) {
|
|
|
161
203
|
let i = m(e, "..", n);
|
|
162
204
|
r = "/" + p(t, i).replace(/\\/g, "/");
|
|
163
205
|
} else r = n;
|
|
164
|
-
let a =
|
|
206
|
+
let a = N(r, t);
|
|
165
207
|
if (!a) {
|
|
166
208
|
console.warn(`[l5e] Island component not found: ${r} (from ${n} in ${e})`);
|
|
167
209
|
continue;
|
|
168
210
|
}
|
|
169
|
-
let c =
|
|
211
|
+
let c = M(r);
|
|
170
212
|
o.has(c) || (o.add(c), i.push({
|
|
171
|
-
component:
|
|
213
|
+
component: j(r),
|
|
172
214
|
resolvedPath: r,
|
|
173
215
|
src: a,
|
|
174
216
|
key: c
|
|
@@ -176,7 +218,7 @@ function N(e, t) {
|
|
|
176
218
|
}
|
|
177
219
|
return i;
|
|
178
220
|
}
|
|
179
|
-
function
|
|
221
|
+
function F(e, t) {
|
|
180
222
|
let n = r(e, "utf-8"), i = [], a = [], o = /useCss\s*\(\s*['"]([^'"]+)['"]\s*,?\s*\)/g, s = /useClientJs\s*\(\s*['"]([^'"]+)['"]\s*,?\s*\)/g, c;
|
|
181
223
|
for (; (c = o.exec(n)) !== null;) {
|
|
182
224
|
let n = c[1];
|
|
@@ -199,7 +241,7 @@ function P(e, t) {
|
|
|
199
241
|
js: a
|
|
200
242
|
};
|
|
201
243
|
}
|
|
202
|
-
function
|
|
244
|
+
function I(n) {
|
|
203
245
|
let i = {}, a = f(n, "src"), s = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map();
|
|
204
246
|
try {
|
|
205
247
|
if (!o(a).isDirectory()) return {
|
|
@@ -213,17 +255,17 @@ function F(n) {
|
|
|
213
255
|
t(h) && (i.global = h, console.log("[l5e] Detected src/client.global.ts and added as entry"));
|
|
214
256
|
let g = e(n);
|
|
215
257
|
g && (i["global-style"] = g, console.log("[l5e] Detected src/global.css and added as global stylesheet"));
|
|
216
|
-
let _ =
|
|
258
|
+
let _ = k(a), v = /* @__PURE__ */ new Set(), y = /* @__PURE__ */ new Set();
|
|
217
259
|
for (let e of _) {
|
|
218
|
-
let { css: t, js: i } =
|
|
260
|
+
let { css: t, js: i } = F(e, n);
|
|
219
261
|
t.forEach((e) => v.add(e)), i.forEach((e) => y.add(e));
|
|
220
|
-
let o =
|
|
262
|
+
let o = P(e, n);
|
|
221
263
|
for (let e of o) s.set(e.key, e.resolvedPath), c.set(e.resolvedPath, e.key), l.set(e.key, e.src);
|
|
222
264
|
let f = e.replace(/\\/g, "/");
|
|
223
265
|
if (/\/actions\.(ts|tsx)$/.test(f)) {
|
|
224
266
|
let t = r(e, "utf-8"), n = /export\s+const\s+(\w+)\s*=\s*defineAction\s*\(/g, i, o = p(a, d(e)).replace(/\\/g, "/") || ".";
|
|
225
267
|
for (; (i = n.exec(t)) !== null;) {
|
|
226
|
-
let e = i[1], t = `${e}_${
|
|
268
|
+
let e = i[1], t = `${e}_${A(o)}`;
|
|
227
269
|
u.set(t, {
|
|
228
270
|
modulePath: o,
|
|
229
271
|
actionName: e
|
|
@@ -266,7 +308,7 @@ function F(n) {
|
|
|
266
308
|
actionRegistry: u
|
|
267
309
|
};
|
|
268
310
|
}
|
|
269
|
-
function
|
|
311
|
+
function L(e, t, n, r, i) {
|
|
270
312
|
let a = [], o = 0, s = /ClientIsland\s*,\s*\{/g, c;
|
|
271
313
|
for (; (c = s.exec(e)) !== null;) {
|
|
272
314
|
let s = c.index + c[0].length, l = e.substring(s, s + 500), u = /from:\s*"([^"]+)"/.exec(l);
|
|
@@ -287,7 +329,7 @@ function I(e, t, n, r, i) {
|
|
|
287
329
|
}
|
|
288
330
|
return a.push(e.substring(o)), a.join("");
|
|
289
331
|
}
|
|
290
|
-
function
|
|
332
|
+
function R(e = {}) {
|
|
291
333
|
let r = process.cwd(), i = !1, o = e.chunking === !1 ? null : v(e.chunking), c = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Map();
|
|
292
334
|
return {
|
|
293
335
|
name: "l5e-jsx-classic",
|
|
@@ -311,7 +353,7 @@ function L(e = {}) {
|
|
|
311
353
|
handleHotUpdate({ file: e, server: t }) {
|
|
312
354
|
let n = p(r, e);
|
|
313
355
|
if (/actions\.(ts|tsx)$/.test(e)) {
|
|
314
|
-
d =
|
|
356
|
+
d = I(r).actionRegistry;
|
|
315
357
|
let e = t.moduleGraph.getModuleById("\0virtual:l5e-actions");
|
|
316
358
|
e && t.moduleGraph.invalidateModule(e), console.log(`[l5e] Action file changed: ${n} — re-scanned ${d.size} action(s)`);
|
|
317
359
|
}
|
|
@@ -351,60 +393,63 @@ function L(e = {}) {
|
|
|
351
393
|
s(f(e, "action-registry.json"), JSON.stringify(i), "utf-8"), console.log(`[l5e] Wrote action-registry.json (${d.size} actions)`);
|
|
352
394
|
}
|
|
353
395
|
},
|
|
354
|
-
config(
|
|
355
|
-
let
|
|
356
|
-
if (
|
|
357
|
-
let
|
|
358
|
-
|
|
359
|
-
let
|
|
360
|
-
...
|
|
361
|
-
...
|
|
362
|
-
} :
|
|
363
|
-
return
|
|
364
|
-
...e.
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
396
|
+
config(t) {
|
|
397
|
+
let n = t.root || process.cwd(), r = t.build?.rolldownOptions?.output, i = !t.build?.ssr && o !== null;
|
|
398
|
+
if (i && (Array.isArray(r) || r?.manualChunks || r?.codeSplitting !== void 0)) throw Error("[l5e chunking] Use coreVite({ chunking: { shared: [...] } }) or set chunking: false when configuring raw Rolldown chunk placement.");
|
|
399
|
+
let a = I(n);
|
|
400
|
+
a.islandRegistry, c = a.pathToKey, l = a.keyToSrc, d = a.actionRegistry;
|
|
401
|
+
let s = t.build?.rolldownOptions?.input || {}, u = typeof s == "object" && !Array.isArray(s) ? {
|
|
402
|
+
...a.input,
|
|
403
|
+
...s
|
|
404
|
+
} : a.input;
|
|
405
|
+
return e.chunking && e.chunking.mode === "compact" && (u["l5e-compact-renderer"] = T), { build: {
|
|
406
|
+
...e.chunking && e.chunking.mode === "compact" ? { modulePreload: { resolveDependencies: (e, t, n) => n.hostType === "html" ? t.filter((e) => !/\.[cm]?js(?:\?|$)/.test(e)) : t } } : {},
|
|
407
|
+
rolldownOptions: {
|
|
408
|
+
...t.build?.rolldownOptions,
|
|
409
|
+
input: Object.keys(u).length > 0 ? u : void 0,
|
|
410
|
+
preserveEntrySignatures: i ? "allow-extension" : "exports-only",
|
|
411
|
+
...i ? { output: {
|
|
412
|
+
...r,
|
|
413
|
+
strictExecutionOrder: !0,
|
|
414
|
+
codeSplitting: { groups: o.groups() },
|
|
415
|
+
entryFileNames: (e) => {
|
|
416
|
+
let t = e.facadeModuleId?.replace(/\\/g, "/") || "";
|
|
417
|
+
return t.endsWith("/src/client.global.ts") ? "assets/global-[hash].js" : /\/react\//.test(t) ? e.name.startsWith("island-") ? "assets/[name]-[hash].js" : "assets/island-[name]-[hash].js" : "assets/bundle-[name]-[hash].js";
|
|
418
|
+
},
|
|
419
|
+
chunkFileNames: (e) => e.name.startsWith("shared-") ? "assets/[name]-[hash].js" : e.name === "shared" ? "assets/shared-[hash].js" : e.name === "lazy-react-runtime" ? "assets/lazy-react-runtime-[hash].js" : e.isDynamicEntry ? "assets/bundle-[name]-[hash].js" : "assets/shared-[name]-[hash].js"
|
|
420
|
+
} } : {}
|
|
421
|
+
}
|
|
422
|
+
} };
|
|
378
423
|
},
|
|
379
424
|
resolveId(e) {
|
|
380
|
-
return e === y ? "\0virtual:l5e-views" : e === b ? "\0virtual:l5e-route" : e === x ? "\0virtual:l5e-ssr-entry" : e === S ? "\0virtual:l5e-global-loader" : e === C ? "\0virtual:l5e-island-strategies" : e === w ? "\0virtual:l5e-islands" : e === T ? "\0virtual:l5e-
|
|
425
|
+
return e === y ? "\0virtual:l5e-views" : e === b ? "\0virtual:l5e-route" : e === x ? "\0virtual:l5e-ssr-entry" : e === S ? "\0virtual:l5e-global-loader" : e === C ? "\0virtual:l5e-island-strategies" : e === w ? "\0virtual:l5e-islands" : e === T ? "\0virtual:l5e-compact-renderer" : e === E ? "\0virtual:l5e-actions" : e === D ? "\0virtual:l5e-middleware" : null;
|
|
381
426
|
},
|
|
382
|
-
async transform(
|
|
383
|
-
if (
|
|
384
|
-
code: `import '@withl5e/l5e/island
|
|
427
|
+
async transform(t, n, i) {
|
|
428
|
+
if (n.replace(/\\/g, "/").endsWith("src/client.global.ts") && !i?.ssr) return {
|
|
429
|
+
code: `import '@withl5e/l5e/island/${e.chunking && e.chunking.mode === "compact" ? "compact-runtime" : "runtime"}';\n${t}`,
|
|
385
430
|
map: null
|
|
386
431
|
};
|
|
387
|
-
if (!
|
|
388
|
-
let
|
|
389
|
-
if (
|
|
390
|
-
let
|
|
391
|
-
for (; (a = r.exec(
|
|
392
|
-
let
|
|
432
|
+
if (!i?.ssr) {
|
|
433
|
+
let e = n.replace(/\\/g, "/").match(/\/src\/(.+)\/actions\.(ts|tsx)$/);
|
|
434
|
+
if (e) {
|
|
435
|
+
let n = e[1], r = /export\s+const\s+(\w+)\s*=\s*defineAction\s*\(/g, i = [], a;
|
|
436
|
+
for (; (a = r.exec(t)) !== null;) {
|
|
437
|
+
let e = a[1], n = t.substring(a.index, a.index + 500).match(/method:\s*['"](\w+)['"]/), r = n ? n[1].toUpperCase() : "GET";
|
|
393
438
|
i.push({
|
|
394
|
-
name:
|
|
439
|
+
name: e,
|
|
395
440
|
method: r
|
|
396
441
|
});
|
|
397
442
|
}
|
|
398
443
|
if (i.length > 0) return {
|
|
399
|
-
code: i.map(({ name: e, method:
|
|
400
|
-
let r = `${e}_${
|
|
401
|
-
return
|
|
444
|
+
code: i.map(({ name: e, method: t }) => {
|
|
445
|
+
let r = `${e}_${A(n)}`;
|
|
446
|
+
return t === "GET" ? `export async function ${e}(params) {
|
|
402
447
|
const res = await fetch('/_l5e/action/${r}?' + new URLSearchParams(params));
|
|
403
448
|
if (!res.ok) throw Object.assign(new Error('HTTP ' + res.status), { status: res.status });
|
|
404
449
|
return res;
|
|
405
450
|
}` : `export async function ${e}(body) {
|
|
406
451
|
const res = await fetch('/_l5e/action/${r}', {
|
|
407
|
-
method: '${
|
|
452
|
+
method: '${t}',
|
|
408
453
|
headers: { 'Content-Type': 'application/json' },
|
|
409
454
|
body: JSON.stringify(body),
|
|
410
455
|
});
|
|
@@ -416,28 +461,28 @@ function L(e = {}) {
|
|
|
416
461
|
};
|
|
417
462
|
}
|
|
418
463
|
}
|
|
419
|
-
if (
|
|
420
|
-
if (/\.(tsx|jsx)$/.test(
|
|
421
|
-
let
|
|
422
|
-
loader:
|
|
464
|
+
if (n.includes("node_modules") || n.includes("/react/") || n.includes("\\react\\")) return null;
|
|
465
|
+
if (/\.(tsx|jsx)$/.test(n)) try {
|
|
466
|
+
let e = `import { Fragment as __Fragment, jsxFactory } from "@withl5e/l5e/jsx-runtime"\n${t}`, i = await u(e, {
|
|
467
|
+
loader: n.endsWith(".tsx") ? "tsx" : "jsx",
|
|
423
468
|
jsx: "transform",
|
|
424
469
|
jsxFactory: "jsxFactory",
|
|
425
470
|
jsxFragment: "__Fragment",
|
|
426
471
|
sourcemap: !0,
|
|
427
|
-
sourcefile:
|
|
472
|
+
sourcefile: n,
|
|
428
473
|
target: "es2020"
|
|
429
474
|
}), a = i.code;
|
|
430
|
-
return a.includes("ClientIsland") && (a =
|
|
475
|
+
return a.includes("ClientIsland") && (a = L(a, n, r, c, l)), {
|
|
431
476
|
code: a,
|
|
432
477
|
map: i.map || null
|
|
433
478
|
};
|
|
434
479
|
} catch (e) {
|
|
435
|
-
throw console.error(`[l5e] Failed to transform JSX in ${
|
|
480
|
+
throw console.error(`[l5e] Failed to transform JSX in ${n}:`, e), e;
|
|
436
481
|
}
|
|
437
|
-
if (
|
|
438
|
-
let
|
|
439
|
-
if (
|
|
440
|
-
code:
|
|
482
|
+
if (i?.ssr) {
|
|
483
|
+
let e = t, n = !1;
|
|
484
|
+
if (e = e.replace(/import\.meta\.env\.([a-zA-Z_][a-zA-Z0-9_]*)/g, (e, t) => O.has(t) ? e : (n = !0, `process.env.${t}`)), e = e.replace(/import\.meta\.env\[(['"`])([^'"`]+)\1\]/g, (e, t, r) => O.has(r) ? e : (n = !0, `process.env[${t}${r}${t}]`)), n) return {
|
|
485
|
+
code: e,
|
|
441
486
|
map: null
|
|
442
487
|
};
|
|
443
488
|
}
|
|
@@ -455,6 +500,7 @@ export const actionRegistry = ${JSON.stringify(e)};`;
|
|
|
455
500
|
}
|
|
456
501
|
if (e === "\0virtual:l5e-middleware") return "\nconst middlewareModules = import.meta.glob([\n '/src/middleware.{ts,tsx,js,jsx}',\n '/src/middleware/index.{ts,tsx,js,jsx}',\n]);\n\nconst middlewarePaths = [\n '/src/middleware.ts',\n '/src/middleware.tsx',\n '/src/middleware.js',\n '/src/middleware.jsx',\n '/src/middleware/index.ts',\n '/src/middleware/index.tsx',\n '/src/middleware/index.js',\n '/src/middleware/index.jsx',\n];\n\nexport async function loadMiddleware() {\n const middlewarePath = middlewarePaths.find((path) => middlewareModules[path]);\n if (!middlewarePath) return undefined;\n\n const mod = await middlewareModules[middlewarePath]();\n return mod.onRequest;\n}\n";
|
|
457
502
|
if (e === "\0virtual:l5e-islands") return "export const islandModules = import.meta.glob('/src/**/react/*.{tsx,jsx}');";
|
|
503
|
+
if (e === "\0virtual:l5e-compact-renderer") return "export * as reactDomClient from 'react-dom/client'; export { createElement } from 'react';";
|
|
458
504
|
if (e === "\0virtual:l5e-island-strategies") {
|
|
459
505
|
let e = f(r, "src", "island-strategies.ts");
|
|
460
506
|
return t(e) ? "import '/src/island-strategies.ts';" : "/* no custom island strategies */";
|
|
@@ -464,6 +510,6 @@ export const actionRegistry = ${JSON.stringify(e)};`;
|
|
|
464
510
|
};
|
|
465
511
|
}
|
|
466
512
|
//#endregion
|
|
467
|
-
export {
|
|
513
|
+
export { R as t };
|
|
468
514
|
|
|
469
|
-
//# sourceMappingURL=vite-plugin-
|
|
515
|
+
//# sourceMappingURL=vite-plugin-BOuzxmb2.js.map
|