|
73 | 73 | * `private`, and the project lands in the |
74 | 74 | * developer's own directory. |
75 | 75 | * `in-repo` (--in-repo) the platform-work shape: `workspace:*` deps, a |
76 | | - * `tsconfig.json` that extends this repo's root |
77 | | - * config, a publishable `@objectstack/plugin-<name>` |
78 | | - * landing under `packages/plugins/`. Explicit and |
| 76 | + * `tsconfig.json` that extends this repo's shared |
| 77 | + * `tsconfig.base.json`, a publishable |
| 78 | + * `@objectstack/plugin-<name>` landing under |
| 79 | + * `packages/plugins/`. Explicit and |
79 | 80 | * documented, never the default — its output |
80 | 81 | * installs nowhere else. |
81 | 82 | * |
@@ -168,15 +169,21 @@ export function objectstackDependencySpec(placement: ScaffoldPlacement): string |
168 | 169 | } |
169 | 170 |
|
170 | 171 | /** |
171 | | - * The `extends` an in-repo scaffold needs to reach this repo's root |
172 | | - * `tsconfig.json`, DERIVED from where the template lands rather than written |
173 | | - * down. Writing it down is how the `plugin` template came to declare |
174 | | - * `'../../tsconfig.json'` from a directory two levels below `packages/`, which |
175 | | - * resolves to a file that does not exist. |
| 172 | + * The `extends` an in-repo scaffold needs to reach this repo's shared |
| 173 | + * `tsconfig.base.json` — the file every package here extends — DERIVED from |
| 174 | + * where the template lands rather than written down. Writing it down is how the |
| 175 | + * `plugin` template came to declare `'../../tsconfig.json'` from a directory two |
| 176 | + * levels below `packages/`, which resolves to a file that does not exist. |
| 177 | + * |
| 178 | + * ⛔ Never the root `tsconfig.json`: that is the type-check program for |
| 179 | + * `scripts/` and the top-level configs, and its `exclude` (`packages`, `apps`, |
| 180 | + * `examples`, `ui`) resolves against the root, so a scaffold that inherited it |
| 181 | + * matched none of its own `src/` — `tsc` stopped with TS18003, "No inputs were |
| 182 | + * found". |
176 | 183 | */ |
177 | | -export function rootTsconfigExtends(inRepoDir: string, projectDirName: string): string { |
| 184 | +export function baseTsconfigExtends(inRepoDir: string, projectDirName: string): string { |
178 | 185 | const depth = path.posix.join(inRepoDir, projectDirName).split('/').filter(Boolean).length; |
179 | | - return `${'../'.repeat(depth)}tsconfig.json`; |
| 186 | + return `${'../'.repeat(depth)}tsconfig.base.json`; |
180 | 187 | } |
181 | 188 |
|
182 | 189 | /** A rendered file: JSON objects are stringified on write, strings land as-is. */ |
@@ -387,7 +394,7 @@ export const templates: Record<string, CreateTemplate> = { |
387 | 394 | // `tsc` emits ES modules under the compiler options below, so the |
388 | 395 | // manifest has to declare the project as ESM or Node refuses the |
389 | 396 | // emitted `dist/index.js`. The in-repo placement inherits its module |
390 | | - // semantics from the root config it extends, so it does not. |
| 397 | + // semantics from the shared base config it extends, so it does not. |
391 | 398 | ...(standalone ? { type: 'module' } : {}), |
392 | 399 | main: 'dist/index.js', |
393 | 400 | types: 'dist/index.d.ts', |
@@ -432,12 +439,18 @@ export const templates: Record<string, CreateTemplate> = { |
432 | 439 | include: SCAFFOLD_TSCONFIG_INCLUDE_SRC_ONLY, |
433 | 440 | }) |
434 | 441 | : { |
435 | | - extends: rootTsconfigExtends(PLUGIN_IN_REPO_DIR, pluginDirName(name)), |
| 442 | + // The shape a sibling under `packages/plugins/` declares |
| 443 | + // (`plugin-email` is one): the shared base, Node's types, and |
| 444 | + // an `exclude` of its own, so nothing it inherits resolves |
| 445 | + // against another directory. |
| 446 | + extends: baseTsconfigExtends(PLUGIN_IN_REPO_DIR, pluginDirName(name)), |
436 | 447 | compilerOptions: { |
437 | 448 | outDir: 'dist', |
438 | 449 | rootDir: 'src', |
| 450 | + types: ['node'], |
439 | 451 | }, |
440 | 452 | include: ['src/**/*'], |
| 453 | + exclude: ['dist', 'node_modules'], |
441 | 454 | }, |
442 | 455 | // The config `build` and `dev` compile with (#25175). `tsconfig.json` |
443 | 456 | // includes all of `src/`, the starter test with it, so `typecheck` |
|
0 commit comments