Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enable placing islands anywhere #176

Merged
merged 6 commits into from
May 11, 2024
Merged

Conversation

yusukebe
Copy link
Member

@yusukebe yusukebe commented May 10, 2024

With this PR, we can put island components anywhere instead of under /app/routes or /app/islands. For example, the components placed like the following will be treated as islands.

  • /app/components/$counter.tsx
  • /app/components/_counter.island.tsx

In addition, I've added the following changes:

  • Made it islands directory only ^/islands or specify the path if passing the option.
  • Corrected importing path of client components in the client.
  • Simplify some options.
  • Fixed resolving alias path.
  • Added some missing tests.

Fixes #159

@yusukebe yusukebe marked this pull request as draft May 10, 2024 10:32
@yusukebe yusukebe marked this pull request as ready for review May 11, 2024 01:13
@yusukebe
Copy link
Member Author

I was thinking of making it based on @liltechnomancer 's code, but there has been a big difference. So, I can't add @liltechnomancer as a co-author, but your comment was helpful!

@yusukebe
Copy link
Member Author

Hi @usualoma !

Could you review this one?

Copy link
Member

@usualoma usualoma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. I think it is a good change!
I made one comment, please check it out.

...import.meta.glob('/app/routes/**/_[a-zA-Z0-9[-]+.island.(tsx|ts)'),
...import.meta.glob('/app/islands/**/[a-zA-Z0-9-]+.(tsx|ts)'),
...import.meta.glob('/app/**/_[a-zA-Z0-9-]+.island.(tsx|ts)'),
...import.meta.glob('/app/**/$[a-zA-Z0-9-]+.(tsx|ts)'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It has nothing to do with this PR change, In matchIslandComponentId(), only .tsx matches (.ts does not), so I think only .tsx` should be used here as well.

https://github.com/honojs/honox/pull/176/files#diff-4b7b8acce4bb320abe3a28d1bb85d7ad346253af647225df7e62d19891192a27R25

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@usualoma

You are right! It should be only .tsx and it's not a problem if it does not support .ts.

@yusukebe
Copy link
Member Author

Thanks @usualoma !

I've fixed it. I'll merge this right now.

@yusukebe yusukebe merged commit 5287f7d into main May 11, 2024
2 checks passed
@yusukebe yusukebe deleted the feat/island-component-anywhere branch May 11, 2024 09:37
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.

It would be nice to place islands anywhere, not just in routes and islands directories.
2 participants