Skip to content

Commit 04e8e8b

Browse files
committed
fix: move repoSocial into api/_lib so Vercel functions can import it
Both api/repo-page and api/og crashed in production with ERR_MODULE_NOT_FOUND on /var/task/src/lib/repoSocial: Vercel compiles TypeScript under api/ only, so a function importing ../src/lib/* ships an import specifier the Node runtime can't resolve — and the /repos/:owner/:name rewrite meant every direct repo-page load 500'd. The module was already runtime-agnostic by design; it now lives in api/_lib with the browser hook importing across, and tsconfig.api's src special-case is gone.
1 parent c682af2 commit 04e8e8b

8 files changed

Lines changed: 6 additions & 6 deletions

File tree

‎api/_lib/og-layout.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { CSSProperties, ReactElement, ReactNode } from 'react';
22

3-
import type { RepoSocialModel } from '../../src/lib/repoSocial';
3+
import type { RepoSocialModel } from './repoSocial';
44

55
export const OG_WIDTH = 1200;
66
export const OG_HEIGHT = 630;

‎api/_tests/og.test.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { afterEach, describe, expect, it, vi } from 'vitest';
22

3-
import { repoCacheVersion } from '../../src/lib/repoSocial';
3+
import { repoCacheVersion } from '../_lib/repoSocial';
44
import type { ApiRepository } from '../_lib/repository';
55
import { GET } from '../og';
66

‎api/og.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
cleanSocialText,
1010
normalizeRepoOwner,
1111
type RepoSocialModel,
12-
} from '../src/lib/repoSocial';
12+
} from './_lib/repoSocial';
1313
import { GenericOgCard, OG_HEIGHT, OG_WIDTH, RepositoryOgCard } from './_lib/og-layout';
1414
import { fetchRepository } from './_lib/repository';
1515

‎api/repo-page.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { buildRepoSocialModel, escapeHtml } from '../src/lib/repoSocial';
1+
import { buildRepoSocialModel, escapeHtml } from './_lib/repoSocial';
22
import { fetchRepository } from './_lib/repository';
33

44
const GENERIC_TITLE = 'gitlawb explorer';

‎src/hooks/useRepositorySocialMetadata.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useEffect } from 'react';
2-
import { buildRepoSocialModel, type RepoSocialInput } from '../lib/repoSocial';
2+
import { buildRepoSocialModel, type RepoSocialInput } from '../../api/_lib/repoSocial';
33
import type { Repository } from '../types/repo';
44

55
const SITE_NAME = 'gitlawb explorer';

‎tsconfig.api.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@
1919
"erasableSyntaxOnly": true,
2020
"noFallthroughCasesInSwitch": true
2121
},
22-
"include": ["api", "src/lib/repoSocial.ts"]
22+
"include": ["api"]
2323
}

0 commit comments

Comments
 (0)