|
1 | 1 | # web-shared |
2 | 2 |
|
3 | | -Server code shared by `apps/web` and `apps/ai-gateway`. The code was moved out of |
4 | | -`apps/web/src` without changing its `@/` import specifiers. |
| 3 | +Server code shared by `apps/web` and `apps/ai-gateway`, consumed from source. |
5 | 4 |
|
6 | 5 | ## Module resolution |
7 | 6 |
|
8 | | -- Consumers map `@/*` to their own `src/*` first and to `packages/web-shared/src/*` |
9 | | - second. Keep both entries in sync in every tsconfig, the web Jest config, the |
10 | | - `@kilocode/trpc` rollup resolver, and the Storybook webpack alias. |
11 | | -- A path must exist in only one of `apps/web/src` and `packages/web-shared/src`. |
12 | | - A duplicate silently shadows the web-shared file inside `apps/web`. |
| 7 | +- Import modules from this package as `@kilocode/web-shared/<path>`, which maps |
| 8 | + to `src/<path>`, both from consumers and inside this package. Every consumer |
| 9 | + tsconfig, the web Jest config, the `@kilocode/trpc` rollup resolver, and the |
| 10 | + Storybook webpack alias map that specifier. There is no `exports` map: |
| 11 | + specifiers are extensionless, so resolution relies on those mappings. |
| 12 | +- `@/` in a consumer means that consumer's own `src`; it never resolves here. |
13 | 13 | - Runtime code here must only import from this package. `pnpm --filter |
14 | 14 | @kilocode/web-shared typecheck` enforces that with `tsconfig.lib.json`, which |
15 | | - resolves `@/*` to this package only and excludes tests. |
16 | | -- Tests run under the `apps/web` Jest config and may import `apps/web` test |
17 | | - helpers; `tsconfig.json` falls back to `apps/web/src` for editors and linting. |
| 15 | + excludes tests and does not map `@/` at all. |
| 16 | +- Tests run under the `apps/web` Jest config and may import `apps/web` modules |
| 17 | + and test helpers through `@/`, which `tsconfig.json` maps to `apps/web/src`. |
18 | 18 | - Declare every npm import in `package.json` with the same version as |
19 | 19 | `apps/web`, including the optional peers that make pnpm resolve the same |
20 | 20 | `next` and `@sentry/nextjs` instances as `apps/web`. Two instances of `next` |
|
0 commit comments