@solidjs/vite-plugin 3.0.0-next.34 → 3.0.0-next.36
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 +56 -5
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.mjs +57 -6
- package/dist/esm/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/esm/index.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import { mergeAndConcat } from 'merge-anything';
|
|
|
6
6
|
import { createRequire } from 'module';
|
|
7
7
|
import path from 'path';
|
|
8
8
|
import { Readable } from 'node:stream';
|
|
9
|
-
import { createFilter, normalizePath, loadEnv, runnerImport, defaultClientConditions, defaultServerConditions } from 'vite';
|
|
9
|
+
import { createFilter, normalizePath, loadEnv, runnerImport, defaultClientConditions, defaultServerConditions, defaultExternalConditions } from 'vite';
|
|
10
10
|
import { pathToFileURL, fileURLToPath } from 'node:url';
|
|
11
11
|
import { crawlFrameworkPkgs } from 'vitefu';
|
|
12
12
|
|
|
@@ -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
|
|
@@ -3460,6 +3497,20 @@ function solidPlugin(options = {}) {
|
|
|
3460
3497
|
// real server build resolves (isServer true).
|
|
3461
3498
|
...(isTestMode && !serverTestPosture && !opts.isSsrTargetWebworker ? ['browser'] : []), ...config.resolve.conditions];
|
|
3462
3499
|
|
|
3500
|
+
// `resolve.conditions` above only governs modules Vite inlines.
|
|
3501
|
+
// Externalized server deps are resolved by `fetchModule` with
|
|
3502
|
+
// `resolve.externalConditions` (default `['node', 'module-sync']`) and
|
|
3503
|
+
// handed to the module runner as concrete file paths — without
|
|
3504
|
+
// `development` there, packages that select their dev build through
|
|
3505
|
+
// the `development` export condition (@solidjs/web's server-functions
|
|
3506
|
+
// runtime among them) run their PRODUCTION copy under `vite dev`:
|
|
3507
|
+
// server errors reach the client sanitized to "Internal Server Error"
|
|
3508
|
+
// instead of carrying the real message, dev-only diagnostics vanish.
|
|
3509
|
+
// So the dev flag has to reach both lists.
|
|
3510
|
+
if (replaceDev && config.consumer !== 'client' && name !== 'client') {
|
|
3511
|
+
config.resolve.externalConditions = ['development', ...(config.resolve.externalConditions ?? defaultExternalConditions)];
|
|
3512
|
+
}
|
|
3513
|
+
|
|
3463
3514
|
// Set resolve.noExternal and resolve.external for the SSR environment.
|
|
3464
3515
|
// Only set resolve.external if noExternal is not true (to avoid conflicts with plugins like Cloudflare)
|
|
3465
3516
|
if (name === 'ssr' && solidPkgsConfig) {
|