Workaround to import third-party libs on Workers Scripts?

I'm trying to build a full-stack app using Hono + ReactJS with Cloudflare Workers for Platforms. My pipeline now involves generating the components, sending these components to Cloudflare Containers, in Containers, I'm compiling React with Vite, and creating the Worker Script. I made a simple API that returns some hard-coded products with IDs and prices. Then I return these scripts, and upload them to Workers for Platforms using formData.append It is all working and is actually fetching data But I would like to extend this back-end to use Hono or create more complex API logic using any other third-party library. How can I do it? Am I thinking about it in the wrong way? How could I use Workers for Platforms to create a more complex back-end logic? I thought about bundling Hono or the lib. I needed as a new script with a new formData append, but it sounds awkward to me
2 Replies
vitor
vitorOP3w ago
Yeah seems like I need to do the bundling by myself So I would need to bundle the script I wanna run, and upload the bundled version to Workers for Platforms I will follow this approach and soon I will be back with something :pepe_coding: It worked
James
James3w ago
seems at first glance you're making this way too complicated than it needs to be, maybe go have a conversation w a gpt about how to efficiently bundle any js libs to a worker

Did you find this page helpful?