-
Notifications
You must be signed in to change notification settings - Fork 610
move markdown-toolbar-element into unconditional render #2353
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
move markdown-toolbar-element into unconditional render #2353
Conversation
|
size-limit report 📦
|
@@ -1,4 +1,5 @@ | |||
import React, {forwardRef, useImperativeHandle, useRef, useEffect} from 'react' | |||
import React, {forwardRef, useImperativeHandle, useRef} from 'react' | |||
import '@github/markdown-toolbar-element' |
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.
Just wanted to double-check, I think one intent behind the condition is to allow for SSR. With this change, I believe SSR would no longer work because @github/markdown-toolbar-element
references globals like HTMLElement
and tries to register itself using if (!window.customElements.get('...'))
when imported.
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.
That's correct. I think as we look more towards SSR we can look to centralise these dependencies into a client-side only bundle.
* Don't crash when building docs * Remove import again after bad merge * Replace require call with a dynamic import * Disable prettier rule * Revert "Replace require call with a dynamic import" This reverts commit 4247039. See nodejs/node#35889 * Wrap `@github/markdown-toolbar-element` require in `useEffect` Co-authored-by: Josh Black <[email protected]> * Don't evaluate on every render Co-authored-by: Matthew Costabile <[email protected]> Co-authored-by: Josh Black <[email protected]> Co-authored-by: Matthew Costabile <[email protected]>
Hi! This pull request has been marked as stale because it has been open with no activity for 60 days. You can comment on the pull request or remove the stale label to keep it open. If you do nothing, this pull request will be closed in 7 days. |
This moves the import of
markdown-toolbar-element
out of a conditional, which seems to be causing SegFaults due to poor support of ESM modules in various tools like Jest. Moving the import out of the conditional allows these tools to pick up the import which resolves segfaults.We may want to move all web component definitions to a central file;
github/github
could de-duplicate these imports as it already imports them via PVC or via direct imports.Closes #2339, refs #2334
Merge checklist
Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.