node-ssdp doesn't work with webpack
dulajra opened this issue · 2 comments
Both server code and client code works fine with a sample node project. My client app is in angular-electron with webpack as the module bundler. node-ssdp
gets installed successfully. But then webpack fails with following errors.
ERROR in ./~/node-ssdp/test/lib/server.js
Module not found: Error: Can't resolve 'chai' in 'J:\fyp\desktop-client\node_modules\node-ssdp\test\lib'
@ ./~/node-ssdp/test/lib/server.js 3:13-28
@ ./~/node-ssdp ^.*server$
@ ./~/node-ssdp/index.js
@ ./src/app/providers/pd.service.ts
@ ./src/app/app.module.ts
@ ./src/main.ts
@ multi ./src/main.ts
ERROR in ./~/node-ssdp/test/lib/client.js
Module not found: Error: Can't resolve 'chai' in 'J:\fyp\desktop-client\node_modules\node-ssdp\test\lib'
@ ./~/node-ssdp/test/lib/client.js 4:13-28
@ ./~/node-ssdp ^.*client$
@ ./~/node-ssdp/index.js
@ ./src/app/providers/pd.service.ts
@ ./src/app/app.module.ts
@ ./src/main.ts
@ multi ./src/main.ts
ERROR in ./~/node-ssdp/test/helper.js
Module not found: Error: Can't resolve 'sinon' in 'J:\fyp\desktop-client\node_modules\node-ssdp\test'
@ ./~/node-ssdp/test/helper.js 1:12-28
@ ./~/node-ssdp/test/lib/server.js
@ ./~/node-ssdp ^.*server$
@ ./~/node-ssdp/index.js
@ ./src/app/providers/pd.service.ts
@ ./src/app/app.module.ts
@ ./src/main.ts
@ multi ./src/main.ts
ERROR in ./~/node-ssdp/test/helper.js
Module not found: Error: Can't resolve 'dgram' in 'J:\fyp\desktop-client\node_modules\node-ssdp\test'
@ ./~/node-ssdp/test/helper.js 3:12-28
@ ./~/node-ssdp/test/lib/server.js
@ ./~/node-ssdp ^.*server$
@ ./~/node-ssdp/index.js
@ ./src/app/providers/pd.service.ts
@ ./src/app/app.module.ts
@ ./src/main.ts
@ multi ./src/main.ts
I tried installing the above missing chai, sinon, dgram dependencies manually. chai and sinon errors got eliminated but not dgram. Is this a bug in node-ssdp or webpack itself?
This is due to the fact you are including the ENTIRE library in your npm package. Adding test to .npmignore should fix this.
Since you use dynamic requires, webpack needs to include every directory while bundling so this general way of doing it is a pretty bad idea as well.
Yeah, this is 100% my fault for including test/
into the published package. v3.2.3 removes it.