mirror of
https://github.com/supabase/supabase.git
synced 2026-10-11 04:15:04 +03:00
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
28 lines
890 B
TypeScript
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)
|
|
})
|
|
})
|