This is the only change that is required to support Webpack 4, works great for me
I see peerDependencies for this library goes back to webpack 2, so I wanted to help make that a thing!
I wish the conditional could be evaluated only once for optimal perf, but it needed to be scoped for this. Perhaps I could set a flag the first time the conditional is evaluated:
let webpack5 = true;
function makeLoader() {
return function (source, inputSourceMap) {
// cheaper boolean conditional.
// if webpack5 is false the first time, don't check again
if(webpack5 && 'getOptions' in this) {
webpack5 = false
}
let loaderOptions = webpack5 ? this.getOptions() : require('loader-utils').getOptions(this)
}
}
Do you have a way of benchmarking the webpack loader? Might be a negligible difference but worth considering
Note: Oddly, it looks like github.dev applied some formatting as well when I created this using this new approach, thought I'd try it
This is the only change that is required to support Webpack 4, works great for me
I see
peerDependencies
for this library goes back to webpack 2, so I wanted to help make that a thing!I wish the conditional could be evaluated only once for optimal perf, but it needed to be scoped for
this
. Perhaps I could set a flag the first time the conditional is evaluated:Do you have a way of benchmarking the webpack loader? Might be a negligible difference but worth considering
Note: Oddly, it looks like
github.dev
applied some formatting as well when I created this using this new approach, thought I'd try it