neveldo / jQuery-Mapael

jQuery plugin based on raphael.js that allows you to display dynamic vector maps
https://www.vincentbroute.fr/mapael/
MIT License
1.01k stars 195 forks source link

Not able to resolve modules mousewheel and mapael in CommonJS in version 2.0.0 #241

Closed shaohuahuang closed 7 years ago

shaohuahuang commented 8 years ago
ERROR in ../~/jquery-mapael/js/jquery.mapael.min.js
Module not found: Error: Cannot resolve module 'mousewheel' in /Users/AirShaos/Documents/dev/prospace_web/node_modules/jquery-mapael/js
 @ ../~/jquery-mapael/js/jquery.mapael.min.js 14:92-113

ERROR in ../~/jquery-mapael/js/maps/world_countries.js
Module not found: Error: Cannot resolve module 'mapael' in /Users/AirShaos/Documents/dev/prospace_web/node_modules/jquery-mapael/js/maps
 @ ../~/jquery-mapael/js/maps/world_countries.js 14:52-69 

Hi. I try to bundle jquery.mapael.js and world_countries.js using webpack, but it gives the error shown above saying the modules mousewheel and mapael cannot be resolved.

I think the issue is caused by requiring wrong modules in the js files.

For jquery.mapael.js, it requires mousewheel, rather jquery-mousewheel, seen from the code extract below: module.exports = factory(require('jquery'), require('raphael'), require('mousewheel'));

For world_countries.js, the same thing happens that it require mapael, rather than jquery-mapael. module.exports = factory(require('jquery'), require('mapael'));

neveldo commented 8 years ago

Hello @shaohuahuang,

Thank you for reporting this error, I will check it as soon as possible. However, feel free to make a pull-request if you can contribute !

shoudaos commented 8 years ago

@neveldo, maybe there are any news for this issue?

neveldo commented 8 years ago

Hello,

I haven't worked on it for now. Maybe you could make a pull-request if you know how to fix it ?

insipx commented 7 years ago

has this been fixed yet? Getting this exact error while trying to use mapael with npm.

If not does anybody have a workaround/potential fix they are working on?

it seems as if NPM needs the require as 'jquery-mousewheel' instead of just 'mousewheel' since that is what the package is called in the NPM repo's and what webpack expects.

Simply changing the require from 'mousewheel' to 'jquery-mousewheel' in jquery.mapael.js fixed this for me.

not sure how that would play out with bower

now the maps aren't being found, but that might just be my own personal issue....

neveldo commented 7 years ago

Hello @InsidiousMind , could you provide me a test script that show the issue with webpack ?

neveldo commented 7 years ago

I have fixed the issue, and it should now work fine : https://github.com/neveldo/jQuery-Mapael/commit/a83bd3a11e635ed9ffe99c070edb275f5c2cc9e4 (this fix will be included in the next release that will come very soon)