reppners / ngx-drag-drop

Angular directives using the native HTML Drag And Drop API
https://reppners.github.io/ngx-drag-drop/
BSD 3-Clause "New" or "Revised" License
307 stars 120 forks source link

last npm version mismatch last repository release #4

Closed jmarc-roy closed 7 years ago

jmarc-roy commented 7 years ago

Hi @reppners,

First of all, thank you for your work. This repo was exactly what I needed.

I have however an issue using your library in an electron application with webpack and angular. I notice that the last version on npm is aplha0 and not your last release on this repo: v1.0.0-rc.0. I don't know if my issue is related with this mismatch of release version :

ngx-drag-drop-npm-screenshot

Indeed I have to change the "main: index.js" to "main: ngx-drag-drop.umd.js" to get your package working, if not, I get this error : C:\Users\Jmarc\Documents\Programmation\materia-designer-angular4\src\node_modules\ngx-drag-drop\index.js:1 Uncaught SyntaxError: Unexpected token import.

When I use "ngx-drag-drop.umd.js" instead of "index.js", everything works as expected.

Any help will be greatly appreciated.

reppners commented 7 years ago

Which version did you install? 1.0.0-rc.0 is also available on npm. Npm just won't update the web page for some reason I don't know. Maybe it's just working for version changes that are not pre-releases.

I'm using it with angular-cli/webpack and its working fine. Can you post the content of your local download of the library's "index.js"?

jmarc-roy commented 7 years ago

In my package.json I have : "ngx-drag-drop": "next"

I can confirm it is the last version, we have (ngx-drag-drop/package.json) : "name": "ngx-drag-drop", "version": "1.0.0-rc.0"

Here is the content of "index.js" in my local download : indexjs-content.txt

We use @angular-cli 1.3.0 with an ejected webpack config to use "electron-renderer" as "target" and we have "target: es5" in our tsconfig.json.

reppners commented 7 years ago

So I think the issue is that it is not transpiled correctly for the node environment.

Can you try something like proposed here?

https://stackoverflow.com/a/45023796/3370601 https://stackoverflow.com/a/45239961/3370601

jmarc-roy commented 7 years ago

Thanks a lot!

I fix my issue with the first link you provided. I modified the webpack.config.js file as follows: "target": "electron-renderer", "externals": [nodeExternals({ whitelist: [ /^ngx-drag-drop/ ] })]

It works great now!

reppners commented 7 years ago

Nice! Don't hesitate to report any bugs you're encountering :-)