-
-
Notifications
You must be signed in to change notification settings - Fork 125
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
Update cloudflare with hono/context-storage external build fix #911
Update cloudflare with hono/context-storage external build fix #911
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
if (source === 'hono/context-storage') { | ||
return { id: source, external: true }; | ||
} |
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.
Hmm, actually this is effective for all the case. Let me see if I can fix.
Actually, @aheissenberger was right. It was my bad. |
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.
I added more commits, but it should be fine.
If there are still some issues, feel free to open PRs.
Oh interesting. Either solution seemed to work from my perspective but I am not using |
Oh, no... I'm going the circle... Let me check it too. |
As far as I tried |
Yeah, this did not work for me unless I update back to import from unstable_hone. Then it works fine. Either is ok with me. It was nice with the version I originally committed here. I was able to bring my own hono (tested with 4.6.3). |
I will test AWS next. I only tested Cloudflare so far. |
Same issue in my aws build. getContext fails if I import from 'hono/context-storage' instead of 'waku/unstable_hono'. |
Maybe it's only |
Hmmm? I think I miss something. Can you try |
When I copy 08_cookies App and Counter components into an empty page on my app, I get a fatal error Error - Context is not available The issue is caused because the entry point ("serve js") for the deploy plugins loads getContext() from waku/unstable_hono with the latest change. It worked better IMHO when the deploy plugins imported from hono/context-storage and let the deploy server bundle include the app's copy of hono/context-storage rather than waku's. Then my app server components received the same bundled version of hono that I supplied. |
From my investigation, importHonoContextStorage and hono/context points to the same file after the build. Let me try it again. pnpm -r --filter='./packages/waku' run compile
cd examples/08_cookies
node ../../packages/waku/dist/cli.js build --with-cloudflare
npx wrangler pages dev Actually I get a different error (unexpected):
But, that brings me a question, how is your setup different? |
You're right. It does work if I deploy from examples/08_cookies directly but I think it is a side-effect of being in the same monorepo. If you change the hono version in 08_cookies to 4.6.3, you will be able to reproduce the error. I thought I already tested using 4.6.1 from my other apps and it didn't work, but I could try again. Even if it does work, it's probably not an ideal solution. This fixes: --- a/packages/waku/src/lib/plugins/vite-plugin-deploy-cloudflare.ts
+++ b/packages/waku/src/lib/plugins/vite-plugin-deploy-cloudflare.ts
@@ -17,16 +17,22 @@ import { DIST_ENTRIES_JS, DIST_PUBLIC } from '../builder/constants.js';
const SERVE_JS = 'serve-cloudflare.js';
const getServeJsContent = (srcEntriesFile: string) => `
-import { runner, importHono, importHonoContextStorage } from 'waku/unstable_hono';
+import { runner, importHono } from 'waku/unstable_hono';
+
+let contextStorage;
+try {
+ ({ contextStorage } = await import('hono/context-storage'));
+} catch {}
const { Hono } = await importHono();
-const { contextStorage } = await importHonoContextStorage();
const loadEntries = () => import('${srcEntriesFile}');
let serveWaku;
const app = new Hono();
-app.use(contextStorage());
+if (contextStorage) {
+ app.use(contextStorage());
+}
app.use('*', (c, next) => serveWaku(c, next));
app.notFound(async (c) => {
const assetsFetcher = c.env.ASSETS; |
^ same patch works for aws for me too. |
I think I tried it standalone too.
Ah, that explains. Well, then I change my opinion. If you use a different hono version, |
Or, I can revert it right away, because this hasn't been released yet. |
#914 |
at least for now. this reverts #891 and re-introduce #852 and #884. #911 (comment)
I see. No problem! That works. Thank you so much. |
re: #882 (comment)
Applies the same fix used for handling hono/context-storage with aws builds.