Skip to content

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

Closed

Conversation

keithamus
Copy link
Contributor

@keithamus keithamus commented Sep 20, 2022

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

  • Added/updated tests (N/A)
  • Added/updated documentation (N/A)
  • Tested in Chrome
  • Tested in Firefox
  • Tested in Safari
  • Tested in Edge

Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.

@keithamus keithamus requested review from a team and colebemis September 20, 2022 10:16
@changeset-bot
Copy link

changeset-bot bot commented Sep 20, 2022

⚠️ No Changeset found

Latest commit: 75645c3

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Sep 20, 2022

size-limit report 📦

Path Size
dist/browser.esm.js 78.84 KB (0%)
dist/browser.umd.js 79.49 KB (0%)

@@ -1,4 +1,5 @@
import React, {forwardRef, useImperativeHandle, useRef, useEffect} from 'react'
import React, {forwardRef, useImperativeHandle, useRef} from 'react'
import '@github/markdown-toolbar-element'
Copy link
Member

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.

Copy link
Contributor Author

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]>
@koddsson koddsson temporarily deployed to github-pages November 4, 2022 13:55 Inactive
@github-actions
Copy link
Contributor

github-actions bot commented Jan 3, 2023

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.

@github-actions github-actions bot added the Stale label Jan 3, 2023
@github-actions github-actions bot closed this Jan 10, 2023
@github-actions github-actions bot deleted the move-markdown-toolbar-element-into-uncodnitional-render branch January 10, 2023 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants