Skip to content

chore: remove SwMedia3D component from autoload #2273

Open
Maciej D (mdanilowicz) wants to merge 2 commits intomainfrom
feat/GH-2272
Open

chore: remove SwMedia3D component from autoload #2273
Maciej D (mdanilowicz) wants to merge 2 commits intomainfrom
feat/GH-2272

Conversation

@mdanilowicz
Copy link
Contributor

@mdanilowicz Maciej D (mdanilowicz) commented Feb 7, 2026

This pull request updates the @shopware/cms-base-layer package to prevent the heavy 3D component SwMedia3D.vue from 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/nuxt and use dynamic imports for SwMedia3D.

Component loading and bundle optimization:

  • Updated nuxt.config.ts to exclude SwMedia3D.vue from auto-import by removing @tresjs/nuxt from the default modules and adding a hook to filter out SwMedia3D from the components list. This prevents unnecessary bundling of heavy 3D libraries.
  • Added documentation and guidance in nuxt.config.ts comments on how to enable 3D support if needed, including instructions to use defineAsyncComponent for dynamic imports.

Changelog:

  • Added a changeset describing the removal of SwMedia3D.vue from autoload in the @shopware/cms-base-layer package.

closes #2272

Before
Screenshot 2026-02-07 at 12 00 23

After
Screenshot 2026-02-07 at 12 14 56

…g.ts to prevent bundling of heavy 3D libraries
@vercel
Copy link

vercel bot commented Feb 7, 2026

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

Project Deployment Actions Updated (UTC)
frontends-starter-template-extended Ready Ready Preview, Comment Feb 7, 2026 11:46am
frontends-vue-starter-template Building Building Preview, Comment Feb 7, 2026 11:46am
old-frontends-demo Building Building Preview, Comment Feb 7, 2026 11:46am
shopware-frontends-docs Ready Ready Preview, Comment Feb 7, 2026 11:46am

Request Review

Copy link
Contributor

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 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/nuxt from the layer’s default modules list.
  • Added a components:extend hook to exclude SwMedia3D from 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.

Comment on lines +8 to +11
// @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.
Copy link

Copilot AI Feb 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Suggested change
// @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.

Copilot uses AI. Check for mistakes.
@BrocksiNet
Copy link
Contributor

Love it, just wondering if there are other places where we should mention that?
For example, on the templates page in docs?

Copy link
Contributor

@patzick Patryk Tomczyk (patzick) left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 👍

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.

Analyze the init bundle size and check if it's possible to make it smaller

3 participants

Comments