humaan / Modaal

An accessible dialog window library for all humans.
http://humaan.com/modaal/
MIT License
2.72k stars 183 forks source link

Support ES6 loading #139

Open jurchiks opened 2 years ago

jurchiks commented 2 years ago

Currently it is impossible to load this plugin when building sources using, e.g. gulp, because import 'modaal' fails with Uncaught ReferenceError: jQuery is undefined, even if you have code like this:

import $ from 'jquery'; <-- This does not define window.jQuery when building code in Node.
import 'modaal'; <-- This subsequently does not have access to a global jQuery object.

I've found a pretty nice workaround for this, but it requires changes in your source code, there's nothing I can do in my code to make it work: https://gist.github.com/monkeymonk/c08cb040431f89f99928132ca221d647 This can obviously be merged into a single JS file, the gist is simply a flexible solution.