chore: remove SwMedia3D component from autoload #2273
chore: remove SwMedia3D component from autoload #2273Maciej D (mdanilowicz) wants to merge 2 commits intomainfrom
Conversation
…g.ts to prevent bundling of heavy 3D libraries
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
This PR updates the @shopware/cms-base-layer Nuxt layer configuration to stop auto-registering/bundling the heavy SwMedia3D.vue component by default, aiming to reduce initial bundle size and only load 3D-related code when explicitly enabled.
Changes:
- Removed
@tresjs/nuxtfrom the layer’s defaultmoduleslist. - Added a
components:extendhook to excludeSwMedia3Dfrom Nuxt auto-components registration. - Added a changeset entry documenting the change.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/cms-base-layer/nuxt.config.ts | Stops default 3D module inclusion and filters SwMedia3D out of component autoload. |
| .changeset/fresh-pianos-act.md | Adds release note/version bump entry for removing SwMedia3D from autoload. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // @tresjs/nuxt is not included here because SwMedia3D is excluded from auto-import | ||
| // to prevent bundling heavy 3D libraries in the initial bundle. | ||
| // If you need 3D support, add "@tresjs/nuxt" to your app's nuxt.config.ts modules array | ||
| // and dynamically import SwMedia3D using defineAsyncComponent. |
There was a problem hiding this comment.
The guidance for enabling 3D support is incomplete: SwMedia3D.vue relies on components (e.g., TresPerspectiveCamera/TresDirectionalLight) that are provided via the @tresjs/nuxt module, so without enabling that module the dynamically imported component will fail at runtime. Consider explicitly documenting that consumers must both enable the @tresjs/nuxt module and ensure it is installed/available in their app (important for strict package managers like pnpm where transitive deps may not be resolvable from the app config).
| // @tresjs/nuxt is not included here because SwMedia3D is excluded from auto-import | |
| // to prevent bundling heavy 3D libraries in the initial bundle. | |
| // If you need 3D support, add "@tresjs/nuxt" to your app's nuxt.config.ts modules array | |
| // and dynamically import SwMedia3D using defineAsyncComponent. | |
| // 3D support (SwMedia3D) relies on components provided by the @tresjs/nuxt module. | |
| // This layer does NOT enable @tresjs/nuxt by default because SwMedia3D is excluded | |
| // from auto-import to avoid bundling heavy 3D libraries in the initial bundle. | |
| // If you need 3D support in your app, you MUST: | |
| // 1) Install "@tresjs/nuxt" (and any required Tres peer deps) as direct dependencies | |
| // of your application (important for strict package managers like pnpm). | |
| // 2) Add "@tresjs/nuxt" to your app's nuxt.config.ts `modules` array. | |
| // 3) Dynamically import SwMedia3D using defineAsyncComponent where it is used. |
|
Love it, just wondering if there are other places where we should mention that? |
Patryk Tomczyk (patzick)
left a comment
There was a problem hiding this comment.
Looks good but as Björn Meyer (@BrocksiNet) mentioned - that should be put in docs and readme so it's clear how to use it
leaving approve as can be merged after adding it 👍
This pull request updates the
@shopware/cms-base-layerpackage to prevent the heavy 3D componentSwMedia3D.vuefrom being auto-imported and bundled by default. This reduces the initial bundle size and ensures that 3D libraries are only loaded when explicitly needed. If 3D support is required, developers are instructed to manually add@tresjs/nuxtand use dynamic imports forSwMedia3D.Component loading and bundle optimization:
nuxt.config.tsto excludeSwMedia3D.vuefrom auto-import by removing@tresjs/nuxtfrom the default modules and adding a hook to filter outSwMedia3Dfrom the components list. This prevents unnecessary bundling of heavy 3D libraries.nuxt.config.tscomments on how to enable 3D support if needed, including instructions to usedefineAsyncComponentfor dynamic imports.Changelog:
SwMedia3D.vuefrom autoload in the@shopware/cms-base-layerpackage.closes #2272
Before

After
