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

fix(optimize-css): indexing should account for nested components #77

Merged
merged 2 commits into from
Jan 19, 2025

Conversation

metonym
Copy link
Collaborator

@metonym metonym commented Jan 19, 2025

The optimize CSS plugin uses a pre-computed index of Carbon components (exported from the barrel file) to determine what classes to prune.

However, most components compose other components. These sub-components (are their sub-components) must be accounted for.

An example would be a selectable DataTable:

<DataTable selectable />

The checkboxes for DataTable are a bespoke, internal-facing component. The optimize plugin does not include the bespoke checkbox styles.

The solution is to:

  • Record a list of sub-component references when extracting selectors from a component.
  • If a component has a list of sub-components, append the additional selectors after all files have been processed.

@metonym metonym force-pushed the fix-nested-components branch 2 times, most recently from 2840941 to bf0718a Compare January 19, 2025 20:40
@metonym metonym force-pushed the fix-nested-components branch from bf0718a to 6ab656e Compare January 19, 2025 21:11
@metonym metonym force-pushed the fix-nested-components branch from 6ab656e to 196f162 Compare January 19, 2025 21:13
@metonym metonym merged commit 87f1b85 into main Jan 19, 2025
1 check passed
@metonym metonym deleted the fix-nested-components branch January 19, 2025 21:14
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