hono: __STATIC_CONTENT_MANIFEST error when bundling with Cloudflare's wrangler.
When using Hono@3.2.1 for Cloudflare’s Workers, when bundling with Wrangler or ESbuild I get this error when importing serveStatic
from hono/cloudflare-workers
✘ [ERROR] Could not resolve "__STATIC_CONTENT_MANIFEST"
node_modules/hono/dist/adapter/cloudflare-workers/server-static-module.js:2:21:
2 │ import manifest from "__STATIC_CONTENT_MANIFEST";
╵ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
You can mark the path "__STATIC_CONTENT_MANIFEST" as external to exclude it
from the bundle, which will remove this error.
1 error
Even when I mark it as external
and exclude it form the bundle
When running the worker I get an error stating Uncaught SyntaxError: Cannot use import statement outside a module
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 8
- Comments: 22 (19 by maintainers)
@Code-Hex
Dynamic import!
Perhap, can we do that with this code?
@Code-Hex
Yes, ideally, we should support it. However, I think our current status is sufficient.
This is a matter of perspective. For the development phase, if we want fast reloading, we should use the
public
directory rather than a workers site. Vite can handle thepublic
directory, but workers sites works in worked, which might be slower.The reason I created the Vite plugin
@hono/vite-dev-server
is to use fast features like fast reloading or HMR (though it currently doesn’t support SSR). Therefore, using thepublic
directory for development makes sense to me.Hi @JeffBue,
Try using esbuild with this command:
But it shouldn’t throw an error when using Wrangler.