-
Notifications
You must be signed in to change notification settings - Fork 43
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: preserved file island support #114
Conversation
@yusukebe This PR is for the question I asked at X (https://x.com/yusukebe/status/1765727221526983014?s=20). However, the options I set for jsxRenderer like docType are no longer being applied and I am stuck without a good solution. Any suggestions? |
I understand. |
Okay @yossydev! Please let me know if the coding is finished. Thanks! |
3a0ac28
to
c5a85fc
Compare
@yusukebe |
c5a85fc
to
c13fc9b
Compare
Hi @yossydev Thanks for the PR. I think we can make this code short. In this case, the value of diff --git a/src/server/server.ts b/src/server/server.ts
index 4fd73ef..a682531 100644
--- a/src/server/server.ts
+++ b/src/server/server.ts
@@ -103,18 +103,14 @@ export const createApp = <E extends Env>(options: BaseServerOptions<E>): Hono<E>
const rendererPaths = getPaths(dir, rendererList)
rendererPaths.map((path) => {
const renderer = RENDERER_FILE[path]
- const setInnerMeta = createMiddleware(async function innerMeta(c, next) {
- // @ts-expect-error renderer[importing_islands_id] is not typed
- const importingIslands = renderer[IMPORTING_ISLANDS_ID] as boolean
- if (importingIslands) {
- hasIslandComponent = true
- }
- c.set(IMPORTING_ISLANDS_ID as any, importingIslands)
- await next()
- })
+ // @ts-expect-error it is not types
+ const importingIslands = renderer[IMPORTING_ISLANDS_ID] as boolean
+ if (importingIslands) {
+ hasIslandComponent = true
+ }
const rendererDefault = renderer.default
if (rendererDefault) {
- subApp.all('*', rendererDefault, setInnerMeta)
+ subApp.all('*', rendererDefault)
}
})
@@ -136,9 +132,7 @@ export const createApp = <E extends Env>(options: BaseServerOptions<E>): Hono<E>
// @ts-expect-error route[IMPORTING_ISLANDS_ID] is not typed
const importingIslands = route[IMPORTING_ISLANDS_ID] as boolean
const setInnerMeta = createMiddleware(async function innerMeta(c, next) {
- if (!hasIslandComponent) {
- c.set(IMPORTING_ISLANDS_ID as any, importingIslands)
- }
+ c.set(IMPORTING_ISLANDS_ID, importingIslands ? true : hasIslandComponent)
await next()
}) |
Thanks! One thing. We have to consider the name of the test application. Currently, you named the app as |
@yusukebe Thank you for the review!! I have made the correction here: edf3f23 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Thanks! Let's go with it. |
Overview
Files of the preserved series in this PR,
When the client component is imported with _renderer.tsx and _404.tsx, js is loaded on the client.
Context
When I made a blog with HonoX before, I imported the island component I made in _renderer.tsx, but currently, JS was not loaded on the client even if I added it to the preserved system file.