Skip to content

Conversation

@jleifeld
Copy link
Contributor

@jleifeld jleifeld commented Nov 26, 2025

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:

Bildschirmfoto 2025-12-01 um 17 01 11 Bildschirmfoto 2025-12-01 um 17 00 50

TODO:

  • improve non-direct import tree shaking (currently bundles other, unused CSS also)
  • Optimize bigger components

@jleifeld jleifeld self-assigned this Nov 26, 2025
@vercel
Copy link

vercel bot commented Nov 26, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
meteor-component-library Ready Ready Preview Comment Dec 9, 2025 3:23pm

- 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
Copy link

Copilot AI left a 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.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 9, 2025

Open in StackBlitz

@shopware-ag/meteor-admin-sdk

npm i https://pkg.pr.new/shopware/meteor/@shopware-ag/meteor-admin-sdk@979

@shopware-ag/meteor-component-library

npm i https://pkg.pr.new/shopware/meteor/@shopware-ag/meteor-component-library@979

@shopware-ag/meteor-icon-kit

npm i https://pkg.pr.new/shopware/meteor/@shopware-ag/meteor-icon-kit@979

@shopware-ag/meteor-prettier-config

npm i https://pkg.pr.new/shopware/meteor/@shopware-ag/meteor-prettier-config@979

@shopware-ag/stylelint-plugin-meteor

npm i https://pkg.pr.new/shopware/meteor/@shopware-ag/stylelint-plugin-meteor@979

@shopware-ag/meteor-tokens

npm i https://pkg.pr.new/shopware/meteor/@shopware-ag/meteor-tokens@979

commit: dddccfb

@jleifeld jleifeld marked this pull request as ready for review December 9, 2025 15:21
@jleifeld jleifeld enabled auto-merge (squash) December 9, 2025 15:21
@jleifeld jleifeld merged commit 0f9a318 into main Dec 9, 2025
9 checks passed
@jleifeld jleifeld deleted the improve-tree-shaking-behavior branch December 9, 2025 15:25
entry: {
index: path.resolve(__dirname, "src/index.ts"),
fonts: path.resolve(__dirname, "src/fonts.ts"),
...allComponents,
Copy link
Contributor

@bojanrajh bojanrajh Dec 30, 2025

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).

  1. 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'
  1. Related to externalizing vue-i18n - meteor uses "^9.9.1" which will be out of maintenance window in ... 🥁 ... 1 day :D Shopware uses 10.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.

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.

Improve tree shaking of bundled output

5 participants