serverFunctions.components (dev): server-functions client is duplicated when @solidjs/web is in optimizeDeps.exclude, so post-boot server components resolve to undefined
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 58/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- typescript, vite
- Bereich
- build-system, devtools
Rechercherichtung
Start with the command === 'serve' && serverComponents dependency entry in src/index.ts, then trace how @solidjs/web/frames and compiled function references resolve their server-functions client imports when @solidjs/web is excluded from optimizeDeps. Reproduce using the supplied Vite config and click sequence; the issue is done when the dynamically mounted panel renders with the exclusion enabled and the existing no-exclusion and build-preview behavior still works.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Versions: [email protected], @solidjs/[email protected], @solidjs/[email protected], [email protected] (first seen on rc.10 / next.46).
Repro
// vite.config.ts
export default defineConfig({
optimizeDeps: { exclude: ['@solidjs/web'] },
plugins: [solid({ ssr: true, start: { app: 'src/App.tsx' }, serverFunctions: { components: true } })],
})
// src/server.tsx
'use server'
export async function getPanel() {
return () => <section id="panel">server panel</section>
}
// src/App.tsx
export default function App() {
const [page, setPage] = createSignal('a')
const Panel = dynamic(() => getPanel())
return (
<>
<button id="go-b" onClick={() => setPage('b')}>go b</button>
{page() === 'a' ? <p id="page-a">page a</p> : <Loading><Panel /></Loading>}
</>
)
}
Run vite dev, load /, then click #go-b. The boundary is not in the document, so it mounts after boot.
Expected: the panel mounts, as it does without the exclude.
Actual: POST /_server/data/getPanel-… returns 200 application/x-frame-stream with the right chunks, but the call resolves to undefined and nothing mounts. A document-SSR'd (adopted) boundary still works, and vite build + vite preview work too.
Cause
With serverComponents, the plugin force-includes @solidjs/web/frames and @solidjs/web/server-functions (src/index.ts, the command === 'serve' && serverComponents entry) so that both share one instance of the transport config module. But @solidjs/web/frames imports @solidjs/web/server-functions/client. When the app excludes @solidjs/web, that subpath is neither included nor resolved to the optimized module:
node_modules/.vite/deps/@solidjs_web_frames.js→import … from "@solidjs/web/server-functions/client", which loads the raw node_modules file.- Compiled function references →
@solidjs/web/server-functions, which loads@solidjs_web_server-functions.js.
That gives two instances of the server-functions client. installServerComponents() calls configureServerFunctionsClient({ responseHandler }) on one of them, while the references call the other, which has no handler. The frame-stream response is therefore decoded as plain data.
Without the exclude, the frames bundle imports ./@solidjs_web_server-functions.js and everything shares one instance. Excluding @solidjs/web is common in apps that pin or link Solid.
Workaround
optimizeDeps: { exclude: ['@solidjs/web'], include: ['@solidjs/web/server-functions/client'] }
Suggested fix
When command === 'serve' && serverComponents, also force-include @solidjs/web/server-functions/client. Alternatively, have frames import the same specifier the references use.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 522
- Forks
- 73
- Ø Merge
- 1 T. 8 Std.
- Gemergte PRs (30 T.)
- 31
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus solidjs/solid-vite-plugin
-
Vitest config is dropped when test.server.deps.external already lists solid-jsEvtl. vergeben @RaphaelFakhri hat das vor 2 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
solidjs/solid-vite-plugin#454 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Test environment detection doesn't consider Vitest workspacesEvtl. vergeben @carloitaben hat das vor 60 Tagen übernommen. Offen1.x
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
solidjs/solid-vite-plugin#205 · 1 Kommentar · 2 Reaktionen ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 56/100
solidjs/solid-vite-plugin#456 · 3 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 58/100
solidjs/solid-vite-plugin#427 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Dev: a stylesheet shared by the entry and a lazy component moves after the lazy component's stylesOffen
Schwierigkeit 3/5 Ein halber Tag Anfängerfreundlichkeit 62/100
solidjs/solid-vite-plugin#425 ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in solidjs/solid-vite-plugin
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 83/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 72/100
zts212653/clowder-ai#1678 ·
Maintainer antworten meist innerhalb von 1 Tag
-
good first issue
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 64/100
Progressive-Victory/the-website#680 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100