From b128c5e5c20a3eea937660c66f673cbafd7062ca Mon Sep 17 00:00:00 2001 From: Marco Pasqualetti <24919330+marcalexiei@users.noreply.github.com> Date: Sat, 14 Nov 2026 13:33:52 +0100 Subject: [PATCH] fix: rename the source export condition to @github-stats-forge/source --- .changeset/source-condition.md | 7 +++++++ AGENTS.md | 4 +++- apps/docs/astro.config.ts | 6 +++--- apps/docs/package.json | 8 ++++---- apps/docs/src/anvil/AGENTS.md | 2 +- apps/server/AGENTS.md | 2 +- apps/server/Dockerfile | 4 ++-- apps/server/package.json | 4 ++-- apps/server/vitest.config.ts | 6 +++--- packages/catalog/package.json | 2 +- packages/catalog/tsconfig.json | 2 +- packages/catalog/vitest.config.ts | 4 ++-- packages/cli/AGENTS.md | 2 +- packages/cli/package.json | 4 ++-- packages/cli/tsconfig.json | 2 +- packages/cli/vitest.config.ts | 4 ++-- packages/core/package.json | 6 +++--- tsconfig.base.json | 2 +- vitest.config.ts | 2 +- 19 files changed, 41 insertions(+), 32 deletions(-) create mode 100644 .changeset/source-condition.md diff --git a/.changeset/source-condition.md b/.changeset/source-condition.md new file mode 100644 index 00000000..91143964 --- /dev/null +++ b/.changeset/source-condition.md @@ -0,0 +1,7 @@ +--- +'@stats-forge/github-stats-forge-core': patch +'@stats-forge/github-stats-forge-catalog': patch +'@stats-forge/github-stats-forge-cli': patch +--- + +fix: rename the source export condition to `@github-stats-forge/source`, so another workspace's `@stats/source` no longer loads TypeScript from `node_modules` diff --git a/AGENTS.md b/AGENTS.md index a3bb3c78..e5c7858b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -119,7 +119,9 @@ pnpm --filter ./packages/core/ run check-graphql-types # what CI runs; fail - **Ordering is `pnpm -r`'s topological order**; `typecheck` builds first because each `tsconfig.typecheck.json` resolves core through its `.d.ts`. turbo cost more than it saved ([#41]); measure before reinstating one. -- **vitest applies `@stats/source` only when it is also under `ssr.resolve.conditions`**; see +- **The source condition is named for this repo, `@github-stats-forge/source`**: a name another + stats-forge workspace also sets would load this package's TypeScript from its `node_modules`. +- **vitest applies it only when it is also under `ssr.resolve.conditions`**; see `packages/cli/vitest.config.ts`. ## Documentation and previews diff --git a/apps/docs/astro.config.ts b/apps/docs/astro.config.ts index 2f708908..beb79e29 100644 --- a/apps/docs/astro.config.ts +++ b/apps/docs/astro.config.ts @@ -39,11 +39,11 @@ export default defineConfig({ vite: { /* * The anvil bundles `packages/core` and the CLI's card catalog from their `src/`, through - * `@stats/source`, so the docs job runs with nothing built. `ssr` has to say it too — a + * `@github-stats-forge/source`, so the docs job runs with nothing built. `ssr` has to say it too — a * condition set only under `resolve` is not applied to the server build. */ - resolve: { conditions: ['@stats/source'] }, - ssr: { resolve: { conditions: ['@stats/source'] } }, + resolve: { conditions: ['@github-stats-forge/source'] }, + ssr: { resolve: { conditions: ['@github-stats-forge/source'] } }, }, markdown: { // Starlight appends its own plugins to whatever processor is configured here. diff --git a/apps/docs/package.json b/apps/docs/package.json index 9d15a167..62ae61b9 100644 --- a/apps/docs/package.json +++ b/apps/docs/package.json @@ -9,11 +9,11 @@ "preview": "astro preview", "generate-cards": "node scripts/generate-cards.ts", "check-cards": "node scripts/generate-cards.ts --check", - "test:live": "node --conditions=@stats/source --env-file-if-exists=../../.env scripts/test-live.ts", - "check-anvil": "node --conditions=@stats/source scripts/check-anvil.ts", + "test:live": "node --conditions=@github-stats-forge/source --env-file-if-exists=../../.env scripts/test-live.ts", + "check-anvil": "node --conditions=@github-stats-forge/source scripts/check-anvil.ts", "test:e2e": "playwright test", - "generate-themes-page": "node --conditions=@stats/source scripts/generate-themes-page.ts", - "check-themes-page": "node --conditions=@stats/source scripts/generate-themes-page.ts --check", + "generate-themes-page": "node --conditions=@github-stats-forge/source scripts/generate-themes-page.ts", + "check-themes-page": "node --conditions=@github-stats-forge/source scripts/generate-themes-page.ts --check", "typecheck": "astro sync && tsc -p tsconfig.json" }, "dependencies": { diff --git a/apps/docs/src/anvil/AGENTS.md b/apps/docs/src/anvil/AGENTS.md index 45a20050..8a99365d 100644 --- a/apps/docs/src/anvil/AGENTS.md +++ b/apps/docs/src/anvil/AGENTS.md @@ -60,7 +60,7 @@ the CLI's `--config` reads. A rule with no link comes from [#58]. the rest open folded. - **The theme is two pickers writing one `theme` param**: "Theme", and "Dark mode", which makes it a `light,dark` pair and is left unset to wear one theme in both. -- **Core and the catalog bundle from source via `@stats/source`, under both `vite.resolve` and +- **Core and the catalog bundle from source via `@github-stats-forge/source`, under both `vite.resolve` and `vite.ssr.resolve`.** The condition misses the client build, so `docs:build` builds the packages first. ## The preview diff --git a/apps/server/AGENTS.md b/apps/server/AGENTS.md index 632319b5..215cbd71 100644 --- a/apps/server/AGENTS.md +++ b/apps/server/AGENTS.md @@ -10,7 +10,7 @@ from [#79]. **It owns routing, HTTP status and headers, caching and the process, - **Never log a query value or a token.** One JSON line per request on stdout, built from the response's headers; `PersonalAccessToken` carries the env var's `name` for this. -- **Never add a build step.** Node strips the types and `--conditions=@stats/source` points at +- **Never add a build step.** Node strips the types and `--conditions=@github-stats-forge/source` points at core's source, so the image runs the repository. A rolldown bundle was removed: nobody could diff it, and its `resolve.conditionNames` fails quietly when misspelt `conditions`. - **Never let a rejection escape the adapter**: Node 24 dies on one. A throwing handler answers diff --git a/apps/server/Dockerfile b/apps/server/Dockerfile index d1f94f57..4f0dd2dd 100644 --- a/apps/server/Dockerfile +++ b/apps/server/Dockerfile @@ -3,7 +3,7 @@ # The build context is the repository root: the lockfile and every workspace manifest live above. # # There is no build step. Node strips the types and every relative import names the `.ts` that -# exists, so the image runs the sources; `--conditions=@stats/source` points the core import at +# exists, so the image runs the sources; `--conditions=@github-stats-forge/source` points the core import at # `packages/core/src`. # Pinned by digest, because `26-alpine` is a moving tag; Renovate maintains it. @@ -83,4 +83,4 @@ EXPOSE 9000 HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ CMD ["node", "src/healthcheck.ts"] -CMD ["node", "--conditions=@stats/source", "src/index.ts"] +CMD ["node", "--conditions=@github-stats-forge/source", "src/index.ts"] diff --git a/apps/server/package.json b/apps/server/package.json index 07a97881..9b2870ae 100644 --- a/apps/server/package.json +++ b/apps/server/package.json @@ -5,8 +5,8 @@ "description": "HTTP server that draws the cards, and the container image it ships in", "type": "module", "scripts": { - "dev": "node --conditions=@stats/source --env-file-if-exists=../../.env --watch src/index.ts", - "start": "node --conditions=@stats/source src/index.ts", + "dev": "node --conditions=@github-stats-forge/source --env-file-if-exists=../../.env --watch src/index.ts", + "start": "node --conditions=@github-stats-forge/source src/index.ts", "test": "vitest", "typecheck": "tsc -p tsconfig.json" }, diff --git a/apps/server/vitest.config.ts b/apps/server/vitest.config.ts index 9602f291..a63c9966 100644 --- a/apps/server/vitest.config.ts +++ b/apps/server/vitest.config.ts @@ -2,16 +2,16 @@ import { defineConfig } from 'vitest/config'; export default defineConfig({ /* - * The server reads core and the catalog through the `@stats/source` condition, which + * The server reads core and the catalog through the `@github-stats-forge/source` condition, which * vitest only applies when it is set under `ssr.resolve.conditions` as well as `resolve` — * the same trap `packages/cli/vitest.config.ts` documents. */ resolve: { - conditions: ['@stats/source'], + conditions: ['@github-stats-forge/source'], }, ssr: { resolve: { - conditions: ['@stats/source'], + conditions: ['@github-stats-forge/source'], }, }, }); diff --git a/packages/catalog/package.json b/packages/catalog/package.json index 4cdcc837..4db8f1fb 100644 --- a/packages/catalog/package.json +++ b/packages/catalog/package.json @@ -31,7 +31,7 @@ "type": "module", "exports": { ".": { - "@stats/source": "./src/index.ts", + "@github-stats-forge/source": "./src/index.ts", "default": "./build/index.js" } }, diff --git a/packages/catalog/tsconfig.json b/packages/catalog/tsconfig.json index 5bf41aa4..e5b7694b 100644 --- a/packages/catalog/tsconfig.json +++ b/packages/catalog/tsconfig.json @@ -6,7 +6,7 @@ "vitest.config.ts", /* - * The `@stats/source` condition points imports of core at its TypeScript, + * The `@github-stats-forge/source` condition points imports of core at its TypeScript, * which carries `declare module` shims for its two untyped dependencies. * `tsconfig.typecheck.json` clears the condition and reads the built types instead, * so this only matters to the editor and to a bare `tsc`. diff --git a/packages/catalog/vitest.config.ts b/packages/catalog/vitest.config.ts index 729ba80e..5ac601f1 100644 --- a/packages/catalog/vitest.config.ts +++ b/packages/catalog/vitest.config.ts @@ -10,11 +10,11 @@ export default defineProject({ * Keep the condition in sync with `tsconfig.base.json#customConditions`. */ resolve: { - conditions: ['@stats/source'], + conditions: ['@github-stats-forge/source'], }, ssr: { resolve: { - conditions: ['@stats/source'], + conditions: ['@github-stats-forge/source'], }, }, }); diff --git a/packages/cli/AGENTS.md b/packages/cli/AGENTS.md index 0cece668..74b1754b 100644 --- a/packages/cli/AGENTS.md +++ b/packages/cli/AGENTS.md @@ -3,7 +3,7 @@ > Scoped to this tree; the repo-wide rules are in the root `AGENTS.md`. `@stats-forge/github-stats-forge-cli`, whose `bin` is `./bin.js`. `pnpm dev` runs -`node --conditions=@stats/source src/index.ts` with no build: Node strips the types, and the +`node --conditions=@github-stats-forge/source src/index.ts` with no build: Node strips the types, and the condition reaches core's source through a symlink outside `node_modules`. `pnpm cli` at the root builds and runs it against the root `.env`. diff --git a/packages/cli/package.json b/packages/cli/package.json index 142431db..43fc9151 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -33,7 +33,7 @@ "type": "module", "exports": { ".": { - "@stats/source": "./src/index.ts", + "@github-stats-forge/source": "./src/index.ts", "default": "./build/index.js" } }, @@ -44,7 +44,7 @@ "build": "tsc -p tsconfig.build.json", "prepack": "pnpm run build", "lint:publish": "attw --pack . --profile node16 --ignore-rules cjs-resolves-to-esm && publint --strict", - "dev": "node --conditions=@stats/source src/index.ts", + "dev": "node --conditions=@github-stats-forge/source src/index.ts", "test": "vitest", "typecheck": "tsc -p tsconfig.typecheck.json" }, diff --git a/packages/cli/tsconfig.json b/packages/cli/tsconfig.json index 5bf41aa4..e5b7694b 100644 --- a/packages/cli/tsconfig.json +++ b/packages/cli/tsconfig.json @@ -6,7 +6,7 @@ "vitest.config.ts", /* - * The `@stats/source` condition points imports of core at its TypeScript, + * The `@github-stats-forge/source` condition points imports of core at its TypeScript, * which carries `declare module` shims for its two untyped dependencies. * `tsconfig.typecheck.json` clears the condition and reads the built types instead, * so this only matters to the editor and to a bare `tsc`. diff --git a/packages/cli/vitest.config.ts b/packages/cli/vitest.config.ts index 729ba80e..5ac601f1 100644 --- a/packages/cli/vitest.config.ts +++ b/packages/cli/vitest.config.ts @@ -10,11 +10,11 @@ export default defineProject({ * Keep the condition in sync with `tsconfig.base.json#customConditions`. */ resolve: { - conditions: ['@stats/source'], + conditions: ['@github-stats-forge/source'], }, ssr: { resolve: { - conditions: ['@stats/source'], + conditions: ['@github-stats-forge/source'], }, }, }); diff --git a/packages/core/package.json b/packages/core/package.json index d7165003..f9aafc86 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -54,15 +54,15 @@ "type": "module", "exports": { "./api": { - "@stats/source": "./src/api/index.ts", + "@github-stats-forge/source": "./src/api/index.ts", "default": "./build/api/index.js" }, "./fetchers": { - "@stats/source": "./src/fetchers/index.ts", + "@github-stats-forge/source": "./src/fetchers/index.ts", "default": "./build/fetchers/index.js" }, "./themes": { - "@stats/source": "./src/themes/index.ts", + "@github-stats-forge/source": "./src/themes/index.ts", "default": "./build/themes/index.js" } }, diff --git a/tsconfig.base.json b/tsconfig.base.json index 3f904816..4e8bcc41 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -25,7 +25,7 @@ * Keep in sync with the `conditions` in each package's `vitest.config.ts`. */ - "@stats/source" + "@github-stats-forge/source" ], // A relative import names the file that exists, so `node src/index.ts` resolves it. diff --git a/vitest.config.ts b/vitest.config.ts index 66a80abb..e660b2ad 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -2,7 +2,7 @@ import { defineConfig } from 'vitest/config'; export default defineConfig({ test: { - // a project does not inherit this file, so each sets the `@stats/source` condition it needs + // a project does not inherit this file, so each sets the `@github-stats-forge/source` condition it needs projects: [ 'packages/core/vitest.config.ts', 'packages/catalog/vitest.config.ts',