Can't create Pages site with Durable Object

I am trying to make a Cloudflare Pages site using Durable Objects. I have a class Mask defined in ./durable_objects/Mask.ts. It only implements the basic constructor.

In wrangler.toml I have

[durable_objects]
bindings = [{ name = "MASK", class_name = "Mask" }]

[[migrations]]
tag = "v1"
new_classes = ["Mask"]

When I try to run the site locally with wrangler pages dev I get the following error.

service core:user:worker: Uncaught TypeError: Class extends value undefined is not a constructor or null
  at functionsWorker-0.9520352929258784.js:684:44 in maskDurableObjectDefinition
  at functionsWorker-0.9520352929258784.js:693:13
✘ [ERROR] MiniflareCoreError [ERR_RUNTIME_FAILURE]: The Workers runtime failed to start. There is likely additional logging output above.

Adding the --experimental-json-config I get the same error, if add --do MASK=Mask I get an error which boils down to The symbol "Mask" has already been declared

So how do I properly declare and use a durable object with Cloudflare Pages?

I had the same issue but finally figured it out. It’s not well documented at all.
Here’s an example setup I use:
api/ - folder with durable object code & wrangler.toml. worker name = “my-api”, do binding name = “MY_DO” class_name = “MyDo”
web/ - folder with pages (some SSR framework).

  1. start wrangler dev in api folder
  2. start wrangler pages dev -o MY_DO=MyDo@my-api in web folder

the two wrangler instances will now link and pages will be able to call the local running dev DO.

Hope that helps!