Skip to content

fix: make MDXRenderer a build error outside server components - #139

Merged
lwwmanning merged 1 commit into
mainfrom
claude/mdx-renderer-server-only
Oct 30, 2026
Merged

lwwmanning merged 1 commit into
mainfrom
claude/mdx-renderer-server-only

Conversation

@lwwmanning

Copy link
Copy Markdown
Contributor

MDXRenderer runs blog posts' compiled MDX with new Function. The CSP does not allow 'unsafe-eval', which is correct only while that code runs on the server. Nothing enforced this. The component now imports server-only, so importing it from a Client Component fails the build. Before, it failed at runtime in the browser. Next.js resolves server-only itself, so no package is added.

The build passes as is. A temporary client component that imported MDXRenderer failed the Turbopack build. Fixes #70.

🤖 Generated with Claude Code

MDXRenderer evaluates velite's compiled MDX with `new Function`. The
CSP has no 'unsafe-eval', which is correct only while the eval runs on
the server, but nothing enforced that. Import "server-only", which
Next.js resolves itself, so importing MDXRenderer from a Client
Component fails the build instead of failing at runtime in the browser.

Verified: the build passes as is, and a temporary client component
that imports MDXRenderer fails the Turbopack build. Fixes #70.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Will Manning <will@willmanning.io>
@vercel

vercel Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
vortex Ready Ready Preview Oct 30, 2026 1:02am UTC

Request Review

@lwwmanning
lwwmanning marked this pull request as ready for review October 30, 2026 01:02
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-30T01:03:48.789148Z e304ccf Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown

🔦 Lighthouse audit

URL Perf A11y Best practices SEO Report
/ 🟢 96 🟢 100 🟢 96 🟢 100 report
/blog 🟢 100 🟢 100 🟢 96 🟢 100 report
/blog/btrblocks-compressor 🟢 100 🟢 96 🟢 96 🟢 100 report

Run 40983369220 · 2026-10-30 01:03 UTC

@lwwmanning
lwwmanning merged commit c868bb8 into main Oct 30, 2026
20 checks passed
@lwwmanning
lwwmanning deleted the claude/mdx-renderer-server-only branch October 30, 2026 01:06
lwwmanning added a commit that referenced this pull request Oct 30, 2026
main adds COOP and CORP headers (#140), makes MDXRenderer server-only
(#139), locks bench's Vercel CLI (#137), and speeds up bench's cache
(#135, #136). CLAUDE.md keeps this branch's globals.css line and takes
main's header list. The site and bench checks, Playwright, and verify
pass on the merged tree.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Will Manning <will@willmanning.io>

This branch was successfully deployed

1 active deployment
Preview — e304ccf6 Deployed Oct 30, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enforce server-only invariant on MDXRenderer's new Function() eval

1 participant