@@ -3,7 +3,7 @@ import * as esbuild from 'esbuild'
33import type { Hono } from 'hono'
44import { buildInitParams , serializeInitParams } from 'hono/router/reg-exp-router'
55import { execFile } from 'node:child_process'
6- import { existsSync , realpathSync } from 'node:fs'
6+ import { existsSync , realpathSync , statSync } from 'node:fs'
77import { dirname , join , resolve } from 'node:path'
88import { buildAndImportApp } from '../../utils/build.js'
99
@@ -33,6 +33,7 @@ export function optimizeCommand(program: Command) {
3333 external : [ '@hono/node-server' ] ,
3434 } )
3535
36+ let routerName
3637 let importStatement
3738 let assignRouterStatement
3839 try {
@@ -54,22 +55,28 @@ export function optimizeCommand(program: Command) {
5455 } )
5556
5657 if ( hasPreparedRegExpRouter ) {
58+ routerName = 'PreparedRegExpRouter'
5759 importStatement = "import { PreparedRegExpRouter } from 'hono/router/reg-exp-router'"
5860 assignRouterStatement = `const routerParams = ${ serialized }
5961 this.router = new PreparedRegExpRouter(...routerParams)`
6062 } else {
63+ routerName = 'RegExpRouter'
6164 importStatement = "import { RegExpRouter } from 'hono/router/reg-exp-router'"
6265 assignRouterStatement = 'this.router = new RegExpRouter()'
6366 }
6467 } catch {
6568 // fallback to default router
69+ routerName = 'TrieRouter'
6670 importStatement = "import { TrieRouter } from 'hono/router/trie-router'"
6771 assignRouterStatement = 'this.router = new TrieRouter()'
6872 }
6973
74+ console . log ( `Router: ${ routerName } ` )
75+
76+ const outfile = resolve ( process . cwd ( ) , options . outfile )
7077 await esbuild . build ( {
7178 entryPoints : [ appFilePath ] ,
72- outfile : resolve ( process . cwd ( ) , options . outfile ) ,
79+ outfile,
7380 bundle : true ,
7481 minify : options . minify ,
7582 format : 'esm' ,
@@ -118,5 +125,8 @@ export class Hono extends HonoBase {
118125 } ,
119126 ] ,
120127 } )
128+
129+ const outfileStat = statSync ( outfile )
130+ console . log ( `App: ${ options . outfile } (${ ( outfileStat . size / 1024 ) . toFixed ( 2 ) } KB)` )
121131 } )
122132}
0 commit comments