davidjbradshaw / image-map-resizer

Responsive HTML Image Maps

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

jQuery required?

cutme opened this issue · comments

Webpack 4:

var imageMapResizer = require("image-map-resizer");

When compile, I have error:

ERROR in ./node_modules/image-map-resizer/js/imageMapResizer.min.js
Module not found: Error: Can't resolve 'jquery' in ...

Is jQuery required for image-map-resizer work?

No it should not be required, it will just create a jQuery interface if it is available. This is the only ref to it in the code, so I'm confused by that error

if('jQuery' in window) {
    jQuery.fn.imageMapResize = function $imageMapResizeF(){
        return this.filter('map').each(scaleImageMap).end();
    };
}

Happy to take a PR if you can workout why this happens

Thinking a bit more, does changing that to the following help?

if('jQuery' in window) {
   window.jQuery.fn.imageMapResize = function $imageMapResizeF(){
        return this.filter('map').each(scaleImageMap).end();
    };
}

I removed this fragment and now is ok. Thanks.

I've release a version with the above patch