docs: Node deployment via start.node emitted entry - #1638
Merged
Merged
Conversation
Document the @solidjs/vite-plugin start.node option: vite build emits dist/server/node.js, a complete Node server (static dist/client first, then handleRequest with event.nativeEvent), so the Node bridge no longer lives in a hand-maintained server.js in each project. - Deployment: rewrite the Node section around start.node and node dist/server/node.js (PORT/HOST, the start script, what the emitted entry does), add 'Your own Node server' for the listener export and a hand-written bridge, re-attribute the Set-Cookie caution and the nativeEvent tip, add a Common problems entry for a missing node.js, update the intro and Recap. - StartOptions reference: add node to the type and options, and to the build outputs and server-functions notes. - Project shapes, Migrate from SolidStart: replace the template-provided server.js statements. Co-authored-by: Cursor <cursoragent@cursor.com>
|
|
✅ Deploy Preview for solid-docs-v2 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
…cipes
- Cache-Control for non-hashed files is public, max-age=0, must-revalidate;
hashed files are those under build.assetsDir.
- Dot-segment paths (.vite/manifest.json) are refused, as in vite preview.
- Exports are listener, createListener({ static?, event? }), and
serve({ port?, host?, static?, event? }) returning the http.Server;
the reference lists the signatures.
- Warnings: start.external, and client mode without serverFunctions;
emission is ssr-environment only and requires server.js in the bundle.
- Deployment: Express recipes (compression + listener; express.static +
createListener({ static: false })), the plain-HTTP/proxy stance, and the
hand-written handleRequest bridge demoted to a last resort.
Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Documents the new
@solidjs/vite-pluginoptionstart.node(solidjs/solid-vite-plugin#366): withstart: { node: true },vite buildemitsdist/server/node.jsnext todist/server/server.js, a complete Node server (staticdist/clientfirst, thenhandleRequest(request, { event: { nativeEvent: req } }),PORT/HOSTfrom the environment,listener/createListener/serveexports).server.js,handleRequest, and the default{ fetch }export are unchanged.Changes per page
(3)building-apps/(7)deployment.mdxdist/server/node.js" rather than the template'sserver.js.Preferversion; the Set-Cookie caution is attributed to the emitted entry.## Noderewritten: enablestart.node(config block),pnpm build+node dist/server/node.js,PORT/HOST, the templates' start script, a bullet list of what the emitted entry does (static first with the cache headers, dot-segment and..refusal; bridge behaviors; client-mode history fallback and endpoint routing; plain HTTP, compress/TLS at the proxy). The nativeEvent tip is kept and attributed to the emitted entry.### Your own Node server: thelistener/createListener(options)/serve(options)exports;http.createServer(listener); two Express recipes matching the plugin README (compression()+listener;express.static+createListener({ static: false })); one sentence each onstatic: false(also drops the client-mode history fallback) andevent; the hand-writtenhandleRequestbridge demoted to a last resort with a pointer to the requirements.startfor the emitted Node server".Cannot find module 'dist/server/node.js'entry (option not set); the existingserver.jsentry is kept and cross-referenced; the Set-Cookie entry is re-attributed.start.nodeand runnode dist/server/node.js...".reference/(5)vite-plugin-solid/(2)start.mdx:node?: booleanadded to theStartOptionstype; new### nodeoption in the page's format with the emitted module's exports as atssignature block;dist/server/node.jsadded to the SSR start mode build outputs and the server-functions/client-mode note.(1)getting-started/(1)project-shapes.mdx: "The template'sserver.jsis the Node version of that" replaced with thestart: { node: true }/dist/server/node.jsstatement.(6)migration/(2)from-solid-start.mdx: "The pinned templates include a verified Node adapter" replaced with thestart.nodeinstruction.Not changed (audited, still true):
app-structure,rendering-and-ssr,choose-a-rendering-mode,modulesonly say "a request handler indist/server"; thedist/server/server.js-as-handler statements everywhere stay as they are.Verified against solidjs/solid-vite-plugin#366 (
ab03656)Checked against
src/node-entry/index.ts,src/ssr/index.ts,src/http.ts, theStartOptions.nodedocblock, the README Node section,.changeset/start-node-entry.md, and thenodemode ofexamples/start-ssr/test/run.mjsandexamples/start-client/test/run.mjs.Confirmed as written:
PORTdefault3000andHOST; listens only when run directly (path.resolve(process.argv[1]) === import.meta.filename), importing does not listen;listeneriscreateListener()and includes static serving;/assets/*(build.assetsDir)Cache-Control: public, max-age=31536000, immutable;..cannot escape the client directory;HEADanswered without a body; bridge streams non-GET/HEADbodies, splitsset-cookie, aborts on client disconnect, applies backpressure;getRequestEvent().nativeEventis theIncomingMessage; client start mode withserverFunctionsgetsindex.htmlhistory fallback for HTML-acceptingGETs plus the endpoint;server.jsbyte-identical with and without the option.Corrected:
must-revalidate+Last-Modified→public, max-age=0, must-revalidate+Last-Modified..vite/manifest.json) are never served, matchingvite preview.listenerandserve()→listener,createListener({ static?, event? }),serve({ port?, host?, static?, event? })returning thehttp.Server; the reference now lists the signatures.nodewhen the build writes no server bundle" → warns and emits nothing withstart.externaland in client mode withoutserverFunctions; emission isssr-environment only and requiresserver.jsin the bundle. (There is no separate "start off" warning in the code;nodelives insidestart.)console.errorand answer500; the entry speaks plain HTTP, so TLS and compression belong at the proxy/CDN or in Express.baseprefixes the static paths.Depends on
start.node.start: { node: true }and use"start": "node --env-file-if-exists=.env dist/server/node.js". The templates still shipserver.jsuntil that lands.Un-draft when both are in.
Checks
pnpm check:lint,pnpm check:types,pnpm lint:tone,prettier --checkon the touched files, andpnpm buildpass.pnpm check:exampleswas not run: it type-checkstsblocks against a sibling plugin checkout, andstart: { node: true }will not type-check until the plugin ships the option.