Skip to content

Commit 3a4804a

Browse files
committed
build(web-shared): stop resolving @/ into packages/web-shared
`@/*` now maps only to the consumer's own src in apps/web, apps/ai-gateway, packages/trpc, the web Jest config and the Storybook alias. Inside packages/web-shared, `@/*` maps to apps/web/src for tests that use apps/web helpers; tsconfig.lib.json drops it so runtime code cannot use `@/` at all. The trpc rollup resolver and the MCP catalog import resolver follow `@kilocode/web-shared/*` into packages/web-shared/src.
1 parent 77f6116 commit 3a4804a

10 files changed

Lines changed: 13 additions & 13 deletions

File tree

‎apps/ai-gateway/tsconfig.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"skipLibCheck": true,
1010
"forceConsistentCasingInFileNames": true,
1111
"paths": {
12-
"@/*": ["./src/*", "../../packages/web-shared/src/*"],
12+
"@/*": ["./src/*"],
1313
"@kilocode/web-shared/*": ["../../packages/web-shared/src/*"],
1414
"@kilocode/db": ["../../packages/db/src/index.ts"],
1515
"@kilocode/db/*": ["../../packages/db/src/*"],

‎apps/storybook/.storybook/main.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const config: StorybookConfig = {
4242
if (config.resolve) {
4343
config.resolve.alias = {
4444
...config.resolve.alias,
45-
'@': [srcDir, webSharedSrcDir],
45+
'@': srcDir,
4646
'@kilocode/web-shared': webSharedSrcDir,
4747
'@/lib/utils': resolve(mocksDir, 'utils.ts'),
4848
};

‎apps/web/jest.config.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const config: Config = {
3333
'^@kilocode/app-shared/(.*)$': '<rootDir>/../../packages/app-shared/src/$1',
3434
'^@kilocode/web-shared/(.*)$': '<rootDir>/../../packages/web-shared/src/$1',
3535
'^(\\.{1,2}/.+)\\.js$': '$1',
36-
'^@/(.*)$': ['<rootDir>/src/$1', '<rootDir>/../../packages/web-shared/src/$1'],
36+
'^@/(.*)$': '<rootDir>/src/$1',
3737
'^server-only$': '<rootDir>/src/tests/setup/__mocks__/server-only.js',
3838
},
3939
roots: ['<rootDir>', '<rootDir>/../../packages/web-shared'],

‎apps/web/src/scripts/mcp-catalog/catalog.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,8 @@ export function buildCatalogJson(rows: CatalogRow[]): string {
417417

418418
const SCRIPTS_DIR = join(__dirname, '..'); // apps/web/src/scripts
419419
const SRC_DIR = join(SCRIPTS_DIR, '..'); // apps/web/src
420+
const WEB_SHARED_SPECIFIER_PREFIX = '@kilocode/web-shared/';
421+
const WEB_SHARED_SRC_DIR = join(REPO_ROOT, 'packages', 'web-shared', 'src');
420422

421423
type RouterFileMap = Map<string, string>; // top-level segment → absolute router file path
422424

@@ -425,6 +427,8 @@ function resolveImportSpecifier(specifier: string, fromDir: string): string | nu
425427
let candidate: string;
426428
if (withoutQuery.startsWith('@/')) {
427429
candidate = join(SRC_DIR, withoutQuery.slice(2));
430+
} else if (withoutQuery.startsWith(WEB_SHARED_SPECIFIER_PREFIX)) {
431+
candidate = join(WEB_SHARED_SRC_DIR, withoutQuery.slice(WEB_SHARED_SPECIFIER_PREFIX.length));
428432
} else if (withoutQuery.startsWith('./') || withoutQuery.startsWith('../')) {
429433
candidate = resolve(fromDir, withoutQuery);
430434
} else {

‎apps/web/tsconfig.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"skipLibCheck": true,
1010
"forceConsistentCasingInFileNames": true,
1111
"paths": {
12-
"@/*": ["./src/*", "../../packages/web-shared/src/*"],
12+
"@/*": ["./src/*"],
1313
"@kilocode/web-shared/*": ["../../packages/web-shared/src/*"],
1414
"@kilocode/db": ["../../packages/db/src/index.ts"],
1515
"@kilocode/db/*": ["../../packages/db/src/*"],

‎apps/web/tsconfig.scripts.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"compilerOptions": {
44
"baseUrl": ".",
55
"paths": {
6-
"@/*": ["./src/*", "../../packages/web-shared/src/*"],
6+
"@/*": ["./src/*"],
77
"@kilocode/web-shared/*": ["../../packages/web-shared/src/*"],
88
"@kilocode/db": ["../../packages/db/src/index.ts"],
99
"@kilocode/db/*": ["../../packages/db/src/*"],

‎packages/trpc/rollup.config.mjs‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,9 @@ const plugins = [
3636
{
3737
name: 'resolve-aliases',
3838
resolveId(source) {
39-
// Resolve @/* path aliases to the tsc output, mirroring the tsconfig
40-
// fallback from apps/web/src to packages/web-shared/src.
39+
// Resolve the tsconfig path aliases to the tsc output.
4140
if (source.startsWith('@/')) {
42-
const webDts = resolveDts(path.resolve(tscOut, 'apps/web/src', source.slice(2)));
43-
if (existsSync(webDts)) return webDts;
44-
return resolveDts(path.resolve(tscOut, 'packages/web-shared/src', source.slice(2)));
41+
return resolveDts(path.resolve(tscOut, 'apps/web/src', source.slice(2)));
4542
}
4643
if (source.startsWith(webSharedPrefix)) {
4744
const subpath = source.slice(webSharedPrefix.length);

‎packages/trpc/tsconfig.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"jsx": "react-jsx",
1717
"resolveJsonModule": true,
1818
"paths": {
19-
"@/*": ["../../apps/web/src/*", "../web-shared/src/*"],
19+
"@/*": ["../../apps/web/src/*"],
2020
"@kilocode/web-shared/*": ["../web-shared/src/*"],
2121
"@kilocode/db": ["../db/src/index.ts"],
2222
"@kilocode/db/*": ["../db/src/*"],

‎packages/web-shared/tsconfig.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"skipLibCheck": true,
1010
"forceConsistentCasingInFileNames": true,
1111
"paths": {
12-
"@/*": ["./src/*", "../../apps/web/src/*"],
12+
"@/*": ["../../apps/web/src/*"],
1313
"@kilocode/web-shared/*": ["./src/*"],
1414
"@kilocode/db": ["../db/src/index.ts"],
1515
"@kilocode/db/*": ["../db/src/*"],

‎packages/web-shared/tsconfig.lib.json‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"compilerOptions": {
44
"types": ["node"],
55
"paths": {
6-
"@/*": ["./src/*"],
76
"@kilocode/web-shared/*": ["./src/*"],
87
"@kilocode/db": ["../db/src/index.ts"],
98
"@kilocode/db/*": ["../db/src/*"],

0 commit comments

Comments
 (0)