Are Page Functions bundled differently than regular Workers?
Does anyone know if Page Functions are bundled differently than regular Workers that you deploy via
I have a Worker that lives in the same project directory as a Cloudflare Pages site.
My Worker fetches data from an external API: https://github.com/AleksandrHovhannisyan/aleksandrhovhannisyan.com/blob/977e2c600ec5c629db61f8ee2eaee60e1ef86923/functions/api/comments.ts
This works as expected when deployed as a regular worker via
However, if I try to convert this worker to be a Page Function so that I don't have to manually re-deploy it every time, I get errors in my deploy logs saying certain external node modules (e.g.,
My
This setup only works with a regular worker, not a Page Function.
I'm not sure if it makes any difference, but:
wrangler deploy?I have a Worker that lives in the same project directory as a Cloudflare Pages site.
My Worker fetches data from an external API: https://github.com/AleksandrHovhannisyan/aleksandrhovhannisyan.com/blob/977e2c600ec5c629db61f8ee2eaee60e1ef86923/functions/api/comments.ts
This works as expected when deployed as a regular worker via
wrangler deploy . All external modules are included/bundled in the final code and my client code is able to read the responses.However, if I try to convert this worker to be a Page Function so that I don't have to manually re-deploy it every time, I get errors in my deploy logs saying certain external node modules (e.g.,
prismjs) could not be resolved. These modules are being imported by the Page Function through other modules outside my functions/ directory. Basically, here is a simplified view of my project structure:My
functions/api/comments.ts script imports shared modules from ../../config/*, such as for Markdown processing (I reuse the same Markdown processor to parse comments as I do on my site).This setup only works with a regular worker, not a Page Function.
I'm not sure if it makes any difference, but:
- I am using pnpm as my package manager (I don't think this is related).
- I am not using pnpm workspaces (maybe this is related?). I have just one
at the root of the project.package.json
