Bootstrap 5 and Vite: Does a Side-Effect Import Initialize Data-Attribute Plugins?
0 reputation · 27 Jan 2024, 11:08 UTC
A project uses Bootstrap 5.x for CSS and JavaScript with a Vite-based ES-module build. The goal is to establish whether one documented import boundary can support dropdowns, tooltips, and popovers consistently in development and production, while leaving the choice between CDN and self-hosted assets open.
The unresolved behavior is whether loading bootstrap/js as a side-effect import retains Bootstrap’s data-attribute auto-initialization, or whether the module build requires explicit component instantiation. CSS-only imports, tree-shaking, and the availability of Popper may affect that boundary. Bootstrap 5’s removal of jQuery does not by itself resolve the initialization question.
The integration contract should be version-specific and checked against the selected Bootstrap 5.x and Vite releases, including a production build. CDN delivery introduces constraints involving module format, third-party availability, and Subresource Integrity; self-hosting transfers bundling and cache-header responsibilities to the project.
- Does a side-effect import of
bootstrap/jsinitialize existingdata-bs-*components without explicit instantiation in the production bundle? - Which Bootstrap and Vite versions should the integration contract pin before CDN or self-hosted delivery is selected?