Search code examples
node.jsnpmwebpackrollupparceljs

Best approach to support Webpack, Parcel and Rollup all at once?


I am writing a library (a cli tool) that works with bundlers. I want to support all the three major bundlers: Webpack, Parcel and Rollup.

I'm thinking of specifying each of them as peer-dependencies in package.json, and then accepting a parameter --webpack, --parcel or --rollup. I would write in the documentation that you need to install one of them and then specify it as a parameter.

The only "problem" seems to be that npm will give you warnings of uninstalled peer-dependencies and I wonder if that's bad user experience. Is there a better way of doing this that I'm missing?


Solution

  • Since the tool you are going to build requires more or less specific versions of webpack & co. anyway to work correctly, you might want to bundle them with your own tool.

    This way you won't have unresolved peer dependencies, and your users only have to add a single dependency, instead of multiple ones. Plus, they get the guarantee that things will definitely work.

    Of course, OTOH this means to install a bunch of packages every time, although most of them are not needed. This is the downside. From my personal point of view, the guarantee that things work would be more important than a smaller download, but YMMV.