Follow-up to #7109 and the static-icon deep-import work tracked in #6627.
Icon and DynamicIcon currently implement their deep imports by overriding _get_imports() in packages/reflex-components-lucide/src/reflex_components_lucide/icon.py. Their import_var properties still describe the package-root import inherited from Component.
For example, rx.icon("apple") exposes a named Apple import with package_path="/" through import_var, while _get_imports() replaces it with the actual default import aliased as LucideApple from lucide-react/dist/esm/icons/apple.mjs. DynamicIcon similarly declares /dynamic.mjs only in _get_imports().
Move these import declarations into overrides of the import_var property, allowing the base _get_imports() implementation to assemble them with the component's other imports. Preserve the static icon's default binding, alias, and filename mapping, and the dynamic icon's named DynamicIcon binding and /dynamic.mjs path. This also avoids replacing the entire Lucide entry in the assembled import dictionary.
The latest #7109 change makes bundle_library(component) consume the rendered paths from _get_imports() directly. It therefore already avoids an unnecessary import * as lucide_react from "lucide-react" in root.jsx when a specific icon is registered. This follow-up is a consistency cleanup, not a prerequisite for that fix: import_var should itself describe the module actually imported, so callers using that property can retain the same deep-import optimization.
Validation should cover:
- Static icon
import_var metadata matches the actual default deep import, including filename overrides and aliases.
- Reactive icon
import_var metadata points to the named import from /dynamic.mjs.
- Repeated
_get_imports() calls preserve other imports and return consistent results.
- Bundling a specific static icon registers its deep module without the
lucide-react barrel; computed components present initially or activated after an event continue to render without introducing an unnecessary barrel import.
Explicit bundle_library("lucide-react") should continue to bundle the package root when requested.
Follow-up to #7109 and the static-icon deep-import work tracked in #6627.
IconandDynamicIconcurrently implement their deep imports by overriding_get_imports()inpackages/reflex-components-lucide/src/reflex_components_lucide/icon.py. Theirimport_varproperties still describe the package-root import inherited fromComponent.For example,
rx.icon("apple")exposes a namedAppleimport withpackage_path="/"throughimport_var, while_get_imports()replaces it with the actual default import aliased asLucideApplefromlucide-react/dist/esm/icons/apple.mjs.DynamicIconsimilarly declares/dynamic.mjsonly in_get_imports().Move these import declarations into overrides of the
import_varproperty, allowing the base_get_imports()implementation to assemble them with the component's other imports. Preserve the static icon's default binding, alias, and filename mapping, and the dynamic icon's namedDynamicIconbinding and/dynamic.mjspath. This also avoids replacing the entire Lucide entry in the assembled import dictionary.The latest #7109 change makes
bundle_library(component)consume the rendered paths from_get_imports()directly. It therefore already avoids an unnecessaryimport * as lucide_react from "lucide-react"inroot.jsxwhen a specific icon is registered. This follow-up is a consistency cleanup, not a prerequisite for that fix:import_varshould itself describe the module actually imported, so callers using that property can retain the same deep-import optimization.Validation should cover:
import_varmetadata matches the actual default deep import, including filename overrides and aliases.import_varmetadata points to the named import from/dynamic.mjs._get_imports()calls preserve other imports and return consistent results.lucide-reactbarrel; computed components present initially or activated after an event continue to render without introducing an unnecessary barrel import.Explicit
bundle_library("lucide-react")should continue to bundle the package root when requested.