@solidjs/vite-plugin 3.0.0-next.34 → 3.0.0-next.35
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/cjs/index.cjs +42 -5
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.mjs +42 -5
- package/dist/esm/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/esm/index.mjs
CHANGED
|
@@ -653,6 +653,16 @@ function solidDiagnostics() {
|
|
|
653
653
|
}];
|
|
654
654
|
},
|
|
655
655
|
configureServer(server) {
|
|
656
|
+
// Announce the surface in the startup block. This is a discovery
|
|
657
|
+
// channel: agents watching dev-server output learn the endpoint and
|
|
658
|
+
// the skill documents without any project-level pointer (AGENTS.md).
|
|
659
|
+
const originalPrintUrls = server.printUrls.bind(server);
|
|
660
|
+
server.printUrls = () => {
|
|
661
|
+
originalPrintUrls();
|
|
662
|
+
const local = server.resolvedUrls?.local[0];
|
|
663
|
+
const endpoint = local ? new URL(DIAGNOSTICS_ENDPOINT, local).href : DIAGNOSTICS_ENDPOINT;
|
|
664
|
+
server.config.logger.info(` ➜ Solid diagnostics: ${endpoint} ` + `(GET status; POST {"method":"begin"|"end"|"whyDidRun"|"costs"})\n` + ` ➜ Agent skills: node_modules/${DIAGNOSTICS_PACKAGE}/skills/agent-loops/SKILL.md, ` + `node_modules/solid-js/skills/reactivity-diagnostics/SKILL.md`);
|
|
665
|
+
};
|
|
656
666
|
const pending = new Map();
|
|
657
667
|
let nextId = 1;
|
|
658
668
|
server.ws.on(RESPONSE_EVENT, data => {
|
|
@@ -1209,24 +1219,47 @@ function serverFunctions(options = {}, internal = {}) {
|
|
|
1209
1219
|
if (internal.externalDevServer || !isRunnableEnvironment(ssrEnvironment)) {
|
|
1210
1220
|
return;
|
|
1211
1221
|
}
|
|
1222
|
+
// A call's address is `<endpoint>/<id>` (solidjs/solid#3076) — the
|
|
1223
|
+
// mount plus exactly one path segment. Bare-mount requests still
|
|
1224
|
+
// reach the runtime handler (it answers 404), so misdirected posts
|
|
1225
|
+
// fail through the endpoint rather than falling through to SSR.
|
|
1226
|
+
const underMount = (pathname, mount) => pathname === mount || pathname.startsWith(mount + '/');
|
|
1212
1227
|
server.middlewares.use((req, res, next) => {
|
|
1213
1228
|
const url = new URL(req.url || '/', 'http://localhost');
|
|
1214
1229
|
// Match with and without `base` — middleware-mode hosts may mount
|
|
1215
1230
|
// vite.middlewares below the base themselves.
|
|
1216
|
-
if (url.pathname
|
|
1231
|
+
if (!underMount(url.pathname, resolvedEndpoint) && !underMount(url.pathname, endpoint)) {
|
|
1217
1232
|
return next();
|
|
1218
1233
|
}
|
|
1234
|
+
const basePrefixed = underMount(url.pathname, resolvedEndpoint);
|
|
1219
1235
|
// When the stripped form matched, restore the base for dispatch:
|
|
1220
1236
|
// the generated handler compares the request pathname against the
|
|
1221
1237
|
// base-prefixed endpoint, and production handlers only ever see
|
|
1222
1238
|
// base-prefixed URLs.
|
|
1223
|
-
const dispatchUrl =
|
|
1239
|
+
const dispatchUrl = basePrefixed ? undefined : joinBase(base, req.url || '/');
|
|
1224
1240
|
(async () => {
|
|
1225
1241
|
// Make sure the referenced module has been evaluated in the SSR
|
|
1226
1242
|
// environment so its registration exists — functions only client
|
|
1227
1243
|
// code references are never loaded by the SSR render itself.
|
|
1228
|
-
|
|
1229
|
-
const
|
|
1244
|
+
// The id lives in the path segment after the mount.
|
|
1245
|
+
const mount = basePrefixed ? resolvedEndpoint : endpoint;
|
|
1246
|
+
const segment = url.pathname.slice(mount.length + 1);
|
|
1247
|
+
let functionId = null;
|
|
1248
|
+
if (segment && !segment.includes('/')) {
|
|
1249
|
+
try {
|
|
1250
|
+
functionId = decodeURIComponent(segment);
|
|
1251
|
+
} catch {
|
|
1252
|
+
// not an address; the runtime handler answers the 404
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
if (!functionId) {
|
|
1256
|
+
// TRANSITIONAL (remove before 3.0 stable): the retired header
|
|
1257
|
+
// and `?id=` addressing, kept only for the RC window where this
|
|
1258
|
+
// plugin meets a @solidjs/web older than the path-addressing
|
|
1259
|
+
// change (solidjs/solid#3076).
|
|
1260
|
+
const headerId = req.headers['x-server-function-id'];
|
|
1261
|
+
functionId = (typeof headerId === 'string' ? headerId.split('#')[0] : undefined) || url.searchParams.get('id');
|
|
1262
|
+
}
|
|
1230
1263
|
if (functionId) {
|
|
1231
1264
|
const entry = moduleForFunctionId(functionId);
|
|
1232
1265
|
if (entry) await ssrEnvironment.runner.import(moduleDevUrl(entry));
|
|
@@ -1864,7 +1897,11 @@ function startServe(options, internal = {}) {
|
|
|
1864
1897
|
// through untouched, so the edge applies it unconditionally.
|
|
1865
1898
|
lines.push(``, `async function dispatchRequest(request, event, options) {`);
|
|
1866
1899
|
if (composeServerFunctions) {
|
|
1867
|
-
lines.push(
|
|
1900
|
+
lines.push(
|
|
1901
|
+
// A call's address is `<endpoint>/<id>` (solidjs/solid#3076); the
|
|
1902
|
+
// bare mount still routes so a misaddressed request 404s through the
|
|
1903
|
+
// runtime handler instead of rendering a page at it.
|
|
1904
|
+
` const requestPath = new URL(request.url).pathname;`, ` if (requestPath === endpoint || requestPath.startsWith(endpoint + '/')) {`,
|
|
1868
1905
|
// The call shares the middleware chain's event (locals decoration,
|
|
1869
1906
|
// the response stub); an explicit host-provided createEvent wins.
|
|
1870
1907
|
// No fold here: the runtime's server-function handler runs the
|