Support reproducible builds by forcing window.search to use stable key ordering. #692
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.
In CI, I run
mdbook build
to check that my repo's book is still well-formed. Each time I run this though, git notices thatsearchindex.js
has been modified, even when I haven't made any changes to the book.Running a diff on the old and new output shows that the only difference is in key ordering. Rust's HashMaps are randomly ordered,
elasticlunr-rs
uses HashMaps internally and when usingserde_json::to_string
that random order is directly written out.We can force reproducible output by using
serde_json::Value
as an intermediary output, which uses BTreeMap internally, and will order the output keys consistently when written to a JSON string.I can confirm that rerunning
mdbook build
repeatedly in my repo does not causesearchindex.js
to be marked as modified.