happo / happo.io

Happo is a cross-browser screenshot testing service
https://happo.io
MIT License
196 stars 25 forks source link

Webpack v4 Support #17

Closed parris closed 6 years ago

parris commented 6 years ago

Hi! So we recently upgraded to webpack v4. Webpack 4 changes how plugins work, and webpack packages some basic plugins in with it. This means old plugins in happo's copy of webpack are not compatible with webpack from our codebase. In addition, even if webpack didn't ship with plugins, npm doesn't allow installation of the same package at 2 separate versions.

Our workaround solution was to do the following in our happo config:

const webpack = require('happo.io/node_modules/webpack/lib/webpack');

plugins: [
   webpack.ModuleConatPlugin, // ... etc etc
]

Options:

  1. Maybe there is a way to setup webpack as a peer dependency? I dislike this because its great that happo works out of the box, and this would start going down the path of happo being dependent on some config.
  2. Pass webpack into the "customWebpackConfig" function as another argument. This means we can use the same version of webpack that happo uses. We will need to redefine the same configuration twice, but it at minimum prevents digging into happo's node_modules.
  3. Optionally, completely delegate control of webpack to the host application some how.
  4. Allow the host application to specify which webpack to use.

Or some combo of the above.

Thoughts?

trotzig commented 6 years ago

Hi! Thanks for outlining possible solutions to this and for finding and sharing a workaround. I went through the same thing with babel dependencies and landed in them being peerDependencies (https://github.com/enduire/happo.io/commit/643bcd573e6317b41b4c6f3184404363eac328db). I'll make the same change to webpack.

In the past, happo used to delegate bundling (be it webpack or another bundler) to the consumer, but I decided to move over some of that control to happo in order to streamline things. The addition of a few peer dependencies shouldn't affect that too much, while still making happo better out-of-the-box.

trotzig commented 6 years ago

Alright, give version 2.0.0 a try and let me know how it goes! https://github.com/enduire/happo.io/releases/tag/v2.0.0

parris commented 6 years ago

Thanks Henric! I'll try this out tomorrow ( happy birthday btw :) )

parris commented 6 years ago

👍 this worked btw

trotzig commented 6 years ago

Nice, good to hear. Thanks for circling back!