/** * Custom generate:importmap script that works around tsx ESM resolution issues. * Run via: node --import tsx/esm scripts/generate-importmap.mjs * (from inside the Docker container where tsx is available in pnpm store) */ import { fileURLToPath, pathToFileURL } from 'url' import path from 'path' import { generateImportMap } from '@payloadcms/next/utilities' const __filename = fileURLToPath(import.meta.url) const __dirname = path.dirname(__filename) const root = path.resolve(__dirname, '..') // Load config from compiled dist or source const configPath = pathToFileURL(path.join(root, 'src/payload.config.ts')).toString() console.log('Loading config from:', configPath) const configModule = await import(configPath) const config = await (configModule.default ?? configModule) await generateImportMap(config, { log: true }) console.log('Done!')