Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
neSpecc
left a comment
There was a problem hiding this comment.
How tree-shaking works for components?
For Components
When user imports: import { Button, Avatar } from '@codexteam/ui/vue';Bundler analyzes and includes ONLY:
All other components (Editor, Input, Chart, etc.) are completely eliminated from the final bundle. For ThemesSimilar approach - each theme is a separate CSS file: import '@codexteam/ui/styles/themes/pure'; // Only pure theme included
import '@codexteam/ui/styles/themes/grass'; // Only grass |
There was a problem hiding this comment.
Pull request overview
This pull request implements tree-shaking support for the @codexteam/ui package, allowing consumers to import only the components and themes they need to reduce bundle size. The implementation restructures the build configuration to split CSS files and preserve module structure.
Changes:
- Enabled CSS code splitting and module preservation in Vite build configuration
- Separated theme CSS files into individual importable modules
- Converted several Vue components to use CSS modules (ThemePreview, Tabbar, Editor, Counter, Chart, ChartLine)
- Updated package.json exports to expose individual theme files and TypeScript types
- Moved font imports to separate fonts.pcss file
- Updated documentation with tree-shaking usage examples
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| @codexteam/ui/vite.config.ts | Enabled CSS code splitting, added individual theme entries, configured module preservation for tree-shaking |
| @codexteam/ui/tsconfig.dts.json | Updated TypeScript declaration output directory structure |
| @codexteam/ui/package.json | Added version bump, sideEffects configuration, individual theme exports, and TypeScript types path |
| @codexteam/ui/src/styles/index.pcss | Removed themes import to enable individual theme imports |
| @codexteam/ui/src/styles/typography.pcss | Removed font imports (moved to separate file) |
| @codexteam/ui/src/styles/fonts.pcss | Created new file with font imports for separate loading |
| @codexteam/ui/src/vue/components/*/**.vue | Converted multiple components to use CSS modules for better encapsulation |
| @codexteam/ui/README.md | Updated documentation with tree-shaking examples and usage instructions |
| @codexteam/ui/.gitignore | Added comprehensive gitignore patterns |
| @codexteam/ui/.npmignore | Added test-app to ignored files |
| @codexteam/ui/dev/index.html | Updated dev environment to import fonts and themes separately |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
@codexteam/ui/src/vue/components/theme-preview/ThemePreview.vue
Outdated
Show resolved
Hide resolved
1259e00 to
3871411
Compare
3871411 to
d74382a
Compare
Tree-shaking Support for @codexteam/ui
Description
Implementation package
Example
main.ts
app.vue
Compare the results with and without tree-shaking