johnagan / clean-webpack-plugin

A webpack plugin to remove your build folder(s) before building
MIT License
1.96k stars 137 forks source link

fix: do not clean directory if webpack errors are present during initial build #134

Closed chrisblossom closed 5 years ago

chrisblossom commented 5 years ago

Please hold off on merging this.

Although this is a fix for #133, is it also a breaking change? I think it could be if someone is using a webpack plugin that manually creates files inside webpack's output.path after the compile hook, although this is not supported by webpack and probably can/should be ignored. Thoughts?

codecov-io commented 5 years ago

Codecov Report

Merging #134 into master will increase coverage by 0.09%. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #134      +/-   ##
=========================================
+ Coverage   98.71%   98.8%   +0.09%     
=========================================
  Files           1       1              
  Lines          78      84       +6     
  Branches       27      28       +1     
=========================================
+ Hits           77      83       +6     
  Misses          1       1
Impacted Files Coverage Δ
src/clean-webpack-plugin.ts 98.8% <100%> (+0.09%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 336dbcb...fce56a8. Read the comment docs.

thomastay commented 3 years ago

Hi @chrisblossom @johnagan this PR broke our build :(, would appreciate feedback on how to upgrade to the new version. We currently have two Webpack configs which emit different files into our shared dist/ folder. Since Webpack runs the configs in parallel, there can be a problem where one config cleans the other's emitted files.

With this change, whichever config finishes compiling second will clean up the other config's emitted files. Previously, since we cleaned before compiling, this didn't happen because both the cleans happened immediately, before any files were compiled. (technically, it was a race condition back then, but our compiles are long enough that it never surfaced)

Is there a way to only clean the files that would be emitted by webpack? Or any other thoughts?

Versions: Webpack 4.44