Skip to content

Migrate off of compound components to standalone components #2464

@viktorrusakov

Description

@viktorrusakov

As was discovered by #2425, compound components that are extensively used by Paragon do not support tree-shaking (e.g., importing Form component would also include From.Group component into the resulting bundle even if From.Group is not explicitly used in the code, same goes for all Form.<subcomponentName> components). This negatively impacts bundles sizes of consuming applications.

It appears that there is no way to support tree-shaking for compound components (that's because all of the Form.<subcomponentName> components are part of the Form object so you have to bring them all into the bundle if you import Form), that's why popular component libraries (e.g. Material UI, Chakra UI) do not have compound components in their code, instead they utilize standalone components.

We should remove compound components from Paragon to provide best performance possible to consumers. This will result in a breaking change, so we should also provide a CLI command to ease migration.

### Tasks
- [ ] Ensure that Paragon no longer uses compound components in the code and instead exports only standalone components (e.g. `Form` should no longer have `Form.Group` component, instead this component should be exported under `FormGroup` name)
- [ ] Create a CLI command that replaces all compound components' usages with their standalone counterpart (e.g. `Form.Group` is replaced with `FormGroup` across all code)
- [ ] Verify all react-bootstrap imports pull from standalone components rather than root import

Metadata

Metadata

Assignees

Labels

best addressed by breaking changecode healthProactive technical investment via refactorings, removals, etc.enhancementRelates to new features or improvements to existing features

Type

No type

Projects

Status

Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions