Can I use Select2 with my AMD or CommonJS loader?

Yes, Select2 should work with most AMD or CommonJS loaders without any issues.

How do I tell Select2 where to look for modules?

For most AMD and CommonJS setups, the location of the data files used by Select2 will be automatically determined and handled without you needing to do anything.

If you are using Select2 in a build environment where preexisting module names are changed during a build step, Select2 may not be able to find optional dependencies or language files. You can manually set the prefixes to use for these files using the amdBase and amdLanugageBase options.

$.fn.select2.defaults.set('amdBase', 'select2/');
$.fn.select2.defaults.set('amdLanguageBase', 'select2/i18n/');

Select2 is being placed before jQuery in my JavaScript file

Due to a bug in older versions of the r.js build tool, Select2 was sometimes placed before jQuery in then compiled build file. Because of this, Select2 will trigger an error because it won't be able to find or load jQuery.

You can fix this issue by upgrading to a newer version of the r.js build tool.