dx build --wasm-split gives different split modules (and hashed names) for identical input

Open
#6,090 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
56/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
rust, wasm
Domain
build-system

Research direction

Start by tracing the dx build --platform web --release --wasm-split path and find where split wasm modules and the JavaScript entry are emitted; the issue does not name files or tests. Check whether map iteration order affects emitted output, then run identical builds twice and compare the split module and entry bytes. Done when identical inputs produce identical bytes and hashed asset names.

Written by the indexing model from the issue text.

Description

Two dx build --platform web --release --wasm-split runs (dx 0.7.10) on the same code, with the same toolchain and settings, give a byte-identical main module, but the split module and the JS entry come out with different bytes and therefore different hashed names (module_0_<name>-dxh….wasm, <app>-dxh….js). With a larger split module, about 37,000 bytes differed between runs.

It looks like wasm-split iterates HashMaps, whose order is random per run.

Effect: every deploy gives every split file a new name, so every client re-downloads every split file even when nothing changed. That defeats long-lived caching of the hashed assets.

Using an ordered map (BTreeMap/IndexMap) or sorting before emitting would make it deterministic. For now we work around it by keeping builds keyed by a hash of their inputs and reusing an unchanged one.

Possibly related: #4439 (HashMap iteration order in asset handling).

Dominant language
Rust
Stars
39.8k
Forks
2k
Avg merge
14h 29m
Merged PRs (30d)
20

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

  • No Dockerfile or Docker Compose file
  • No pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from DioxusLabs/dioxus

All issues in DioxusLabs/dioxus

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.