Skip to content

Commit

Permalink
follow #898 change
Browse files Browse the repository at this point in the history
  • Loading branch information
dai-shi committed Sep 24, 2024
1 parent bc9e68c commit 8ba7f22
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions packages/waku/src/lib/plugins/vite-plugin-deploy-partykit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,21 @@ import { DIST_PUBLIC } from '../builder/constants.js';
const SERVE_JS = 'serve-partykit.js';

const getServeJsContent = (srcEntriesFile: string) => `
import { runner, importHono, importHonoContextStorage } from 'waku/unstable_hono';
import { runner, importHono } from 'waku/unstable_hono';
const { Hono } = await importHono();
const { contextStorage } = await importHonoContextStorage();
let contextStorage;
try {
({ contextStorage } = await import('hono/context-storage'));
} catch {}
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;
Expand Down Expand Up @@ -92,6 +97,9 @@ export function deployPartykitPlugin(opts: {
if (id === `${opts.srcDir}/${SERVE_JS}`) {
return getServeJsContent(entriesFile);
}
if (id === 'hono/context-storage') {
return '';
}
},
closeBundle() {
const { deploy, unstable_phase } = platformObject.buildOptions || {};
Expand Down

0 comments on commit 8ba7f22

Please sign in to comment.