Conversation
@solidjs/vite-plugin 3.0.0-next.44 adds `start.node` (solidjs/solid-vite-plugin#366): with `start: { node: true }` the ssr build emits a ready-to-run Node entry at dist/server/node.js. The templates adopted it and deleted the hand-written solid-v2/fullstack/server.js (solidjs/templates#304), so the CLI's --ssr flip must stop baking a copy of that file into scaffolds. - ssr-flip.ts: rewrite the `solid({ start: true` anchor to `solid({ start: { node: true }, ssr: true` (anchor + hint comment are preserved by templates#304, so detection is unchanged); SSR_START_SCRIPT is now `node --env-file-if-exists=.env dist/server/node.js`; drop SERVER_JS, the @generated-server-js markers and the server.js write. - Delete scripts/gen-ssr-flip-server.mjs (nothing left to embed). - tests: assert the new config text / start script and that the flip touches only vite.config.ts + package.json; solid-v2-basic fixture mirrors templates#304's basic (rc.9 / next.44 / next.26 pins, diagnostics: true). - changeset (minor). retargetTSFilenames / the --js conversion are unaffected: the config edit still happens on the .ts source and dist/server/node.js is a build artifact.
…: { node: true })
…e, start: { node: true })"
This reverts commit 225cb51.
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.
Follow-up to solidjs/templates#304 (rc.9 /
@solidjs/vite-pluginnext.44 repin) and solidjs/solid-vite-plugin#366 (start.node).@solidjs/vite-plugin3.0.0-next.44 addsstart.node: withstart: { node: true }the ssr build emits a ready-to-run Node entry atdist/server/node.js(staticdist/clientwith immutable/must-revalidate cache headers,PORT/HOST, everything else throughhandleRequestwithnativeEvent). The templates adopted it and deletedsolid-v2/fullstack/server.js, which the CLI's--ssrflip was baking byte-for-byte into every flipped scaffold (SERVER_JS, kept in sync byscripts/gen-ssr-flip-server.mjs). This PR is the CLI side of the spec in templates#304's body.Changes
packages/create/src/utils/ssr-flip.tssolid({ start: true→solid({ start: { node: true }, ssr: true(SSR_ANCHOR_REPLACEMENT); the hint comment is still stripped. templates#304 preserves both the anchor and the// add \ssr: true` for streaming SSR` hint in every client-mode config, so detection is unchanged.SSR_START_SCRIPT=node --env-file-if-exists=.env dist/server/node.js(--env-file-if-existsstays: the emitted entry does not read.envitself).SERVER_JS, the@generated-server-js-*markers and theserver.jswrite — the flip now touches exactlyvite.config.ts+package.json.scripts/gen-ssr-flip-server.mjs.create-solid-v2.ts: comment only.retargetTSFilenames/ the--jsconversion need no change (the config edit still happens on the.tssource;dist/server/node.jsis a build artifact, not a source file to convert). There was no server.js copy step to remove — it was written byapplySsrFlipinside the temp dir and copied by the generic conversion walk.tests/ssr-flip.test.ts: asserts the new config text and start script, that the flip leaves onlypackage.json+vite.config.tsin the dir (noserver.js), and the abort path still writes nothing. Thesolid-v2-basicfixture now mirrors templates#304'sbasic(vite.config.tsincl.diagnostics: true/fileRoutes({ types: true }), rc.9 / next.44 / next.26 pins).minorforcreate-solid+@solid-cli/create), matching the repo's changesets flow.utils/manifest.ts/constants.ts): checked, nothing referencesserver.js. Templates copied whole (fullstack,fullstack-tanstack) need nothing — the file is simply no longer in the tree.Verification
pnpm build && pnpm test: 58/58 tests, 11/11 files (suite grew from 54 onmainwith the devtools/tsOnly work; all green).basic(ref65899ca). The CLI has no ref override any more (0.10.0 removedSOLID_CLI_TEMPLATES_REF; it tracks templates HEAD), so I drove the realcreateSolidV2(..., ssr = true)code path withdownloadTemplateswapped for a local copy of the PR branch'ssolid-v2/basic:--ssr:vite.config.ts→solid({ start: { node: true }, ssr: true, extensions: ['.jsx', '.tsx'], diagnostics: true }), hint comment gone, noserver.js,start=node --env-file-if-exists=.env dist/server/node.js.npm installresolves@solidjs/vite-plugin@3.0.0-next.44/solid-js@2.0.0-rc.9;npm run buildemitsdist/server/node.js(7.14 kB) +dist/server/server.js;npm start→Listening on http://localhost:<PORT>;GET /200text/htmlwith the SSR'd shell + hydration script; hashed/assets/web-*.js200Cache-Control: public, max-age=31536000, immutable;/favicon.ico200must-revalidate+Last-Modified;/users/1200 with SSR'd<h2>Ada Lovelace</h2>; unknown route 404;/../package.json404.--js+--ssron the same template:.projecttemp dir cleaned,vite.config.js→solid({ start: { node: true }, ssr: true, extensions: ['.jsx'], diagnostics: true }),setupFiles: ['./vitest-setup.js'], noserver.js; build emitsdist/server/node.js;npm startservesGET /200 and/users/2→<h2>Grace Hopper</h2>.Merge order: after templates#304
The flip itself is order-independent: it only rewrites
vite.config.ts+package.json, and thesolid({ start: trueanchor is identical on templatesmainand on #304, so it applies cleanly against either. What is not order-independent is the runtime of the flipped scaffold: templatesmainpins@solidjs/vite-plugin^3.0.0-next.38and ships apnpm-lock.yamlresolvingnext.38, which predatesstart.node. Verified against a flipped copy ofmain'sbasic: withpnpm install --frozen-lockfile→next.38,start: { node: true }is silently ignored, nodist/server/node.jsis emitted andnpm startfails withMODULE_NOT_FOUND; withnpm install(no lockfile) the caret resolves tonext.44and it works. So merging this first would break--ssrscaffolds for pnpm users until #304 lands (and the CLI tracks templates HEAD, so there is no window where the old bakedserver.jsis needed after #304 merges). Merge #304 first, then this.Not for merging by the author — please review.