Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/source-condition.md
Original file line number Diff line number Diff line change
@@ -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`
4 changes: 3 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions apps/docs/astro.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions apps/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/src/anvil/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion apps/server/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions apps/server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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"]
4 changes: 2 additions & 2 deletions apps/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
6 changes: 3 additions & 3 deletions apps/server/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
},
},
});
2 changes: 1 addition & 1 deletion packages/catalog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"type": "module",
"exports": {
".": {
"@stats/source": "./src/index.ts",
"@github-stats-forge/source": "./src/index.ts",
"default": "./build/index.js"
}
},
Expand Down
2 changes: 1 addition & 1 deletion packages/catalog/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
4 changes: 2 additions & 2 deletions packages/catalog/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
},
},
});
2 changes: 1 addition & 1 deletion packages/cli/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

Expand Down
4 changes: 2 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"type": "module",
"exports": {
".": {
"@stats/source": "./src/index.ts",
"@github-stats-forge/source": "./src/index.ts",
"default": "./build/index.js"
}
},
Expand All @@ -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"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
},
},
});
6 changes: 3 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
},
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Loading