leongersen / noUiSlider

noUiSlider is a lightweight, ARIA-accessible JavaScript range slider with multi-touch and keyboard support. It is fully GPU animated: no reflows, so it is fast; even on older devices. It also fits wonderfully in responsive designs and has no dependencies.
https://refreshless.com/nouislider/
MIT License
5.66k stars 659 forks source link

ESM/ES6 module support #1149

Closed cdalexndr closed 3 years ago

cdalexndr commented 3 years ago

Please provide esm module distribution.

leongersen commented 3 years ago

Could you add some details on your use case?

ivoevolution commented 3 years ago

we need to

import noUiSlider from 'noUiSlider'

//...
leongersen commented 3 years ago

@ivoevolution You can currently do that:

// Either import the default:
import noUiSlider from 'nouislider';
// Or the namespace:
import * as noUiSlider from 'nouislider';
cdalexndr commented 3 years ago

@ivoevolution You can currently do that:

Without any javascript bundler, directly in browser:

<script type="module">
    import noUiSlider from 'nouislider.js'; //auto loads nouislider.js
</script>

For this to work, the distributed javascript must have esm compliant export statements. Other libraries build a separate .esm.js & min file, with this specificaiton.

leongersen commented 3 years ago

Ah, right. I'm open to a PR adding these distribution files.

leongersen commented 3 years ago

As of noUiSlider 15.4.0 the distribution offers nouislider.mjs and nouislider.min.mjs. You can see the module import in action here. Thank you for contributing!

github-actions[bot] commented 2 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.