anseki / plain-draggable

The simple and high performance library to allow HTML/SVG element to be dragged.
https://anseki.github.io/plain-draggable/
MIT License
765 stars 96 forks source link

Support installation as a node module #12

Closed pavelhamrik closed 5 years ago

pavelhamrik commented 5 years ago

I would appreciate if this could work as a regular node module with ES6 imports, allowing greater flexibility and interoperability with other libraries as well as own code.

I tried to make this work in a webpack environment to no avail – mostly due to missing dependencies I'm not willing to install explicitly as they have nothing to do with my project, just this library.

I'm looking forward to giving this a shot in the future; especially the snapping features look great.

anseki commented 5 years ago

Hi @pavelhamrik, thank you for the comment. Could you explain about details?

pavelhamrik commented 5 years ago

I got confused by the installation instructions which point me in the direction of linking a minified script in my html, a practice I don't want to turn to in e.g. a React project.

However, I realized I can use script-loader for webpack and the library is indeed to be found in the npm repository, so I can list it as a dependency. Not Ideal, but workable.

Thank you for your quick response.

anseki commented 5 years ago

Ok. :smile: So, could you close this issue because it was already solved?

ubirajaramneto commented 5 years ago

If you are not being able to install the library with NPM due to missing dependencies, run the following command:

npm install --save anim-event cssprefix m-class-list pointer-event

It solved the problem for me.

anseki commented 5 years ago

Hi @ubirajaramneto, thank you for your report. You have to install the devDependencies only when you will develop something. The dev in the devDependencies means that.

ubirajaramneto commented 5 years ago

Hello Anseki, thanks for the clarification, but what I meant here, and maybe I am posting in the wrong issue is that, when I tried installing your library using NPM, it would error out and give me and error telling me that it could not find these dependencies.

After issuing the above command, everything started working normally. I understand that the dev dependencies are only to be used when requiring dependencies that are only needed at development, but not in production. In my case I will be using this library in production.

Maybe I did not get what you meant, if that is the case I am sorry. Was just trying to help out anyone having issues using this library as a NPM module.

anseki commented 5 years ago

NPM never throw that error because the library has no dependency. Maybe you mistook NPM for a development tool (e.g. Webpack, Rollup, etc. (that try to bundle modules)) that try to find the link modules. For example, that development tool may throw an error when link modules are not found.

As you said, your case is unrelated to this issue, but thank you for your report. :smile: