Files
supabase/apps/studio/static-data/integrations/overviews.test.ts
Alaister Young 80e44df4be fix(studio): load integration overview markdown in the TanStack build
Every integration detail page's overview text was blank under the Vite
dev/TanStack build: the two MarkdownContent components loaded their copy
via a template-literal dynamic import
(import(`@/static-data/integrations/${id}/overview.md`)), which webpack
turns into a context module but Vite/Rolldown leaves untouched, so the
browser threw "TypeError: Failed to resolve module specifier" for every
integration (data_api, cron, queues, vault, graphiql, ...).

Replace the template-literal import with an explicit registry of literal
dynamic imports (static-data/integrations/overviews.ts) that both
bundlers can statically analyze and code-split, and add an mdRawLoader
Vite plugin mirroring next.config.ts's raw-loader rule so .md files
resolve to their text content under Vite without query-suffixed
specifiers (which would break the turbopack rule). A unit test keeps the
registry in sync with the overview.md files on disk, and types/markdown.d.ts
types the literal .md imports.

Claude-Session: https://claude.ai/code/session_01MLH8WVg8zBJnmZTYTV3ooo
2026-07-07 04:11:22 +08:00

28 lines
890 B
TypeScript

import { readdirSync, statSync } from 'node:fs'
import { join } from 'node:path'
import { describe, expect, it } from 'vitest'
import { INTEGRATION_OVERVIEW_IDS } from './overviews'
const INTEGRATIONS_DIR = join(__dirname)
const idsOnDisk = readdirSync(INTEGRATIONS_DIR)
.filter((entry) => {
try {
return statSync(join(INTEGRATIONS_DIR, entry, 'overview.md')).isFile()
} catch {
return false
}
})
.sort()
describe('integration overview registry', () => {
// The registry uses literal import specifiers (required for both bundlers
// to statically analyze them), so it can't glob the directory at runtime.
// This keeps it honest: adding/removing an overview.md must be mirrored in
// overviews.ts.
it('stays in sync with static-data/integrations/*/overview.md', () => {
expect([...INTEGRATION_OVERVIEW_IDS].sort()).toEqual(idsOnDisk)
})
})