Error while building Pages Functions from monorepo (nx): Could not resolve

I have a monorepo that contains a Pages project and a library that the Pages _worker.js function depends on. During the CF build I get the following error (which works fine locally).
22:20:45.746 > build:functions
22:20:45.746 > esbuild ./src/functions/_worker.ts --bundle --format=cjs --outfile=./dist/_worker.js
22:20:45.778 [ERROR] Could not resolve "@dxos/web-auth"
22:20:45.746 > build:functions
22:20:45.746 > esbuild ./src/functions/_worker.ts --bundle --format=cjs --outfile=./dist/_worker.js
22:20:45.778 [ERROR] Could not resolve "@dxos/web-auth"
I suspect this might be related to the module being part of a monorepo?
4 Replies
richburdon
richburdonOP8mo ago
22:51:38.594 Finished
22:51:38.595 Found _worker.js in output directory. Uploading.
22:51:39.646 ✨ Compiled Worker successfully
22:51:39.679 Validating asset output directory
22:51:40.484 Deploying your site to Cloudflare's global network...
22:51:44.433 Uploading... (22/29)
22:51:45.047 Uploading... (24/29)
22:51:45.328 Uploading... (27/29)
22:51:45.770 Uploading... (29/29)
22:51:45.770 ✨ Success! Uploaded 7 files (22 already uploaded) (1.57 sec)
22:51:45.770
22:51:46.086 ✨ Upload complete!
22:51:48.920 Success: Assets published!
22:51:50.874 Error: Failed to publish your Function. Got error: multipart uploads must contain a readable body_part or main_module
22:51:38.594 Finished
22:51:38.595 Found _worker.js in output directory. Uploading.
22:51:39.646 ✨ Compiled Worker successfully
22:51:39.679 Validating asset output directory
22:51:40.484 Deploying your site to Cloudflare's global network...
22:51:44.433 Uploading... (22/29)
22:51:45.047 Uploading... (24/29)
22:51:45.328 Uploading... (27/29)
22:51:45.770 Uploading... (29/29)
22:51:45.770 ✨ Success! Uploaded 7 files (22 already uploaded) (1.57 sec)
22:51:45.770
22:51:46.086 ✨ Upload complete!
22:51:48.920 Success: Assets published!
22:51:50.874 Error: Failed to publish your Function. Got error: multipart uploads must contain a readable body_part or main_module
ok resolved. needed --format=esm not cjs
Dilip kumar tekwani
Hello @richburdon I wanted to ask few things from you, If I am not mistaken then you are using Cloudflare pages plus nx monorepo next.js apps right?? Actually we are also using same, we have next js several application in our nx monorepo, which we want to deploy on Cloudflare pages, but after deployment it don't work as build must be done using next-on-pages plugin. And I am stuck on the build issue, so could you please let me know how we can achieve build for each app separately.
richburdon
richburdonOP8mo ago
hi Dilip. i am using CF and NX but we're not useing next.js -- i'm using hono and other technologies. i'm new to this, but my understanding is that w dev initiates an esbuild and will try to respect your local tsconfig rules; i don't have any experience with nextjs i have found the people on the site to be very helpful if you give them the actual build errors you're seeing in a new thread on #general-help if wrangler pages dev works for you then the GH deploy should also work so i would start there. best of luck.
Dilip kumar tekwani
Thanks, let me check this, thank you for reverting back.
Want results from more Discord servers?
Add your server