BuilderIO / BuilderIO/mitosis

webcomponents: unnecessary wrappers

Open
#284 9 comments 3 reactions 0 assignees View on GitHub
enhancement web-components
Dominant language
TypeScript
Stars
14.4k
Forks
672
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
[The outcome](https://mitosis.builder.io/?outputTab=webcomponents) produces a `builder-component` which wouldn't exist in the React counterpart, meaning that each component will result in DOM bloat for no reason, nor benefits.

**To Reproduce**
Steps to reproduce the behavior:
1. visit [this demo example](https://mitosis.builder.io/?outputTab=webcomponents)
2. inspect the DOM
3. note `builder-component` wraps the DIV, which is the only thing React would render instead

**Expected behavior**
A `div` builtin extend that `is="builder-component-xxx"` where `xxx` is the unique relation between the `MyComponent` function and the outcome in the DOM.

**Additional context**
The only way to represent React output as Custom Element is to use builtin extends, available in every browser but Safari, which can easily be [polyfilled if necessary](https://github.com/ungap/custom-elements) in case `window.safari` or `window.webkit` exists, through import maps or ad-hoc builds for these targets.

The output should be a custom elements which represents what the React function would return and update its state/view whenever a state is triggered.

This is because **it's impossible otherwise to represent special nodes** such as `td`, `li`, `tr`, `option`, or others, if these get wrapped by unrelated nodes.

Changing `div` with `td` as returned node will indeed fail.

Contributor guide

Open the contributing guide

Research direction

Start with the linked Builder demo and inspect the generated webcomponents DOM alongside the React output. No source files or tests are named; completion should avoid the unnecessary builder-component wrapper while preserving state updates and support for special nodes such as td, li, tr, and option.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
compilers, web-dev
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.