socib / Leaflet.TimeDimension

Add time dimension capabilities on a Leaflet map.
MIT License
435 stars 139 forks source link

npm package ? #87

Closed mdartic closed 7 years ago

mdartic commented 7 years ago

Hello again,

I'm using npm to instantiate my projects, and not bower.

There isn't any npm package published yet, I think it could be nice.

But, with npm, we can install a package directly from his github URL, for example

npm install socib/Leaflet.TimeDimension#d579118

I encounter some errors :

npm ERR! Linux 4.4.0-47-generic
npm ERR! argv "/home/mdartic/.nvm/versions/node/v4.4.7/bin/node" "/home/mdartic/.nvm/versions/node/v4.4.7/bin/npm" "install" "socib/Leaflet.TimeDimension#d579118"
npm ERR! node v4.4.7
npm ERR! npm  v2.15.8
npm ERR! code E404

npm ERR! 404 Registry returned 404 for GET on https://registry.npmjs.org/iso8601-js-period
npm ERR! 404 
npm ERR! 404 'iso8601-js-period' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 It was specified as a dependency of 'leaflet-timedimension'
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

This is due to the iso8601-js-period that is not declared into npmjs registry.

Several questions :

bielfrontera commented 7 years ago

Hi @mdartic, we should make a PR at iso8601-js-period, or ask @phammer if he can add a package.json in their repository, no?

Here, I assume we should change: "iso8601-js-period": "*", by: "iso8601-js-period": "nezasa/iso8601-js-period",

And its ok for me to publish the plugin in npm!

mdartic commented 7 years ago

I'll do that, but I checked the repo and I didn't see any activity since the last commit in 2013.

So, I prefer to add the repo first in your package.json and after see if there is any chance to transform iso8601 in a npm package.

mdartic commented 7 years ago

So, in fact I've created the npm package of iso8601-js-period.

I didn't remember npm installneed a repo with a package.json.

Thanks for reviewing the PR.

bielfrontera commented 7 years ago

thanks @mdartic! merged! :)

mdartic commented 7 years ago

Great, thank you, could you publish it to npm ?

bielfrontera commented 7 years ago

done. Can you test it?

mdartic commented 7 years ago

Well, the package is well published,

But I encounter an error with the initialisation of the plugin.

I use webpack, and I import leaflet-timedimension.

When I execute the code, I get the error in the browser

leaflet.timedimension.min.js:18Uncaught ReferenceError: jQuery is not defined

And if I import jQuery before leaflet-timedimension in my code, same result.

If you have an idea, I'll take it !

Else, maybe I'm gonna make a PR for #86 :-)

mdartic commented 7 years ago

By the way, thanks for publishing it !

mdartic commented 7 years ago

To make it work for the moment, we have to include a script tag and load jQuery basically before the bundle of webpack, or the plugin itself.

Just like if we were writing vanilla JS.

But it's ok, and I close the issue. I'm gonna work on #86 to make the integration better.

bielfrontera commented 7 years ago

I managed to make it work with webpack (v1) with these instructions:

require('iso8601-js-period');
window.jQuery = require('jquery');
require('leaflet');
require('leaflet-timedimension');

I think this is related to #12

mdartic commented 7 years ago

Thank you ! Works perfectly.