fiberplane / fpx

Supercharge your local development
https://fiberplane.dev
MIT License
154 stars 3 forks source link

SST Support #248

Open austinm911 opened 2 months ago

austinm911 commented 2 months ago

I'm running hono on a cloudflare worker using SST in a monorepo. Any guidance here?

keturiosakys commented 2 months ago

Hey @austinm911, thanks for checking us out! I'm gonna try to figure out SST support live :D here's my simple model repo: https://github.com/keturiosakys/cloudflare-hono-sst

In theory it should work without any extra modifications. You simply need to import the instrument function, wrap your exported app object from Hono, and run npx sst dev.

However, looks like SST doesn't like the Node.js dependencies our client library depends on as I've gotten the error below. The nodejs_compat flag is enabled in wrangler.toml but I'm not sure why SST is ignoring that... will keep you posted!

node:http error:

|  Error       Hono sst:cloudflare:Worker → HonoScript cloudflare:index:WorkerScript
|    sdk-v2/provider2.go:385: sdk.helper_schema: error creating worker script: Uncaught Error: No such module "node:http".
  imported from "worker.mjs"
 (10021): provider=cloudflare@5.37.1
|  Error       Hono sst:cloudflare:Worker → HonoScript cloudflare:index:WorkerScript
|  Error: No such module "node:http".
|  imported from "worker.mjs"
|  (10021)

✕  Failed
   Hono sst:cloudflare:Worker → HonoScript cloudflare:index:WorkerScript
     sdk-v2/provider2.go:385: sdk.helper_schema: error creating worker script: Uncaught Error: No such module "node:http".
  imported from "worker.mjs"
 (10021): provider=cloudflare@5.37.1
   Hono sst:cloudflare:Worker → HonoScript cloudflare:index:WorkerScript
   Error: No such module "node:http".
   imported from "worker.mjs"
   (10021)
austinm911 commented 2 months ago

@keturiosakys it might be a similar issue to https://github.com/sst/sst/issues/4677. I tried adding the esbuild options suggested and wasn't able to get it working.

Also, probably worth noting I don't see SST projects use a wrangler/dev.vars file since everything is configured in the sst.config.ts file https://github.com/sst/ion/tree/dev/examples/cloudflare-hono. Not sure if that impacts the way fpx is setup

keturiosakys commented 2 months ago

Gotcha, looks similar - will ask the SST team about it