Because Select2 and therefore SelectWoo, wraps the module in the UMD loader pattern, importing it returns an initialisation function as seen in the source here:
Because Meteor uses a Common JS environment on the client, you will need to import the initialisation function and pass it it’s dependencies:
import selectWoo from 'selectwoo/dist/js/selectWoo.js';
// May need to import jQuery
selectWoo(window, jQuery)
I haven’t tested this, but I think this should work.
The other alternative is to replace the call to require('jQuery') in their loader with the correct path for your app.
Which if you’re using Meteor’s jQuery package is require('meteor/jquery')
Thanks alot for your detailed explanation. Very useful
working perfectly
Can I ask you another import question ?
I planned to use the bootstrap package from twbs. But version 4.0.0 is not functional, it still lacks dependencies (Popper.js and some others).
So I wanted to import it myself with the same method. And it works … But …
DevTools failed to parse SourceMap: http://localhost:3000/category/bootstrap.css.map
DevTools failed to parse SourceMap: http://localhost:3000/category/bootstrap-grid.css.map
I got theses messages in the console. From what I know this is related to the css preprocessor, and this is theses files which allow to debug css much easily, because currently, it’s hard to identify where the class is…
it do not provide the file or line related…
I try to import it like a css… but it’s not working.
Is there a good way to import theses files in meteor ?