create-rsc-kit 0.7.2 → 0.8.0

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.
Files changed (2) hide show
  1. package/dist/templates.js +53 -11
  2. package/package.json +1 -1
package/dist/templates.js CHANGED
@@ -63,16 +63,34 @@ export function scripts(o) {
63
63
  return {
64
64
  dev: 'vite',
65
65
  build: 'vite build',
66
+ // The two that produce something you ship build first, rather than reading
67
+ // whatever .output happens to hold. Run on a project that has never been
68
+ // built, they failed with `ENOENT opening root directory ".output/server"`
69
+ // — a path the app did not write and has no reason to recognise. Run on one
70
+ // built a while ago, which is worse, they silently packaged the old code.
71
+ //
72
+ // start and preview are left alone: they are the inner loop, they follow a
73
+ // build in every set of instructions, and re-running one on each restart
74
+ // costs more than it saves.
66
75
  ...(o.host === 'worker'
67
- ? { preview: 'wrangler dev .output/server/index.mjs', deploy: 'nitro deploy --prebuilt' }
76
+ ? {
77
+ preview: 'wrangler dev .output/server/index.mjs',
78
+ deploy: 'vite build && nitro deploy --prebuilt',
79
+ }
68
80
  : {
69
81
  start: `${o.host === 'node' ? 'node' : 'bun'} .output/server/index.mjs`,
70
82
  // Bun only, and only because serveStatic: 'inline' is set in the vite
71
83
  // config. Without that the binary compiles, serves pages, and 404s
72
84
  // every asset — the static path resolves into Bun's virtual
73
85
  // filesystem, where the files on disk are not.
86
+ //
87
+ // Into dist/, which is already ignored. Named after the project it
88
+ // landed a 63MB binary in the root of, next to the source, with
89
+ // nothing in .gitignore covering it.
74
90
  ...(o.host === 'bun'
75
- ? { compile: `bun build --compile .output/server/index.mjs --outfile ${o.name}` }
91
+ ? {
92
+ compile: 'vite build && bun build --compile .output/server/index.mjs --outfile dist/app',
93
+ }
76
94
  : {}),
77
95
  }),
78
96
  typecheck: 'tsc --noEmit',
@@ -260,23 +278,39 @@ export default function RootLayout({ children }: { children: ReactNode }) {
260
278
  export function page(o) {
261
279
  const h1 = o.tailwind ? ' className="text-3xl font-bold"' : '';
262
280
  const p = o.tailwind ? ' className="mt-4 text-slate-600"' : '';
281
+ const code = o.tailwind ? ' className="rounded bg-slate-100 px-1"' : '';
282
+ // Deliberately nothing that changes between renders.
283
+ //
284
+ // This page said "Rendered on the server at {new Date()}" — and every route
285
+ // it can is frozen at build time, so that timestamp was the build's and
286
+ // never moved again. Reload and the same instant is still there, under a
287
+ // sentence claiming it was rendered just now. The first thing the starter
288
+ // did was look broken, and the fix someone reaches for is to stop
289
+ // prerendering the page that is teaching them about prerendering.
263
290
  return `import { Counter } from '../components/Counter'
264
291
 
265
292
  export const metadata = { title: 'Home' }
266
293
 
267
- // A server component: async, runs only on the server, ships no JavaScript.
268
- export default async function HomePage() {
269
- const now = new Date().toISOString()
270
-
294
+ // A server component. It runs on the server and ships no JavaScript of its
295
+ // own — this file is not in the browser bundle. It can be \`async\` and await
296
+ // whatever it needs; nothing here does yet.
297
+ export default function HomePage() {
271
298
  return (
272
299
  <>
273
300
  <h1${h1}>${o.name}</h1>
274
301
  <p${p}>
275
- Rendered on the server at {now}. The only JavaScript on this page is the
276
- counter below.
302
+ The only JavaScript on this page is the counter below, because
303
+ <code${code}>Counter.tsx</code> is the only file that opts into the
304
+ client. Everything else rendered on the server and stayed there.
277
305
  </p>
278
306
 
279
307
  <Counter />
308
+
309
+ <p${p}>
310
+ Edit <code${code}>src/app/page.tsx</code> and the change arrives without
311
+ a reload. Add <code${code}>src/app/about/page.tsx</code> and{' '}
312
+ <code${code}>/about</code> exists — there is no route table to update.
313
+ </p>
280
314
  </>
281
315
  )
282
316
  }
@@ -384,9 +418,17 @@ export function readme(o) {
384
418
  ? `${pm} preview # wrangler dev, on workerd\n${pm} deploy # nitro deploy --prebuilt`
385
419
  : `${pm} start # serve on http://localhost:${PORT}`;
386
420
  const compile = o.host === 'bun'
387
- ? `\n\n\`${pm} compile\` puts the whole application in one file — engine, pages and
388
- assets — with Bun's runtime inside it. Frozen pages stay outside: a binary
389
- has no filesystem to read them from, so it renders those live.`
421
+ ? `\n\n\`${pm} compile\` builds and then puts the whole application into
422
+ \`dist/app\` — engine, pages and assets, with Bun's runtime inside it. Run it
423
+ directly:
424
+
425
+ \`\`\`sh
426
+ ./dist/app
427
+ \`\`\`
428
+
429
+ It builds first, so the binary is never a version behind your source. Frozen
430
+ pages stay outside it: a binary has no filesystem to read them from, so it
431
+ renders those live.`
390
432
  : '';
391
433
  return `# ${o.name}
392
434
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-rsc-kit",
3
- "version": "0.7.2",
3
+ "version": "0.8.0",
4
4
  "type": "module",
5
5
  "description": "Scaffold an RSC app on Bun, Hono, Elysia or Node.",
6
6
  "bin": {