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

feat!: library rewrite #54

Merged
merged 19 commits into from
Mar 23, 2024
Merged

feat!: library rewrite #54

merged 19 commits into from
Mar 23, 2024

Conversation

metonym
Copy link
Collaborator

@metonym metonym commented Mar 16, 2024

Closes #50, closes #44, closes #46, closes #53, closes #52, closes #48, closes #47, closes #46, closes #40, closes #26, closes #24, closes #19, closes #18, closes #17, closes #28

Breaking Changes

  • Remove all preprocessors except for optimizeImports
  • optimizeImports: drop support for carbon-icons-svelte version 10, carbon-pictograms-svelte version 10
  • Rewrite optimizeCss plugin from scratch; it's now offered as a Vite/Rollup/Webpack plugin. carbon-components-svelte@0.85.0 or greater is required

optimizeImports

  • Completely re-written imports optimizer
  • Only supports latest major versions of icons/pictgrams

Notes: for best DX, also instruct Vite to optimizeDeps.ignore

optimizeCss

  • Vite/Rollup plugin, enforced in build phase

Steps:

The potential for false positives is too high (relying on any and all selectors). Instead, focus on class names as this is much more defensive (e.g., .bx--). The goal is to still remove the bulk of unused .bx-- selectors without needing to stress about false positives.

  1. Pre-index the used class names per Carbon component.
  2. Gather the resolved component names in the plugin.transform hook.
  3. In the generateBundle hook, read in all generated .css files.
  4. Traverse the CSS AST and remove all .bx-- selectors that are not included in the map.

@metonym metonym force-pushed the rewrite-preprocessor branch 18 times, most recently from 8e36b7b to e85c028 Compare March 17, 2024 20:55
@metonym metonym force-pushed the rewrite-preprocessor branch from e85c028 to c24d2fe Compare March 17, 2024 20:57
@metonym
Copy link
Collaborator Author

metonym commented Mar 18, 2024

What's blocking this PR is that some Carbon components that employ custom styling (e.g., HeaderSearch) does not correctly prune this.

@metonym metonym marked this pull request as ready for review March 23, 2024 21:18
@metonym metonym changed the title feat!: rewrite feat!: library rewrite Mar 23, 2024
@metonym metonym merged commit 2523bef into main Mar 23, 2024
1 check passed
@metonym metonym deleted the rewrite-preprocessor branch March 23, 2024 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment