create-bakery 2.0.1 → 2.0.2

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/package.json +1 -1
  2. package/src/template.ts +22 -16
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-bakery",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "Scaffold a Bakery app: bun create bakery <directory>",
5
5
  "keywords": [
6
6
  "bakery",
package/src/template.ts CHANGED
@@ -362,6 +362,11 @@ function gitignore(orm: boolean): string {
362
362
  # Disposable: the framework deletes it wholesale on every version bump and
363
363
  # dev<->prod switch.
364
364
  .cache
365
+
366
+ # Generated on every dev boot and by \`bakery --types\`. tsconfig.json references
367
+ # the first; \`tsc -b\` writes the second.
368
+ tsconfig.bakery.json
369
+ *.tsbuildinfo
365
370
  ${data}`
366
371
  }
367
372
 
@@ -436,28 +441,26 @@ ${pluginSection}
436
441
  * makes it nasty.
437
442
  *
438
443
  * `extends` still carries everything else, and is what `tsc` reads.
444
+ *
445
+ * **And it claims no files.** It reaches the app through
446
+ * `tsconfig.bakery.json`, which Bakery writes on every dev boot and on
447
+ * `bakery --types` and which lists one project per scope: server code, `api/`
448
+ * routes, browser code, and one per plugin. An editor then gives each file
449
+ * its scope, and `tsc -b` checks all of them. A root that also claimed
450
+ * `src/**` would fail `tsc -p` with TS6305 once per shared file, which is why
451
+ * there is no `include` here, and why the ORM's directories need no mention:
452
+ * the server project claims everything outside `src/`.
439
453
  */
440
- function tsconfig(orm: boolean): string {
441
- const include = [
442
- '"src/**/*.ts"',
443
- '"src/**/*.tsx"',
444
- ...(orm ? ['"orm/**/*.ts"', '"scripts/**/*.ts"'] : []),
445
- '"server.config.ts"',
446
- ]
447
- .map(entry => ` ${entry}`)
448
- .join(',\n')
449
-
454
+ function tsconfig(): string {
450
455
  return `{
451
- "$comment": "The three jsx* options are also set by @bakery-framework/core/tsconfig.server.json, and tsc reads them from there, but Bun's runtime does not follow 'extends' into a package specifier, only a relative path. Without them here, every .tsx page fails at runtime with \\"Cannot find module 'react/jsx-dev-runtime'\\" while typecheck stays clean. Keep them.",
456
+ "$comment": "Yours to edit. The three jsx* options are also set by @bakery-framework/core/tsconfig.server.json, but Bun's runtime does not follow 'extends' into a package specifier, so they are repeated for it: without them every .tsx page fails at runtime while typecheck stays clean. The app's files are reached through tsconfig.bakery.json, which Bakery generates, and claiming them here as well would break tsc.",
452
457
  "extends": "@bakery-framework/core/tsconfig.server.json",
453
458
  "compilerOptions": {
454
459
  "jsx": "react",
455
460
  "jsxFactory": "createElement",
456
461
  "jsxFragmentFactory": "Fragment"
457
462
  },
458
- "include": [
459
- ${include}
460
- ]
463
+ "references": [{ "path": "./tsconfig.bakery.json" }]
461
464
  }
462
465
  `
463
466
  }
@@ -493,7 +496,10 @@ export function templateFiles(
493
496
  scripts: {
494
497
  dev: 'bakery --dev',
495
498
  start: 'bakery',
496
- typecheck: 'tsc --noEmit',
499
+ // Generate first: a fresh clone has no tsconfig.bakery.json, and tsc
500
+ // would stop at TS6053. `-b`, because the root claims no files and
501
+ // `tsc -p` on it checks nothing while reporting success.
502
+ typecheck: 'bakery --types && tsc -b',
497
503
  ...(orm
498
504
  ? {
499
505
  'db:sync': 'bun run scripts/db-sync.ts',
@@ -539,7 +545,7 @@ export function templateFiles(
539
545
 
540
546
  const files: TemplateFile[] = [
541
547
  { path: 'package.json', contents: `${JSON.stringify(pkg, null, 2)}\n` },
542
- { path: 'tsconfig.json', contents: tsconfig(orm) },
548
+ { path: 'tsconfig.json', contents: tsconfig() },
543
549
  { path: '.gitignore', contents: gitignore(orm) },
544
550
  { path: 'README.md', contents: readme(name, orm, plugins) },
545
551
  { path: 'server.config.ts', contents: serverConfig(plugins) },