Skip to content

Add ESM Support#12

Merged
MikeAlhayek merged 3 commits into
mainfrom
ma/use-esm
Jun 16, 2026
Merged

Add ESM Support#12
MikeAlhayek merged 3 commits into
mainfrom
ma/use-esm

Conversation

@MikeAlhayek

@MikeAlhayek MikeAlhayek commented Jun 16, 2026

Copy link
Copy Markdown
Member

This pull request introduces significant improvements to both the build process and documentation for @crestapps/bootstrap-select. The main focus is on supporting multiple JavaScript module formats (ESM, CommonJS, and UMD), clarifying usage instructions for each format, and enhancing documentation with new sections, examples, and clearer organization. Additionally, new features and documentation for selection indicators and events are added.

Build system and module format enhancements:

  • Refactored the build process in Gruntfile.js to explicitly list source files, and added new build targets for ESM (.esm.mjs) and CommonJS (.cjs) outputs, in addition to the existing UMD/browser build. This ensures the package now ships with three distinct, first-class JavaScript entry styles for modern and legacy toolchains. [1] [2] [3]
  • Updated the versioned CDN references in README.md to reflect the new release and clarified usage instructions for each module format, including code examples for ESM, CommonJS, and browser-global usage.

Documentation improvements:

  • Added a new "Package formats" section in README.md to guide users on when and how to use each JavaScript module format, with detailed examples and caveats.
  • Introduced a comprehensive "Events" documentation page (docs/content/events.mdx), listing all custom events emitted by bootstrap-select, their usage, and event details.
  • Expanded the "Examples" documentation (docs/content/examples.mdx) with a new topical organization, additional live examples for selection indicators (checkmark/radio/checkbox), and clarified workflows for search, multi-select, and tag-style pickers. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14]
  • Documented the new selection indicator options in both README.md and examples, showing how to use show-tick and data-selection-indicator="checkbox" for different selection patterns.

Minor updates:

  • Updated version references and clarified the recommendation to pin explicit package versions in production.
  • Added a link to the new "Events" documentation in the main documentation navigation.
  • Adjusted the Gruntfile to use bootstrap-select.api.js for version stamping.

These changes make the package easier to integrate with modern build tools, provide clearer guidance for users, and improve the documentation experience for both new and existing users.

MikeAlhayek and others added 3 commits June 16, 2026 08:40
Split the ~3000-line bootstrap-select.js into 11 focused source files:
- helpers.js (246 lines): DOM utilities, sanitizer, data parsing
- search.js (166 lines): search/filter/normalization logic
- constants.js (309 lines): keycodes, classnames, element templates
- class.js (351 lines): constructor, event helpers, init, createDropdown
- virtual-scroll.js (364 lines): virtual scroll/view management
- data.js (309 lines): fetchData, buildData, buildList
- render.js (443 lines): render, syncTagEditor, option UI
- sizing.js (492 lines): liHeight, setSize, positioning, state mgmt
- interaction.js (432 lines): click/search event listeners
- api.js (579 lines): public API, keyboard nav, lifecycle, statics
- runtime.js (72 lines): auto-init, global exposure control

Added multi-format build support:
- ESM (.mjs) for modern bundlers
- CJS (.cjs) for Node.js require()
- UMD (.js) for browser globals/CDN

Updated package.json exports map, README, and docs with usage
examples for all three consumption styles. All 22 tests passing.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@MikeAlhayek MikeAlhayek merged commit 306540c into main Jun 16, 2026
4 checks passed
@MikeAlhayek MikeAlhayek deleted the ma/use-esm branch June 16, 2026 23:01
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.

1 participant