Skip to content

MultiSelect class not usable as ES module (missing export) #17

@theo-dep

Description

@theo-dep

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch multi-select-dropdown-js@1.0.3 for the project I'm working on.

The issue is that MultiSelect.js declares the class without exporting it, which makes it impossible to use in native ESM environments (browser without bundler, or bundlers like Rollup/Vite) without relying on window.MultiSelect as a side effect, which doesn't work in ESM module scope.

Adding export default MultiSelect; or export { MultiSelect }; at the end of the file would make the library usable as a proper ES module while keeping full backward compatibility with the existing auto-init behavior (document.querySelectorAll('[data-multi-select]')...).

Here is the diff that solved my problem:

diff --git a/node_modules/multi-select-dropdown-js/MultiSelect.js b/node_modules/multi-select-dropdown-js/MultiSelect.js
index 390ac78..cbf79d2 100644
--- a/node_modules/multi-select-dropdown-js/MultiSelect.js
+++ b/node_modules/multi-select-dropdown-js/MultiSelect.js
@@ -672,3 +672,4 @@ class MultiSelect {
 }
 
 document.querySelectorAll('[data-multi-select]').forEach(select => new MultiSelect(select));
+export default MultiSelect;

This issue body was partially generated by patch-package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions