Add ESM Support#12
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
Gruntfile.jsto 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]README.mdto reflect the new release and clarified usage instructions for each module format, including code examples for ESM, CommonJS, and browser-global usage.Documentation improvements:
README.mdto guide users on when and how to use each JavaScript module format, with detailed examples and caveats.docs/content/events.mdx), listing all custom events emitted by bootstrap-select, their usage, and event details.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]README.mdand examples, showing how to useshow-tickanddata-selection-indicator="checkbox"for different selection patterns.Minor updates:
bootstrap-select.api.jsfor 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.