perf: emit_assets only emit changed assets #3305
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related issue (if exists)
Before
After
Summary
馃 Generated by Copilot at bb1ef0f
This pull request implements a feature that allows the compiler to only emit changed assets, except for the hot module replacement assets, which are always emitted. This can improve the performance and efficiency of the compilation process. To achieve this, the pull request adds a
version
field to theAsset
andCompilationAsset
structs, which stores the content hash of the asset. It also adds and implements aremove_file
method to theAsyncFileSystem
trait and its concrete implementations, which enables the compiler to delete outdated assets from the output directory. Additionally, it modifies theOutputOptions
andDevtoolPlugin
structs to set theversion
field of the asset info variables accordingly.Walkthrough
馃 Generated by Copilot at bb1ef0f
remove_file
to theAsyncFileSystem
trait and implement it for theNativeFileSystem
andNodeFileSystem
structs using thetokio::fs::remove_file
andfs.unlinkSync
functions respectively (link, link, link, link, link, link, link, link)mut
modifier and a default value assignment to theasset
variable in thefor
loop incrates/rspack_core/src/compiler/hmr.rs
to ensure that the hot module replacement assets are always emitted (link, link)