Skip to content

v5.4.1 - #335

Merged
palcarazm merged 3 commits into
v5from
develop/5.4.1
Jun 28, 2026
Merged

v5.4.1#335
palcarazm merged 3 commits into
v5from
develop/5.4.1

Conversation

@palcarazm

@palcarazm palcarazm commented Jun 28, 2026 •

Copy link
Copy Markdown
Owner

Change Summary

Indicate the type of change being made.

  • New Feature
  • Bug Fix
  • Refactor
  • Documentation

Description

Bug Fix: Tree-shaking removes DOM-initializing side-effects (#334)

This PR fixes an issue where the DOM-initializing side-effect that registers bootstrapToggle on HTMLInputElement.prototype was being removed by tree-shaking in ESM/bundler environments (Vite, Webpack, Rollup, etc.).

The Problem
When importing the full bundle via import 'bootstrap5-toggle/js/bootstrap5-toggle.ecmas.js', bundlers would tree-shake the side-effect that patches HTMLInputElement.prototype.bootstrapToggle. This resulted in:

TypeError: element.bootstrapToggle is not a function

The workaround of new BootstrapToggle(element) still worked, confirming that only the prototype-patching side-effect was being eliminated.

The Fix

  • Updated sideEffects in package.json to mark CSS and JS files as side-effectful:
    "sideEffects": [
      "css/*.css",
      "js/*.js"
    ]

Related Issues


Test Coverage

Indicate whether you have added, modified, fixed, or removed tests.

  • Added tests
  • Modified tests
  • Fixed tests
  • Removed tests

Documentation Changes

Indicate whether any documentation has been updated.

  • Documentation updated

Note: No documentation updates included in this PR. The fix is internal and does not change the public API.


Additional Notes

Breaking Changes: None - this is a patch release.


Pull Request Checklist

  • Code adheres to the project's coding style guide
  • All tests are passing
  • The pull request description is complete
  • Documentation is updated if needed (not applicable for this change)

@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 95.217%. remained the same — develop/5.4.1 into v5

@sonarqubecloud

Copy link
Copy Markdown

@palcarazm
palcarazm merged commit 270958e into v5 Jun 28, 2026
16 of 18 checks passed
@palcarazm
palcarazm deleted the develop/5.4.1 branch June 28, 2026 12:36
@github-project-automation github-project-automation Bot moved this from To do to Done in Pull Request Jun 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Tree‑shaking removes DOM‑initializing side‑effects, breaking element.bootstrapToggle() when imported via bundlers

2 participants