diff --git a/packages/docs/src/app/layout.tsx b/packages/docs/src/app/layout.tsx index eca2f1e4..36973ae6 100644 --- a/packages/docs/src/app/layout.tsx +++ b/packages/docs/src/app/layout.tsx @@ -87,6 +87,10 @@ export default async function RootLayout({children}: {children: React.ReactNode} docsRepositoryBase="https://github.com/redotvideo/revideo/blob/main/packages/docs" sidebar={{defaultMenuCollapseLevel: 1}} pageMap={pageMap} + // The docs are dark-only (forcedTheme below), so hide the theme + // switch Nextra otherwise renders in the sidebar footer — a toggle + // that has no effect. + darkMode={false} nextThemes={{defaultTheme: "dark", forcedTheme: "dark"}} > {children} diff --git a/packages/docs/src/components/site/revideo-import-map.tsx b/packages/docs/src/components/site/revideo-import-map.tsx index e8fa5ede..874c2e28 100644 --- a/packages/docs/src/components/site/revideo-import-map.tsx +++ b/packages/docs/src/components/site/revideo-import-map.tsx @@ -1,5 +1,13 @@ -import fs from 'node:fs'; -import path from 'node:path'; +// Statically imported (rather than read via `fs` at render time) so Next +// bundles it into the server output. A runtime `fs.readFileSync` of a computed +// path isn't picked up by Next's file tracing, so it's dropped from the +// production build and the import map silently disappears - which breaks the +// fiddles' `import('@revideo/2d')` with "bare specifier ... not remapped". +// +// The manifest is generated by scripts/copy-modules.mjs, which runs before +// `next build`/`next dev` (see package.json). It maps `@revideo/core` / +// `@revideo/2d` to the hashed ESM bundles copied into public/modules. +import manifest from '@/generated/modules.json'; // Keep in sync with `basePath` in next.config.ts. const BASE_PATH = '/revideo'; @@ -10,24 +18,6 @@ const BASE_PATH = '/revideo'; * bundles copied into public/modules by scripts/copy-modules.mjs. */ export function RevideoImportMap() { - let manifest: Record; - try { - manifest = JSON.parse( - fs.readFileSync( - path.join(process.cwd(), 'src', 'generated', 'modules.json'), - 'utf8', - ), - ); - } catch { - // Without the manifest the fiddles cannot load the runtime; skip the - // import map instead of failing the whole site. - console.warn( - 'src/generated/modules.json is missing - run `npm run modules:copy` ' + - 'to enable the interactive fiddles.', - ); - return null; - } - const importMap = { imports: { '@revideo/core': `${BASE_PATH}${manifest['@revideo/core']}`,