Skip to content

hono/logger fails to compile: dynamic import() with non-literal path in hono/utils/color.js #1725

Description

@proggeramlug

Scope

import { logger } from 'hono/logger' fails to compile under Perry-native. hono/logger pulls in hono/dist/utils/color.js, which uses a dynamic import() whose path argument isn't a literal:

Error: dynamic import() in module node_modules/hono/dist/utils/color.js: path argument
references a binding that is not a module-level const initialized to a literal (only string
literals, ternaries, template literals over const locals, and the module-level consts
themselves are supported)

This blocks the app.use('*', logger()) line in the #1655 acceptance program.

Repro (Perry @ main 6a77dd7, hono@4.10)

import { Hono } from 'hono'
import { logger } from 'hono/logger'
const app = new Hono()
app.use('*', logger())
app.get('/', (c) => c.text('ok'))

perry compile app.tsx → the error above.

Context

#1655 explicitly lists dynamic imports as "out of scope … call-site workarounds exist", so this may be WONTFIX for the tracker — but the literal 30-line acceptance program uses logger(), so flagging it. Options: (a) relax the dynamic-import guard for this color-detection pattern, (b) treat hono/logger as needing a compilePackages-level shim, or (c) accept it as out-of-scope and drop logger() from the acceptance.

The rest of the acceptance (HTML via c.html(<Layout/>), c.json, query parsing, POST body) works end-to-end through @hono/perry-server — only logger() is blocked.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions