Skip to content

Commit 35ffdfa

Browse files
committed
fix: ESM-proof the api function imports; inline the OG layout
Follow-up to the repoSocial move — two more tracer/runtime mismatches kept api/og crashing: - The package is type:module, so compiled functions run as Node ESM and extensionless relative specifiers never resolve. All cross-file api imports now carry explicit .js extensions (TS, Vite, and vitest all resolve .js -> .ts natively). - The tracer maps .js specifiers to .ts sources but not .tsx, so an imported .tsx module is silently dropped from the bundle. og-layout is inlined into the og.tsx entrypoint (entrypoint .tsx compiles fine); its exports remain for the tests. Verified against a local vercel build: both compiled functions import cleanly under node --input-type=module, and GET on og.js renders a real 200 image/png including the traced JetBrains Mono TTFs.
1 parent 04e8e8b commit 35ffdfa

8 files changed

Lines changed: 563 additions & 559 deletions

File tree

‎api/_lib/og-layout.tsx‎

Lines changed: 0 additions & 545 deletions
This file was deleted.

‎api/_lib/repoSocial.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
normalizeRepoOwner,
99
repoCacheVersion,
1010
type RepoSocialInput,
11-
} from './repoSocial';
11+
} from './repoSocial.js';
1212

1313
const REPO: RepoSocialInput = {
1414
name: 'digital-garden',

‎api/_lib/repository.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { afterEach, describe, expect, it, vi } from 'vitest';
2-
import { fetchRepository, type ApiRepository } from './repository';
2+
import { fetchRepository, type ApiRepository } from './repository.js';
33

44
const REPOSITORY: ApiRepository = {
55
id: 'repo-1',

‎api/_tests/og.test.tsx‎

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

3-
import { repoCacheVersion } from '../_lib/repoSocial';
4-
import type { ApiRepository } from '../_lib/repository';
5-
import { GET } from '../og';
3+
import { repoCacheVersion } from '../_lib/repoSocial.js';
4+
import type { ApiRepository } from '../_lib/repository.js';
5+
import { GET } from '../og.js';
66

77
const repository = {
88
id: 'repo-1',

‎api/_tests/repo-page.test.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
2-
import { fetchRepository, type ApiRepository } from '../_lib/repository';
3-
import { GET } from '../repo-page';
2+
import { fetchRepository, type ApiRepository } from '../_lib/repository.js';
3+
import { GET } from '../repo-page.js';
44

5-
vi.mock('../_lib/repository', () => ({
5+
vi.mock('../_lib/repository.js', () => ({
66
fetchRepository: vi.fn(),
77
}));
88

0 commit comments

Comments
 (0)