Skip to content

Commit

Permalink
fix: clear webpack asset emit cache afterEmit
Browse files Browse the repository at this point in the history
Fix #126
  • Loading branch information
jbedard committed Nov 2, 2023
1 parent 5b68345 commit 8ffe827
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions webpack/private/webpack_worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@ class WebpackWorker extends WebpackCLI {
console.error(options)
this.compiler = await super.createCompiler(options, cb)
this.options = options

// The output directory will be cleaned between runs, webpack assumes the output directory will not be modified:
// Webpack5: https://github.com/webpack/webpack/blob/v5.36.2/lib/Compiler.js#L783-L788
if (this.compiler._assetEmittingPreviousFiles) {
this.compiler.hooks.afterEmit.tap("rules_webpack", () => this.compiler._assetEmittingPreviousFiles.clear())
}
// Webpack4: https://github.com/webpack/webpack/blob/v4.47.0/lib/Compiler.js#L393-L398
if (this._assetEmittingSourceCache) {
this.compiler.hooks.afterEmit.tap("rules_webpack", () => this.compiler._assetEmittingSourceCache.clear())
}
}
}
}
Expand Down

0 comments on commit 8ffe827

Please sign in to comment.