Make the production frontend build reproducible
Merged
H4
1mo ago+84+84+01234567890123456789-3-3-0123456789
Description
Fixes #7562.
state.jsno longer importsreflex.json. It reads the Reflex version fromenv.json, whichset_env_json()writes from values that only change with the config (REFLEX_VERSIONis added next toTRANSPORTandTEST_MODE).reflex.jsonitself is unchanged: the CLI still keeps the project hash and the last run time there.format_refreplaces the Var marker (<reflex.Var>{hash}</reflex.Var>) with a short digest of the Var's expression and type as text. An f-string id around a Var then gets the same ref name in every run, and Vars that differ only by type keep separate refs. It is still one ref per component, as before.
The backend's subprotocol check (HTTP_SEC_WEBSOCKET_PROTOCOL against constants.Reflex.VERSION in EventNamespace.on_connect) gets the same value as before.
Testing
- New unit tests:
test_set_env_json_holds_the_reflex_versionandtest_format_ref_names_an_f_string_var_by_its_expression_and_type. tests/unitspass.- On an app with f-string Var ids, two clean
reflex export --frontend-only --no-zip --env prodruns in separate web folders:- on
main: different manifests (manifest-0ee1b19e.js,manifest-ba20c90e.js), and every page's HTML differs; - with this change: the same manifest in both runs, and
diff -rqfinds no difference inbuild/client.
- on
Type of change
- Bug fix (non-breaking change which fixes an issue)