-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix: Resolve serverless runtime errors for mdx-bundler and esbuild #16109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
6cd714b
fix(DOCS-A0W): Replace mdx-bundler/client with local getMDXComponent
jaffrepaul e810778
fix(DOCS-A3H): Pre-compile API markdown at build time
jaffrepaul feea019
fix(DOCS-A3F): Handle sitemap gracefully when doctree unavailable
jaffrepaul 20ae29c
[getsentry/action-github-commit] Auto commit
getsantry[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| /** | ||
| * Local implementation of getMDXComponent from mdx-bundler/client. | ||
| * | ||
| * This eliminates the runtime dependency on mdx-bundler/client which has | ||
| * CJS/ESM compatibility issues when loaded in Vercel serverless functions. | ||
| * The mdx-bundler package uses "type": "module" but the client/ subdirectory | ||
| * uses CommonJS require() to load ../dist/client.js, causing: | ||
| * "require() of ES Module not supported" | ||
| * | ||
| * Since getMDXComponent only needs React at runtime (and the compiled MDX code | ||
| * is just a string), we can safely inline this implementation. | ||
| * | ||
| * Fixes: DOCS-A0W | ||
| * @see https://github.com/kentcdodds/mdx-bundler/blob/main/src/client.js | ||
| */ | ||
| import type {ComponentType, FunctionComponent} from 'react'; | ||
| // These namespace imports are required - the MDX runtime expects React, ReactDOM, | ||
| // and jsx_runtime objects in scope to call methods like React.createElement() | ||
| // eslint-disable-next-line no-restricted-imports | ||
| import * as React from 'react'; | ||
| import * as jsxRuntime from 'react/jsx-runtime'; | ||
| // eslint-disable-next-line no-restricted-imports | ||
| import * as ReactDOM from 'react-dom'; | ||
|
|
||
| export interface MDXContentProps { | ||
| [key: string]: unknown; | ||
| components?: Record<string, ComponentType>; | ||
| } | ||
|
|
||
| /** | ||
| * Takes the compiled MDX code string from bundleMDX and returns a React component. | ||
| * | ||
| * @param code - The string of code you got from bundleMDX | ||
| * @param globals - Any variables your MDX needs to have accessible when it runs | ||
| * @returns A React component that renders the MDX content | ||
| */ | ||
| export function getMDXComponent( | ||
| code: string, | ||
| globals?: Record<string, unknown> | ||
| ): FunctionComponent<MDXContentProps> { | ||
| const mdxExport = getMDXExport(code, globals); | ||
| return mdxExport.default; | ||
| } | ||
|
|
||
| /** | ||
| * Takes the compiled MDX code string from bundleMDX and returns all exports. | ||
| * | ||
| * @param code - The string of code you got from bundleMDX | ||
| * @param globals - Any variables your MDX needs to have accessible when it runs | ||
| * @returns All exports from the MDX module, including the default component | ||
| */ | ||
| export function getMDXExport< | ||
| ExportedObject = {default: FunctionComponent<MDXContentProps>}, | ||
| >(code: string, globals?: Record<string, unknown>): ExportedObject { | ||
| const scope = { | ||
| React, | ||
| ReactDOM, | ||
| _jsx_runtime: jsxRuntime, | ||
| ...globals, | ||
| }; | ||
| // The MDX runtime requires dynamic function construction to evaluate compiled code | ||
| // eslint-disable-next-line @typescript-eslint/no-implied-eval, no-new-func | ||
| const fn = new Function(...Object.keys(scope), code); | ||
| return fn(...Object.values(scope)); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parameter descriptions render as plain text, not markdown
Medium Severity
API parameter descriptions are now rendered as plain text instead of being processed as markdown. The main API
descriptionMarkdownfield is pre-compiled to HTML at build time inresolveOpenAPI.ts, but parameter descriptions (path, query, body) receive no markdown processing. OpenAPI specs support CommonMark in description fields, so any markdown formatting like backticks, links, or emphasis in parameter descriptions will display as raw syntax instead of rendered HTML. This is inconsistent with howapiCategoryPage.tsxprocesses category descriptions withmarkdown2Html.