gajus / write-file-webpack-plugin

Forces webpack-dev-server to write bundle files to the file system.
Other
527 stars 54 forks source link

feat: Replace output files atomically (new option: atomicReplace). #69

Closed transplier closed 6 years ago

transplier commented 6 years ago

This is useful if the written files are watched by an external program like test watchers (i.e., karma). Without an atomic replace, these programs may process an incomplete file. This usually results in syntax errors being reported.

This commit introduces an atomic replacement strategy whereby the new version of a file is written to a temporary file. When the file is completely written, the temporary file is renamed to the output file name, replacing the contents atomically. This strategy can be disabled via the atomicReplace boolean option.

transplier commented 6 years ago

I use this plugin to let Karma (test runner) use the same WDS instance as the rest of my dev setup. This saves significant time when starting tests. Unfortunately the streaming write this plugin uses often causes karma to see partial output, which is undesirable. Hence this PR. Thoughts?

transplier commented 6 years ago

Thanks! Version bump?