@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/cjs/index.cjs
CHANGED
|
@@ -677,6 +677,16 @@ function solidDiagnostics() {
|
|
|
677
677
|
}];
|
|
678
678
|
},
|
|
679
679
|
configureServer(server) {
|
|
680
|
+
// Announce the surface in the startup block. This is a discovery
|
|
681
|
+
// channel: agents watching dev-server output learn the endpoint and
|
|
682
|
+
// the skill documents without any project-level pointer (AGENTS.md).
|
|
683
|
+
const originalPrintUrls = server.printUrls.bind(server);
|
|
684
|
+
server.printUrls = () => {
|
|
685
|
+
originalPrintUrls();
|
|
686
|
+
const local = server.resolvedUrls?.local[0];
|
|
687
|
+
const endpoint = local ? new URL(DIAGNOSTICS_ENDPOINT, local).href : DIAGNOSTICS_ENDPOINT;
|
|
688
|
+
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`);
|
|
689
|
+
};
|
|
680
690
|
const pending = new Map();
|
|
681
691
|
let nextId = 1;
|
|
682
692
|
server.ws.on(RESPONSE_EVENT, data => {
|
|
@@ -1233,24 +1243,47 @@ function serverFunctions(options = {}, internal = {}) {
|
|
|
1233
1243
|
if (internal.externalDevServer || !isRunnableEnvironment(ssrEnvironment)) {
|
|
1234
1244
|
return;
|
|
1235
1245
|
}
|
|
1246
|
+
// A call's address is `<endpoint>/<id>` (solidjs/solid#3076) — the
|
|
1247
|
+
// mount plus exactly one path segment. Bare-mount requests still
|
|
1248
|
+
// reach the runtime handler (it answers 404), so misdirected posts
|
|
1249
|
+
// fail through the endpoint rather than falling through to SSR.
|
|
1250
|
+
const underMount = (pathname, mount) => pathname === mount || pathname.startsWith(mount + '/');
|
|
1236
1251
|
server.middlewares.use((req, res, next) => {
|
|
1237
1252
|
const url = new URL(req.url || '/', 'http://localhost');
|
|
1238
1253
|
// Match with and without `base` — middleware-mode hosts may mount
|
|
1239
1254
|
// vite.middlewares below the base themselves.
|
|
1240
|
-
if (url.pathname
|
|
1255
|
+
if (!underMount(url.pathname, resolvedEndpoint) && !underMount(url.pathname, endpoint)) {
|
|
1241
1256
|
return next();
|
|
1242
1257
|
}
|
|
1258
|
+
const basePrefixed = underMount(url.pathname, resolvedEndpoint);
|
|
1243
1259
|
// When the stripped form matched, restore the base for dispatch:
|
|
1244
1260
|
// the generated handler compares the request pathname against the
|
|
1245
1261
|
// base-prefixed endpoint, and production handlers only ever see
|
|
1246
1262
|
// base-prefixed URLs.
|
|
1247
|
-
const dispatchUrl =
|
|
1263
|
+
const dispatchUrl = basePrefixed ? undefined : joinBase(base, req.url || '/');
|
|
1248
1264
|
(async () => {
|
|
1249
1265
|
// Make sure the referenced module has been evaluated in the SSR
|
|
1250
1266
|
// environment so its registration exists — functions only client
|
|
1251
1267
|
// code references are never loaded by the SSR render itself.
|
|
1252
|
-
|
|
1253
|
-
const
|
|
1268
|
+
// The id lives in the path segment after the mount.
|
|
1269
|
+
const mount = basePrefixed ? resolvedEndpoint : endpoint;
|
|
1270
|
+
const segment = url.pathname.slice(mount.length + 1);
|
|
1271
|
+
let functionId = null;
|
|
1272
|
+
if (segment && !segment.includes('/')) {
|
|
1273
|
+
try {
|
|
1274
|
+
functionId = decodeURIComponent(segment);
|
|
1275
|
+
} catch {
|
|
1276
|
+
// not an address; the runtime handler answers the 404
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1279
|
+
if (!functionId) {
|
|
1280
|
+
// TRANSITIONAL (remove before 3.0 stable): the retired header
|
|
1281
|
+
// and `?id=` addressing, kept only for the RC window where this
|
|
1282
|
+
// plugin meets a @solidjs/web older than the path-addressing
|
|
1283
|
+
// change (solidjs/solid#3076).
|
|
1284
|
+
const headerId = req.headers['x-server-function-id'];
|
|
1285
|
+
functionId = (typeof headerId === 'string' ? headerId.split('#')[0] : undefined) || url.searchParams.get('id');
|
|
1286
|
+
}
|
|
1254
1287
|
if (functionId) {
|
|
1255
1288
|
const entry = moduleForFunctionId(functionId);
|
|
1256
1289
|
if (entry) await ssrEnvironment.runner.import(moduleDevUrl(entry));
|
|
@@ -1888,7 +1921,11 @@ function startServe(options, internal = {}) {
|
|
|
1888
1921
|
// through untouched, so the edge applies it unconditionally.
|
|
1889
1922
|
lines.push(``, `async function dispatchRequest(request, event, options) {`);
|
|
1890
1923
|
if (composeServerFunctions) {
|
|
1891
|
-
lines.push(
|
|
1924
|
+
lines.push(
|
|
1925
|
+
// A call's address is `<endpoint>/<id>` (solidjs/solid#3076); the
|
|
1926
|
+
// bare mount still routes so a misaddressed request 404s through the
|
|
1927
|
+
// runtime handler instead of rendering a page at it.
|
|
1928
|
+
` const requestPath = new URL(request.url).pathname;`, ` if (requestPath === endpoint || requestPath.startsWith(endpoint + '/')) {`,
|
|
1892
1929
|
// The call shares the middleware chain's event (locals decoration,
|
|
1893
1930
|
// the response stub); an explicit host-provided createEvent wins.
|
|
1894
1931
|
// No fold here: the runtime's server-function handler runs the
|