-
Notifications
You must be signed in to change notification settings - Fork 13
Improve tree shaking behavior #979
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
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
684ef42 to
e58af9f
Compare
- Added vite-plugin-inspect for enhanced debugging capabilities. - Updated package.json to reflect new file paths for styles and fonts. - Modified Vite configuration to include external package handling and improved entry points. - Added new dependencies and updated existing ones in pnpm-lock.yaml. - Updated .gitignore to exclude .vite-inspect directory.
- Increased size limits for various components in .size-limit.ts to accommodate larger builds. - Updated package.json to correct file paths for styles and fonts. - Enhanced Vite configuration to include new components and improve external package handling. - Added 'onlyBuiltDependencies' to pnpm-workspace.yaml for better dependency management.
- Reduced size limits for various components in .size-limit.ts to optimize performance. - Refactored external package handling in vite.config.ts to streamline configuration.
- Added transformIgnorePatterns for lodash-es in jest.config.js to improve module handling. - Refactored .size-limit.ts for consistent formatting and added missing commas. - Updated Vite configuration for better readability and consistency in import statements. - Enhanced helper functions for component path resolution in build scripts.
…onent library because the final application bundle will handle the whole minifcation
…icon import path in mt-icon.vue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR improves tree-shaking behavior for the component library by implementing per-component builds and migrating from lodash to lodash-es. The changes enable better dead code elimination when consumers import individual components.
Key Changes:
- Configured Vite to build individual component entry points alongside the main bundle
- Added size-limit tooling to track and enforce bundle size limits
- Migrated admin-sdk from lodash to lodash-es for better ESM tree-shaking
Reviewed changes
Copilot reviewed 16 out of 17 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
pnpm-workspace.yaml |
Added esbuild to onlyBuiltDependencies for build optimization |
packages/component-library/vite.config.ts |
Configured multi-entry build with individual component exports and CSS injection |
packages/component-library/build/helper.ts |
Added helper functions for component discovery and CSS injection plugin |
packages/component-library/package.json |
Added wildcard exports, sideEffects configuration, and size-limit tooling |
packages/component-library/.size-limit.ts |
Configured bundle size limits for main bundle and key components |
packages/admin-sdk/package.json |
Migrated from lodash to lodash-es dependency |
packages/admin-sdk/src/**/*.ts |
Updated imports from lodash to lodash-es |
packages/admin-sdk/jest.config.js |
Added transformIgnorePatterns for lodash-es |
packages/component-library/src/components/form/mt-checkbox/mt-checkbox.vue |
Fixed CSS selector specificity |
.github/workflows/size-limit.yml |
Added CI workflow to validate bundle sizes |
packages/component-library/tsconfig.node.json |
Added build directory to includes |
packages/component-library/.gitignore |
Added build artifacts to ignore list |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (2)
packages/component-library/vite.config.ts:9
- Unused import Inspect.
import Inspect from "vite-plugin-inspect";
packages/component-library/vite.config.ts:14
- Unused variable pkg.
const pkg = JSON.parse(fs.readFileSync(path.resolve(__dirname, "package.json"), "utf-8"));
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…function in helper.ts
…n build configuration
packages/component-library/src/components/form/mt-checkbox/mt-checkbox.vue
Show resolved
Hide resolved
@shopware-ag/meteor-admin-sdk
@shopware-ag/meteor-component-library
@shopware-ag/meteor-icon-kit
@shopware-ag/meteor-prettier-config
@shopware-ag/stylelint-plugin-meteor
@shopware-ag/meteor-tokens
commit: |
| entry: { | ||
| index: path.resolve(__dirname, "src/index.ts"), | ||
| fonts: path.resolve(__dirname, "src/fonts.ts"), | ||
| ...allComponents, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jleifeld @Haberkamp Something here seems like a breaking change (v4.23.0 works okay).
- missing
.maps
WARN Failed to load source map for /www/shopware/community-hub/node_modules/.pnpm/@shopware-ag+meteor-component-library@4.24.0_@codemirror+autocomplete@6.19.0_@codemirror+comm_vgdykszbymclx32issykq4ho6e/node_modules/@shopware-ag/meteor-component-library/dist/mt-datepicker.css.
Error: An error occurred while trying to read the map file at main.css.map
Error: ENOENT: no such file or directory, open '/www/shopware/community-hub/node_modules/.pnpm/@shopware-ag+meteor-component-library@4.24.0_@codemirror+autocomplete@6.19.0_@codemirror+comm_vgdykszbymclx32issykq4ho6e/node_modules/@shopware-ag/meteor-component-library/dist/main.css.map'
- Related to externalizing
vue-i18n- meteor uses "^9.9.1" which will be out of maintenance window in ... 🥁 ... 1 day :D Shopware uses10.0.8, also out in 1 day.
Uncaught (in promise) SyntaxError: The requested module '/_nuxt/@fs/www/shopware/community-hub/node_modules/.pnpm/@intlify+core-base@11.2.7/node_modules/@intlify/core-base/dist/core-base.mjs?v=43652d33' does not provide an export named 'compileToFunction' (at vue-i18n.mjs:7:559)
■ Nuxt build error: RollupError: node_modules/.pnpm/vue-i18n@9.14.5_vue@3.5.26_typescript@5.9.3_/node_modules/vue-i18n/dist/vue-i18n.mjs (6:24): "incrementer" is not exported by "node_modules/.pnpm/@intlify+shared@10.0.8/node_modules/@intlify/shared/dist/shared.mjs", imported by "node_modules/.pnpm/vue-i18n@9.14.5_vue@3.5.26_typescript@5.9.3_/node_modules/vue-i18n/dist/vue-i18n.mjs".
│ file: /www/shopware/community-hub/node_modules/.pnpm/vue-i18n@9.14.5_vue@3.5.26_typescript@5.9.3_/node_modules/vue-i18n/dist/vue-i18n.mjs:6:24
npm why vue-i18n
vue-i18n@9.14.5
node_modules/.pnpm/vue-i18n@9.14.5_vue@3.5.26_typescript@5.9.3_/node_modules/vue-i18n
vue-i18n@9.14.5
node_modules/.pnpm/@shopware-ag+meteor-component-library@4.23.0_@codemirror+autocomplete@6.19.0_@codemirror+comm_kfwwtvppwyepxbvyiiecimveua/node_modules/vue-i18n
vue-i18n@"^9.9.1" from @shopware-ag/meteor-component-library@4.23.0
node_modules/.pnpm/@shopware-ag+meteor-component-library@4.23.0_@codemirror+autocomplete@6.19.0_@codemirror+comm_kfwwtvppwyepxbvyiiecimveua/node_modules/@shopware-ag/meteor-component-library
@shopware-ag/meteor-component-library@4.23.0
node_modules/@shopware-ag/meteor-component-library
@shopware-ag/meteor-component-library@"4.23.0" from the root project
Didn't find a solution for this yet.
What?
Fixes #978
Testing?
See the GH action which validates and checks the bundled output files. Also check the results here: shopware/shopware#13798
Current result:
TODO: