Skip to content

Conversation

@Ryan-Amirthan
Copy link
Contributor

Fixes custom React components not rendering inside <Aside> components.

Short description of the changes made

When the rehypeExtractAsides plugin extracts Aside content, it generates a component that destructures JSX elements from useMDXComponents(). This was causing imported custom components to be shadowed by undefined values, resulting in "Something went wrong!" errors.

The fix extracts module-level ESM bindings from the full AST and filters them out from the list of components to destructure, preventing the shadowing of imported custom components.

What was the motivation & context behind this PR?

Custom React components (e.g., CustomCard) work correctly in the main content but fail inside <Aside> components. This was reported in Slack - see the test case at https://plantman-preview-4ed7e531-1b9f-402c-9f0f-a2e2b811e9ed.docs.buildwithfern.com/concepts

The root cause: the generated AsideComponent function creates const { CustomCard } = MdxJsReact.useMDXComponents(), which shadows any CustomCard imported at module scope. Since the MDXProvider doesn't have CustomCard, it becomes undefined.

How has this PR been tested?

  • Lint checks pass (pnpm lint:biome)

Human review checklist:

  • Verify the fix works against the failing preview URL
  • Confirm extractJsx(ast).esmElements correctly captures imported component names
  • Check for edge cases where a component might need to come from both import and MDXProvider
  • Consider if extractJsx call should be moved after the asides.length === 0 check for performance

Link to Devin run: https://app.devin.ai/sessions/48f55436d7304e6fbf43694fbaf910a7
Requested by: [email protected] (@Ryan-Amirthan)

@devin-ai-integration
Copy link
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@vercel
Copy link
Contributor

vercel bot commented Dec 23, 2025

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

Project Deployment Review Updated (UTC)
dev.ferndocs.com Ready Ready Preview Dec 23, 2025 2:33am
fern-dashboard Ready Ready Preview Dec 23, 2025 2:33am
fern-dashboard-dev Ready Ready Preview Dec 23, 2025 2:33am
prod-assets.ferndocs.com Ready Ready Preview Dec 23, 2025 2:33am
prod.ferndocs.com Ready Ready Preview Dec 23, 2025 2:33am
1 Skipped Deployment
Project Deployment Review Updated (UTC)
fern-platform Ignored Ignored Dec 23, 2025 2:33am

@github-actions
Copy link
Contributor

github-actions bot commented Dec 23, 2025

🌱 Smoke Test Preview

Run at: 2025-12-23 02:46:52 UTC

Testing branch changes with smoke test content:

🕷️ Smoke Test Crawler Results

Pages crawled: 49
Successful: 44
With errors: 5 ❌

❌ Pages with Errors

https://smoke-test-preview-e680e257-6822-4485-ae14-f1d6aa76e4c4.docs.buildwithfern.com/home/rest-api/rest-api/user/get-auth-token

  • Network errors (1):
    • Failed to load https://api.github.com/repos/fern-api/fern: net::ERR_ABORTED

https://smoke-test-preview-e680e257-6822-4485-ae14-f1d6aa76e4c4.docs.buildwithfern.com/home/rest-api/rest-api/user/get-user-by-name

  • Network errors (1):
    • Failed to load https://api.github.com/repos/fern-api/fern: net::ERR_ABORTED

https://smoke-test-preview-e680e257-6822-4485-ae14-f1d6aa76e4c4.docs.buildwithfern.com/home/rest-api/rest-api/one-of-examples/one-of-example

  • Network errors (1):
    • Failed to load https://api.github.com/repos/fern-api/fern: net::ERR_ABORTED

https://smoke-test-preview-e680e257-6822-4485-ae14-f1d6aa76e4c4.docs.buildwithfern.com/home/rest-api/rest-api/one-of-examples/one-of-example-no-discriminator

  • Network errors (1):
    • Failed to load https://api.github.com/repos/fern-api/fern: net::ERR_ABORTED

https://smoke-test-preview-e680e257-6822-4485-ae14-f1d6aa76e4c4.docs.buildwithfern.com/home/rest-api/rest-api/one-of-examples/one-of-example-titled

  • Network errors (1):
    • Failed to load https://api.github.com/repos/fern-api/fern: net::ERR_ABORTED
📊 Full error breakdown
  • Console errors: 0
  • Network errors: 5
  • Page errors: 0

See full details in the workflow logs.

@fern-support fern-support merged commit d8a6121 into app Dec 23, 2025
23 of 25 checks passed
@fern-support fern-support deleted the devin/1766456645-fix-custom-components-in-aside-v2 branch December 23, 2025 03:05
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.

4 participants