Creating wrangler.toml to deploy Pages

Hello.
I am struggling hard with node compatibility issues. I followed the documentation - https://developers.cloudflare.com/workers/wrangler/configuration/#use-runtime-apis-directly where found the possible solution and need to add polyfills to my build (SvelteKit + Cloudflare Pages adapter) using Wrangler.

I tried to use runtime APIs directly but it does not work. Managed to manually set compatibility flags in Cloudflare dashboard to be nodejs_compat but it did not change the behaviour and the issue is still there.

Hence, it seems to me the only way to make it work is to deploy Pages manually using Wrangler but it’s difficult to me to find the right configuration set for wrangler.toml. I am new to Cloudflare and everything feels so mixed up between workers and pages.

I am trying to do something like:

name = "<pages project name>"
main = ".svelte-kit/cloudflare/_worker.js"
compatibility_date = "2024-02-01"

workers_dev = false
build = "npm run build"
node_compat = true

when I use: wrangler pages deploy it asks me for a directory. When I use wrangler deploy it throws an error: Cannot use 'in' operator to search for 'upload' in npm run build.

There is no issue deploying the project via Github upon push but without being able to add this flag the project is garbage.

Could you point me to the direction how the example config for pages project deployment should look like or advice how else I can turn on adding polyfills using Wrangler?

Pages doesn’t use wrangler.toml. Add compatibility flags to the Pages project in the Cloudflare dashboard as per this documentation.

The Cloudflare docs say the following, which makes me believe Pages can use wrangler.toml after all:

Note: If you have a wrangler.toml file configured for your Pages project, you can run wrangler pages dev without specifying a directory.

Yep it’s supported now

1 Like