HonoH
Hono•10mo ago
Masami Ogasawara

How can I resolve bundle error with Hono and Bun in monorepo

Hi, could you please tell me how to resolve bundle error with Hono and Bun in monorepo?

What I want to do

I have created my own Web Components framework.
I want to import this framework in the test application with Hono.

Current situation

Current directory architecture is here:
  • root
    • packages: Web Components framework
    • examples: test applications
This is monorepo architecture.

And I executed the following steps.
  1. transpile packages and create JS files and d.ts files to dist directory in packages
  2. load transpiled JS files in
    package.json
    of examples directory as follows:
    package.json
    "dependencies": {
     "[my-framework]": "*",
     "@hono/node-server": "^1.13.8",
     "hono": "^4.7.1"
    },
  3. execute bun i and check packages is existed in node_modules
  4. move to examples directory
  5. execute rm -rf dist && bunx tsc && bunx postcss src/**/*.css --dir dist && bun run --hot app.ts
  6. check whether the architecture dist directory in examples is correct
  7. access to localhost
## Error
The error Uncaught TypeError: Failed to resolve module specifier "[my framework]". Relative references must start with either "/", "./", or "../". is occurred in browser console.

Upon checking JS files in dist, the pass has not been resolved.
 import { xxx } from [my-framework](absolute path)

How can I resolve it?🤔
Was this page helpful?