I'm working on a symfony 5.4 application that uses webpack / encore. I want to use the tomselect javascript plugin. i installed it with yarn and want to import it somehow in app.js but it doesn't work.
I tryed this ways in app.js:
TomSelect = window.TomSelect = require('tom-select');
and
import {TomSelect} from 'tom-select'
and
import TomSelect from "tom-select/dist/js/tom-select.complete.min.js";
and I write this in the html.twig files:
{% block javascripts %}
{{ parent() }}
<script>
new TomSelect('select', {});
</script>
{% endblock %}
I always get the error in browser's javascript console:
Uncaught ReferenceError: TomSelect is not defined
but if I import this way, TomSelect is work:
<script src="https://cdnjs.cloudflare.com/ajax/libs/tom-select/2.0.1/js/tom-select.complete.js"></script>
<script>
new TomSelect('select', {});
</script>
So what should I write in app.js to make tomselect work?