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 1c14fe3 commit 8729136
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions packages/waku/src/lib/plugins/vite-plugin-deploy-aws-lambda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,24 @@ const getServeJsContent = (
) => `
import path from 'node:path';
import { existsSync, readFileSync } from 'node:fs';
import { runner, importHono, importHonoContextStorage, importHonoNodeServerServeStatic, importHonoAwsLambda } from 'waku/unstable_hono';
import { runner, importHono, importHonoNodeServerServeStatic, importHonoAwsLambda } from 'waku/unstable_hono';
const { Hono } = await importHono();
const { contextStorage } = await importHonoContextStorage();
const { serveStatic } = await importHonoNodeServerServeStatic();
const { handle } = await importHonoAwsLambda();
let contextStorage;
try {
({ contextStorage } = await import('hono/context-storage'));
} catch {}
const distDir = '${distDir}';
const publicDir = '${distPublic}';
const loadEntries = () => import('${srcEntriesFile}');
const app = new Hono();
app.use(contextStorage());
if (contextStorage) {
app.use(contextStorage());
}
app.use('*', serveStatic({ root: distDir + '/' + publicDir }));
app.use('*', runner({ cmd: 'start', loadEntries, env: process.env }));
app.notFound(async (c) => {
Expand Down Expand Up @@ -71,6 +76,9 @@ export function deployAwsLambdaPlugin(opts: {
if (id === `${opts.srcDir}/${SERVE_JS}`) {
return getServeJsContent(opts.distDir, DIST_PUBLIC, entriesFile);
}
if (id === 'hono/context-storage') {
return '';
}
},
closeBundle() {
const { deploy, unstable_phase } = platformObject.buildOptions || {};
Expand Down

0 comments on commit 8729136

Please sign in to comment.