Skip to content

Fix lazy loading of imported components - #287

Merged
timriley merged 2 commits into
mainfrom
fix-lazy-loading-imported-keys
Aug 14, 2025
Merged

Fix lazy loading of imported components#287
timriley merged 2 commits into
mainfrom
fix-lazy-loading-imported-keys

Conversation

@timriley

Copy link
Copy Markdown
Member

We were checking for an import namespace using a component root_key, which is a symbol, whereas the importer was expecting strings. This led to imported components only becoming available on a full boot, not when lazy loading properly (because the check for their namespace in the importer would always return false due to the type mismatch).

This will resolve hanami/hanami#1529.

@unused

unused commented Aug 13, 2025

Copy link
Copy Markdown

Instead of adapting the check, how about updating the storage (Importer@registry) instead to store the specific type solely registry[namespace.to_s] = # ... in Importer#register?

@timriley
timriley force-pushed the fix-lazy-loading-imported-keys branch from 3b92e3c to 252eb21 Compare August 14, 2025 11:45
@timriley

Copy link
Copy Markdown
Member Author

@unused thank you for checking this out! :D I agree, that's a much better approach. I've just pushed that up in the last commit here. I'll merge this now and cut a patch release.

@timriley
timriley force-pushed the fix-lazy-loading-imported-keys branch from 252eb21 to 2b8646d Compare August 14, 2025 11:47
@timriley
timriley merged commit 2065557 into main Aug 14, 2025
14 checks passed
@timriley
timriley deleted the fix-lazy-loading-imported-keys branch August 14, 2025 11:49
@timriley

Copy link
Copy Markdown
Member Author

Released in 1.2.4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Imported app-component does not lazy-load

2 participants