fix: expose deep Lucide imports through import_var

Merged
SA
7d ago
+124-29

All Submissions:

  • Have you followed the guidelines stated in CONTRIBUTING.md file?
  • Have you checked to ensure there aren't any other open Pull Requests for the desired changed?

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Changes To Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran tests with your changes locally?

Changes

Declare static and dynamic Lucide module imports through import_var, so the public metadata describes the same deep module that the component imports. Let the base implementation collect and cache these imports together with imports required by props.

Preserve static default bindings, aliases and filename overrides, the named dynamic binding even when callers set is_default=True, and explicit package-root bundling. Add metadata and same-library prop-import regressions, and extend the existing dynamic-components app's browser coverage for initial and event-activated icons.

Closes #7111.

Validation

Tested on Windows with Python 3.12.10. Checks cover the patch committed as 0215ea166dce197170b5f7db23be0a0a0f7244cf.

  • Before the fix, six metadata/import-preservation cases failed.

  • uv run --python 3.12 --locked pytest tests/units/components/lucide/test_icon.py tests/units/compiler/test_dynamic_components_codegen.py -q --tb=short: 3,592 passed. Existing compiler tests cover explicit root bundling and specific deep-module registration.

  • All applicable pre-commit hooks passed, including Ruff, codespell, stub generation, Pyright, ty, and Biome. The first stub-generation run updated the required Lucide entry in pyi_hashes.json; the subsequent run passed.

  • With APP_HARNESS_HEADLESS=1 and PYTHONIOENCODING=utf-8, uv run --python 3.12 --locked pytest tests/integration/test_dynamic_components.py::test_dynamic_components -q -s -o faulthandler_timeout=120: 1 passed in 242.65 seconds. This extends the existing Selenium test, including its initial/reactive icons, repeated activation and counter events, with module-registry assertions and an explicit is_default=True caller. Its existing timeouts are unchanged; the 120-second diagnostic stack dump occurred during navigation, and pytest completed normally.

  • Rechecking the final six unit regressions against the original affected module produced 6 failures; restoring the fixed module produced 6 passes.

  • Cubic's caller-flag regression produced 2 failures and 2 passing controls before forcing the dynamic import to remain named. All four cases pass in the final unit run.

The browser follow-up initially failed during fixture setup. A diagnostic captured StaleElementReferenceException on the original token input while the current input was populated. The fixture now re-locates the input on each poll, retaining its existing 15-second timeout. The final passing run used no diagnostic plugin.

The initial uncaptured browser invocation failed while printing the server's Unicode arrow under Windows cp1252 output. Setting UTF-8 process output resolved that setup error. The full repository unit and integration matrices were not run locally; remote CI remains unverified until the workflows run.

An independent source review found no actionable correctness or security finding in this scoped patch. This is not a full repository security audit.

Implemented with assistance from OpenAI Codex. No human review or manual testing is claimed.