Friday, 28 April 2017

Ignoring node packages when bundling for browser using rollup

I am trying to use a library (lib-foo) which has a dependency on the websockets npm package. However, it is written such that when used in browser, it doesn't use this package and relies on the websocket available in the browser by default.

However, when I am trying to bundle my library (lib-browser), it is trying to bundle the websockets along with the lib-foo package. This results in multiple errors since websockets is a library for node.

'http' is imported by node_modules/lib-foo/node_modules/websockets/lib/websockets/server.js, but could not be resolved – treating it as an external dependency
https://github.com/rollup/rollup/wiki/Troubleshooting#treating-module-as-external-dependency

I would like to make sure that websockets is not included in the bundling process since that code path will not be executed on browser during run-time.

Any help in figuring out how to do this is appreciated.



via Kiran Madipally

No comments:

Post a Comment