Skip to content
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

POC: defining custom elements in the wc, passing to app #33

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

elliotBraem
Copy link
Contributor

-- DO NOT MERGE --

image

This is a small proof of concept exploring a how to simplify development of new near-bos-webcomponents that offer unique custom elements and nothing else.

Here is a quick rundown:

  1. Several projects use near-bos-wc as a starter template to offer and deploy their own custom elements (tldraw Canvas, livepeer Player & Broadcast, etc) -- these apps do not change anything else about the web component, only the custom elements that are offered.
  2. Keeping up to date with the core, stable near-bos-wc can be difficult needing to rebase unrelated, but necessary changes
  3. The app that holds the VM is becoming increasingly black-boxed, and in this POC, creating a new web component that offers unique custom elements would only need to extend and publish a version of the html element itself, rather than the underlying app.

Highlights of this solution

  1. This passes "customElements" as props from the element definition to the "App" that uses them.
  2. The "App" with near-social-vm installed can be separately bundled and pulled in from CDN, meaning easier updates and releases to the core functionality, while also enabling freedom to swap it out and completely change how it works (what if a version of the VM was made to expect HTMLElement customElements instead of React.Components? Would maintain the same interface and should pass the same regression tests)
  3. Because of these unique custom elements, these web components should probably be named something other than "near-social-viewer" and should maintain their own releases. Maybe further simplification is to extend the NearSocialViewerElement class, to enforce uniformity.

Possible next steps

  • Separately bundle and distribute the App with near-social-vm
  • export NearSocialViewerElement class for easy extension
  • How can we leverage ES modules more?

Please let me know what you think and if this direction should be pursued!

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.

1 participant