aleksandr
aleksandr
CDCloudflare Developers
Created by aleksandr on 9/7/2024 in #pages-help
Documentation on using wrangler.toml to configure a Pages project (not workers/functions)
No description
2 replies
CDCloudflare Developers
Created by aleksandr on 9/1/2024 in #workers-help
Are Page Functions bundled differently than regular Workers?
Does anyone know if Page Functions are bundled differently than regular Workers that you deploy via 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:
.
├── config
│   └── utils.js
├── functions
│   ├── api
│   │   └── comments.ts
│   └── tsconfig.json
├── package.json
├── pnpm-lock.yaml
├── src
├── wrangler.toml
└── wrangler.toml.example
.
├── config
│   └── utils.js
├── functions
│   ├── api
│   │   └── comments.ts
│   └── tsconfig.json
├── package.json
├── pnpm-lock.yaml
├── src
├── wrangler.toml
└── wrangler.toml.example
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 package.json at the root of the project.
5 replies
CDCloudflare Developers
Created by aleksandr on 8/31/2024 in #workers-help
Unable to test Cloudflare Page Function: [wrangler:err] Error: No response!
No description
9 replies