@@ -2,6 +2,8 @@ import { serve } from '@hono/node-server'
22import { serveStatic } from '@hono/node-server/serve-static'
33import { transformSync } from 'amaro'
44import { Hono } from 'hono'
5+ import * as path from 'node:path'
6+ import { fileURLToPath } from 'node:url'
57import * as puppeteer from 'puppeteer'
68import type { Runtime } from './main.ts'
79
@@ -13,23 +15,25 @@ export async function create_browser_runtime(): Promise<Runtime> {
1315
1416 const app = new Hono ( )
1517
16- app . get ( '/@runner' , c =>
17- c . html ( `
18+ app . get ( '/@runner' , c => {
19+ const pkg = ( specifier : string ) => '/' + path . relative ( '.' , fileURLToPath ( import . meta. resolve ( specifier ) ) )
20+
21+ return c . html ( `
1822 <!doctype html>
1923 <link rel="icon" href="data:" />
2024 <script type="importmap">${ JSON . stringify ( {
2125 imports : {
2226 dhtml : '/dist/index.js' ,
2327 'dhtml/client' : '/dist/client.js' ,
2428 'dhtml/server' : '/dist/server.js' ,
25- birpc : '/node_modules/ birpc/dist/index.mjs' ,
26- devalue : '/node_modules/ devalue/index.js' ,
27- mitata : '/node_modules/ mitata/src/main.mjs' ,
29+ birpc : pkg ( ' birpc' ) ,
30+ devalue : pkg ( ' devalue' ) ,
31+ mitata : pkg ( ' mitata' ) ,
2832 } ,
2933 } ) } </script>
3034 <script type="module" src="/scripts/test/runtime.ts"></script>
31- ` ) ,
32- )
35+ ` )
36+ } )
3337
3438 app . use ( async ( c , next ) => {
3539 await next ( )
0 commit comments