H
Hono4w ago
Ray

Using hono with bundlers (tsup)

Is it possible to avoid the "Module 'hono' declares 'Hono' locally, but it is not exported" when using moduleResolution set to bundler? The only configuration I've found to work is strict ESM: * "module": "nodenext" * "moduleResolution": "nodenext" * "type": "module" in package.json This is problematic since I'm working with an large existing codebase that omits file extensions and automatic index resolution. Related issue: https://github.com/honojs/hono/issues/4474
GitHub
Hono bundler support (module import error) · Issue #4474 · honojs...
What is the feature you are proposing? Hi Hono team, I'd like like incrementally migrate a large Express project running on Node.js to Hono. We use Tsup as our bundler and cannot switch to pure...
2 Replies
ambergristle
ambergristle4w ago
this works fine
{
"compilerOptions": {
"module": "preserve",
"moduleResolution": "bundler",
"strict": true,
}
}
{
"compilerOptions": {
"module": "preserve",
"moduleResolution": "bundler",
"strict": true,
}
}
Ray
RayOP3w ago
Hmm somehow after fiddling with my tsup.config.ts and tsconfig.json it worked! Thanks for the help.
// tsup.config.ts
export default defineConfig({
entry: ['./src/index.ts'],
format: 'cjs',
target: 'node22',
sourcemap: true,
cjsInterop: true,
});

// tsconfig.json
{
"compilerOptions": {
"module": "preserve",
"moduleResolution": "bundler",
"strict": true,
}
}
// tsup.config.ts
export default defineConfig({
entry: ['./src/index.ts'],
format: 'cjs',
target: 'node22',
sourcemap: true,
cjsInterop: true,
});

// tsconfig.json
{
"compilerOptions": {
"module": "preserve",
"moduleResolution": "bundler",
"strict": true,
}
}

Did you find this page helpful?