Fix: recompile server bundle when assets manifest changed#7120
Fix: recompile server bundle when assets manifest changed#7120
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes an issue where the server bundle was not being recompiled when the assets manifest changed during development. The fix introduces detection logic to compare old and new assets manifest content and forces a full rebuild when changes are detected.
- Adds assets manifest change detection by comparing JSON stringified versions
- Modifies the compilation flow to force full rebuilds instead of incremental rebuilds when manifest changes
- Extends the
buildResulttype to include anassetsManifestChangedflag for tracking state
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/ice/src/webpack/ServerCompilerPlugin.ts | Implements assets manifest change detection and forces full rebuild when changes occur |
| .changeset/big-cats-act.md | Adds changeset entry documenting the fix |
| const oldAssetsManifest = this.compilerOptions.compilationInfo.assetsManifest; | ||
|
|
||
| // Check if assets manifest has changed | ||
| if (JSON.stringify(oldAssetsManifest) !== JSON.stringify(newAssetsManifest)) { |
There was a problem hiding this comment.
Using JSON.stringify() for deep comparison is inefficient and can be unreliable due to property ordering. Consider using a dedicated deep comparison utility or computing a hash of the manifest content for more reliable change detection.
| this.task = null; | ||
| } | ||
| }); | ||
| } else if (assetsManifestChanged && this.buildResult?.context?.rebuild) { |
There was a problem hiding this comment.
The variable assetsManifestChanged is declared inside the if (!this.isCompiling) block but is used outside of it. This will cause a ReferenceError when this.isCompiling is true, as the variable will be undefined in the outer scope.
This pull request introduces a fix to ensure the server bundle is recompiled whenever the assets manifest changes. The changes involve detecting modifications to the assets manifest and triggering a rebuild if necessary.