-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
fix(nuxt): sort hash sources and files #32048
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR resolves the issue of inconsistent ordering in Nuxt’s build hash computation by adding explicit sorting to both file hashes and hash source arrays.
- Sort file entries by name right after mapping their properties
- Sort hash sources before generating the final build hash
@@ -117,7 +117,7 @@ async function getHashes (nuxt: Nuxt, options: GetHashOptions): Promise<Hashes> | |||
name: f.name, | |||
size: f.attrs?.size, | |||
data: hash(f.data), | |||
})) | |||
})).sort((a, b) => a.name.localeCompare(b.name)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider extracting the sorting logic into a helper function to avoid duplication and improve consistency if similar sorts are needed elsewhere.
Copilot uses AI. Check for mistakes.
@@ -152,6 +152,8 @@ async function getHashes (nuxt: Nuxt, options: GetHashOptions): Promise<Hashes> | |||
}) | |||
} | |||
|
|||
hashSources.sort((a, b) => a.name.localeCompare(b.name)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Using an inline sort here ensures stable ordering, but abstracting the sorting logic into a dedicated helper could improve overall maintainability and consistency across the codebase.
hashSources.sort((a, b) => a.name.localeCompare(b.name)) | |
sortByName(hashSources); |
Copilot uses AI. Check for mistakes.
WalkthroughThe update introduces sorting by file name using localeCompare to two arrays within the getHashes function in the cache module. The array produced by normaliseFiles is now sorted by its name property before being added to hashSources. Additionally, the entire hashSources array is sorted by name before the final hash is calculated and cached on the nuxt instance. These changes ensure a deterministic order of file entries and hash sources, directly influencing the consistency of the hash calculation. No changes have been made to the declarations of exported or public entities. Tip ⚡️ Faster reviews with caching
Enjoy the performance boost—your workflow just got faster. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
⏰ Context from checks skipped due to timeout of 90000ms (2)
🔇 Additional comments (2)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
@nuxt/kit
nuxt
@nuxt/rspack-builder
@nuxt/schema
@nuxt/vite-builder
@nuxt/webpack-builder
commit: |
CodSpeed Performance ReportMerging #32048 will not alter performanceComparing Summary
|
🔗 Linked issue
resolves #32047
📚 Description
this sorts hash sources as a potential solution to #32047