Skip to content

Commit 222d144

Browse files
authored
fix(mdx): handle picocolors ESM/CJS interop for Turbopack (#2685)
1 parent d6d772b commit 222d144

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/mdx/src/utils/validation.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ export class ValidationError extends Error {
1515
}
1616

1717
async toStringFormatted() {
18-
const picocolors = await import('picocolors');
18+
// Handle ESM/CJS interop: picocolors is a CJS module that exports via
19+
// module.exports = createColors(). When dynamically imported in ESM context
20+
// (e.g., Next.js 16 Turbopack), the exports are wrapped under .default
21+
const picocolorsModule = await import('picocolors');
22+
const picocolors = picocolorsModule.default ?? picocolorsModule;
1923

2024
return [
2125
picocolors.bold(`[MDX] ${this.title}:`),

0 commit comments

Comments
 (0)