Repository navigation
fix(compiler): omit descendant imports in passthrough memo modules - #8013
MilindChatrabhuji wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
All reported issues were addressed across 4 files
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
[Medium impact] The PR appears safe to merge; no new actionable issues were found. SummaryPassthrough memo modules now omit imports used only by their children while keeping imports needed by the root component.
The earlier unnumbered finding is fixed: the page test now compares the complete normalized output. Reviews (4) · Last reviewed commit: "fix(compiler): validate pre-swap passthr..." · Reviewed by Greptile |
There was a problem hiding this comment.
All reported issues were addressed across 3 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
All Submissions:
Type of change
Changes To Core Features:
Summary
Fixes passthrough memo modules pulling in descendant libraries, child memo wrappers, and descendant client-state imports when
definition.component.childrenretains the user-authored subtree.reflex/compiler/utils.py(compile_experimental_component_memo), the passthrough branch calledrender._get_all_imports()before replacingrender.children = [hole_child], walking all descendant children even though descendants render in the caller/page scope behind{children}._root_only_hooks,_root_only_added_imports,_root_only_custom_code, and_root_only_dynamic_importsfrom the root before swapping children (while preserving_form_control_source/_get_all_refsdelegation back todefinition.componentwhen not already set onrender), then setrender.children = [hole_child]before callingrender._get_all_imports(). Whenanalysis is None, validate pre-swapadd_importsand hookVarData.importsvia_check_prohibited_importsand merge them viamerge_parsed_importsso child-aware rootadd_importsandadd_hookskeep their imports without triggeringForm._get_vars(include_children=True)on descendants.tests/units/reflex_base/components/test_memo.pyandtests/units/compiler/test_memoize_plugin.pycovering passthrough child exclusion + prop component retention,Formref imports, custom child-inspectingadd_imports/add_hooks, prohibited import validation for pre-swap root hooks/imports,is_instance_boundary(withClientStateScope) handling for root vs descendant client state,_memo_body_analysesisolation, and full-page auto-memo compilation.Verification
uv run --frozen pytest tests/units/compiler tests/units/components/test_memo.py tests/units/components/test_memo_cross_module.py tests/units/components/forms tests/units/reflex_base/components tests/units/reflex_base/test_client_state.py tests/units/components/test_component.py -q—1017 passed, 9 skippeduv run --frozen pyright --pythonplatform Linux reflex tests/units/reflex_base/components/test_memo.py tests/units/compiler/test_memoize_plugin.py—0 errors, 0 warnings, 0 informationsuv run --frozen pyright --pythonversion 3.11 tests/type_checking&--pythonversion 3.14 tests/type_checking—0 errors, 0 warnings, 0 informationsuv run --frozen ty check --python-version 3.14 tests/type_checking—All checks passed!uv run --frozen ruff check .—All checks passed!uv run --frozen ruff format --check .&news/+memo-passthrough-descendant-imports.bugfix.md— clean (2089python files + fragment formatted)uv run --frozen codespellon changed files,uv run --frozen python scripts/make_pyi.py --check, anduv run --frozen --package reflex-release reflex-release sync --check/check-headings/changelog-check --base-ref upstream/main— clean (News fragments present for: reflex)Closes #6429