shama / webpack-stream

:tropical_drink: Run webpack through a stream interface
MIT License
1.39k stars 122 forks source link

Make webpack-stream agnostic of the webpack version #188

Closed germain-gg closed 6 years ago

germain-gg commented 6 years ago

The current implementation of webpack-stream forces developers to use the webpack version defined in the package.json. Realistically we can assume that this package will always be used in a context where its host have webpack as dependency. This is why we can leverage the npm peer dependencies.

I added the package install-peer-dependencies so that we can run the unit tests even if the project is not embedded anywhere. I also decided not to add that to the postinstall npm hook because it is intended for development purposes only.

Those change bring up another problems though. The unit tests are very version dependant and about 80% of them are failing if we try running this with webpack 4.

Not too sure what to do with those, I'd be happy to listen to your recommendation and update accordingly.

rgov commented 6 years ago

Thanks for the changes, Germain. For others taking a look, I installed using npm i --save-dev https://github.com/gsouquet/webpack-stream.git and it resolved the issues I was seeing.

I hope @shama has a few cycles to spare to move this pull request forward.

shama commented 6 years ago

The tests are likely failing because webpack-stream needs updates in order to work with webpack 4, hence the normal dependency. I think I've mentioned it before in this project's issue board but peer dependencies are flawed and don't solve this issue.

If you really want to use your own version of webpack without waiting for it to be updated, then as shown in the docs, you can supply your own version of webpack as a second parameter:

const gulp = require('gulp');
const webpack = require('webpack');
const gulpWebpack = require('webpack-stream');
gulp.task('default', function() {
  return gulp.src('src/entry.js')
    .pipe(gulpWebpack({}, webpack))
    .pipe(gulp.dest('dist/'));
});
germain-gg commented 6 years ago

Thanks for your update on that! 👍 Do you remember why peer dependencies are flawed by any chance? Otherwise i'll try to dig in the issues board

rgov commented 6 years ago

as shown in the docs, you can supply your own version of webpack as a second parameter

For what it's worth, though others reported this working in #180, I had copied the exact code from the README and tried passing in the latest webpack module and it seemed to ignore what I passed in and continued to use the older webpack.