12 Replies
You mean like multiple
wrangler dev
calls?Yup
i see! so my repo directory structure should be like:
essentially a module (with
package.json
+ wrangler.toml
inside a subdirectory of my Pages repo)
ah, figured it out!Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
yep! i was able to get a worker in the pages deploy to bind to a durable object, both locally and remotely
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
haha, that's what i did too, using the discord search function scoped to the #durable-objects channel 🙂
I think this is demonstrable proof that DO and DO+Pages needs better documentation...
@ar0man do you happen to have any proof of concept code online I can look at? Does my DO really need a worker associated with it? And when Pages uses the DO, does it go through the worker or interact with the DO directly?
Yes, and no, not necessarily
Basically, the Worker is only needed to publish the DO class. It doesn't need any of the normal Worker logic. It could be as simple as Notice the lack of
export default
This also means that you can bind directly to the DO from your Functions, and not have to invoke the Worker itself at allthanks - i've tried that, I have a
src/index.tx
that exports just
and wrangler.toml
like this:
but when I wrangler publish
, it says
so i'm guessing something wrong with the wrangler.toml?What if you do
Oh wait
Bundle it first, then change the main
Or just add an to the file
that did it! (adding
export default {}
). thanks.
Hmm... but I can't get it to show up in my pages project. I added to my wrangler pages
command, and when it starts it says but does not show up in context.env
in my request handler...
Oh, never mind. i was running the do with wrangler dev
instead of wrangler dev --local