wasm_js rustlfags on top workspace by youknowone · Pull Request #6116 · RustPython/RustPython
🛠️ Refactor suggestion
Avoid double-enabling getrandom’s JS backend; rely on common’s feature only.
wasmbind currently enables both rustpython-common/wasm_js and getrandom/wasm_js. Due to feature unification this is redundant and risks confusion about the single source of truth. Drop the direct getrandom/wasm_js from vm and let common own it.
Apply:
-wasmbind = ["rustpython-common/wasm_js", "chrono/wasmbind", "getrandom/wasm_js", "wasm-bindgen"] +wasmbind = ["rustpython-common/wasm_js", "chrono/wasmbind", "wasm-bindgen"]
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| wasmbind = ["rustpython-common/wasm_js", "chrono/wasmbind", "getrandom/wasm_js", "wasm-bindgen"] | |
| wasmbind = ["rustpython-common/wasm_js", "chrono/wasmbind", "wasm-bindgen"] |
🤖 Prompt for AI Agents
In vm/Cargo.toml around line 27, the wasmbind feature list currently includes
both "rustpython-common/wasm_js" and "getrandom/wasm_js"; remove
"getrandom/wasm_js" from the vm crate's wasmbind feature so the getrandom JS
backend is provided only via rustpython-common's wasm_js feature, leaving
wasmbind = ["rustpython-common/wasm_js", "chrono/wasmbind", "wasm-bindgen"]
(ensure no other references to getrandom/wasm_js remain in this feature).
💡 Verification agent
🧩 Analysis chain
Do not enable browser/wasm bindings by default; this likely caused the test failures.
default = ["compiler", "wasmbind", "stdio"] means native builds also activate wasmbind, which (transitively) opts into the JS randomness backend. Make wasmbind opt‑in only.
Apply:
-default = ["compiler", "wasmbind", "stdio"] +default = ["compiler", "stdio"]
Quick checks:
🏁 Script executed:
#!/bin/bash # 1) Confirm default features no longer include wasmbind rg -nP '^\s*default\s*=\s*\[.*wasmbind' -g 'vm/Cargo.toml' # 2) Ensure no other crate pulls wasmbind by default rg -nP '\bfeatures\b.*wasmbind' -C2 -g '!**/target/**' # 3) Inspect .cargo/config.* to ensure any `--cfg getrandom_backend="wasm_js"` is target-scoped to wasm32 only rg -nP --hidden -C2 'getrandom_backend\s*=\s*"wasm_js"|--cfg\s+getrandom_backend' -g '.cargo/**'
Length of output: 209
Remove wasmbind from default features in vm/Cargo.toml
vm/Cargo.toml:13 currently enables wasmbind in default features, which pulls in the JS getrandom backend for native builds — make wasmbind opt‑in.
Apply:
-default = ["compiler", "wasmbind", "stdio"] +default = ["compiler", "stdio"]
Also ensure any .cargo/config.* or --cfg getrandom_backend="wasm_js" entries are target‑scoped to wasm32 and that no other crate exposes wasmbind in its default features.
Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In vm/Cargo.toml around line 27, remove "wasmbind" from the default features
list so the getrandom wasm_js backend is not pulled into native builds; instead
add a separate optional feature (e.g., wasmbind) that includes the wasmbind deps
and mark those dependencies as optional under that feature so wasm support is
opt‑in. Also audit any .cargo/config.* files and Cargo command args and make
sure any --cfg getrandom_backend="wasm_js" or equivalent settings are restricted
to the wasm32 target (or moved into target."cfg(target_arch = \"wasm32\")"
sections), and verify no other crate in the workspace exposes wasmbind in its
default-features so the change actually prevents native pulls.