github / github/markdown-toolbar-element

Element should not auto-register itself unless a browser context is found

Aperta
#68 8 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
JavaScript
Stelle
411
Fork
60
Merge medio
2g 22h
PR unite (30g)
6

Descrizione

Per discussion in https://github.com/primer/react/pull/2339, the fact that this element automatically registers itself at the top level makes it incompatible with server-side rendering, where JavaScript might be run outside of a browser context.

> From an SSR perspective, adding a simple `typeof window !== 'undefined'` guard should be sufficient. However, that won't solve the fact that the markdown-toolbar-element currently executes with side-effects, and thus cannot be tree-shaken. This means bundles in dotcom that do not need toolbar element will carry it as extra weight that is not needed. We would need to add a `register()` function to allow tree shaking, which would be a breaking change on the web component package.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Start by reading the discussion in pull request 2339 and the registration behavior described in this issue. Define whether the change should only guard browser access or also introduce an explicit register() API; done should address server-side rendering and avoid unnecessary toolbar-element side effects without leaving the package behavior unresolved.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
javascript
Ambito
frontend, web-dev
Tipo di issue
Refactoring
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
28/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.