Apply package.json overrides after frozen install
Type of change
- Bug fix (non-breaking change which fixes an issue)
Description
Fixes the issue where upgrading Reflex to a version that introduces a new package.json override fails with lockfile had changes, but lockfile is frozen.
Root cause: Framework overrides were being merged into package.json while restoring the persisted file from reflex.lock/, which would desync it from the persisted lockfile and cause --frozen-lockfile to fail.
Solution: Defer merging framework overrides until after the frozen install completes. This keeps the restored package.json/lockfile pair intact for the frozen install, then applies overrides via a new update_package_json_overrides() function before any dependency resolution happens.
Changes
Core logic (reflex/utils/frontend_skeleton.py):
- Refactored
_read_persisted_package_json()into a generic_read_package_json_object()helper - Modified
_compile_package_json()to preserve persisted overrides verbatim (no framework merging) - Added
update_package_json_overrides()to merge framework overrides into.web/package.jsonafter the frozen install - Updated docstrings to clarify the new override handling strategy
Install flow (reflex/utils/js_runtimes.py):
- Call
update_package_json_overrides()after the frozen install - If overrides changed but no packages are being added, run a non-frozen install to resolve the new overrides into the lockfile
- Updated cache payload to include overrides so changes bust the install cache
Tests (tests/units/test_prerequisites.py):
- Added
_stub_framework_packages()to also stubOVERRIDESfor predictable test counts - Added 4 new integration tests covering:
- Applying new overrides after frozen install while preserving user overrides
- Reconciling lockfile when only overrides change
- Skipping reconcile when overrides are already applied
- Cache invalidation when overrides change
- Added 5 new unit tests for
update_package_json_overrides()covering merging, missing sections, no-ops, and malformed files - Updated existing tests to reflect that framework overrides are no longer merged during compilation
Test Plan
All new tests pass and cover the override handling logic:
test_install_frontend_packages_applies_overrides_after_frozen_installvalidates the core fixtest_install_frontend_packages_reconciles_lockfile_for_overrides_only_changeensures lockfile is refreshed when neededtest_install_frontend_packages_skips_reconcile_when_overrides_unchangedprevents unnecessary worktest_install_frontend_packages_cache_invalidated_by_new_overrideensures cache busting works- Unit tests for
update_package_json_overrides()cover all edge cases
Existing tests updated to match new behavior where framework overrides are applied post-frozen-install rather than during compilation.
closes #6792