-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrap the Cloudflare Worker runtime APIs #138
Comments
What about using ScalablyTyped to generate the Scala defs as an initial start? |
As an initial start, we can grab most of these from existing places. I've already done some in #4.
My preference would be not to expose the facades at all if possible. I think that's what I was doing in #4, but it's been a while. Would be great if you'd like to pick this up :) my main concern was figuring out a way to actually test this. |
I don't know much about Feral, or Cloudflare Workers :P. But for testing, am I misunderstanding something? We should be able to test with https://developers.cloudflare.com/workers/wrangler/ right? |
Sounds like a great learning opportunity! :P
Yes, actually I've had my eye on https://miniflare.dev/ for testing. But wiring it up is non-trivial :) I started a branch doing that here: |
I read up on Miniflare recently and from Cloudflare's blog: https://blog.cloudflare.com/workerd-open-source-workers-runtime/
|
I'll check out the #4 PR, but from a cursory glance it looks hella intimidating :P. So it uses facades, but provides a very functional-programming-y interface on top of it using cats effect and fs2? |
Interesting! Well I guess we should toss that miniflare branch then 😂 Thanks for sharing, that's pretty cool. I'll have to look at it more closely to figure out how we might use it. It also reminded me that cloudflare workers supports WASM, and Scala Native will support WASM in the next major release. So that's something to keep in mind as well 🤔
Yes, that's the idea. http4s-dom does a similar thing, as does the Feel free to comment directly on the PR with questions! |
I asked in the scala-native discord channel about Scala Native wasm examples, but I didn't know it was slated for next release, thought it was in already haha. I guess the hard part of contributing to that PR is, the fact that I've never written/worked on a FP library, I've only consumed them! |
Yes, check out https://github.com/shadaj/scala-native-wasm
Yep it was already merged into the 0.5.x branch, in theory you can publish a snapshot and start playing it.
Personally I find it quite fun to figure out how to wrap some (god awful) non-FP API with CE3/FS2 😃 |
It does sound quite fun, I just have never done it :P. So let's try this out!
|
@zetashift personally I merge instead of rebase 😜 but yes!! 🚀
I'm quite interested about this part too :) |
So this seems to be a bit of a rabbithole. This is as far I know the current situation.
So I think we should still use Miniflare, but for the developer experience that will mean actually using |
I agree.
I'm less sure about this. I wonder if instead of working with the wrangler CLI, we can directly use the Miniflare JS API. This is essentially what I was exploring in armanbilge/scala-js-env-jsdom-nodejs@7f6081c. |
Ah yea! You posted this link before, but I couldn't really grasp the implications.I'll look into the Miniflare API more (the docs seem solid from a first glance) and figure out what this whole |
Right, I cheated by starting with a fork of this project because it does a similar thing and trying to modify it for miniflare: https://github.com/scala-js/scala-js-env-jsdom-nodejs Basically, JSDOM is a thing that lets you emulate browser APIs inside of Node.js. https://github.com/jsdom/jsdom Similarly, Miniflare is a thing that lets you emulate Cloudflare APIs inside of Node.js. (Or at least it used to be, not sure if workerd has changed that.) The scala-js-env-jsdom-nodejs lets you run your Scala.js tests inside of the JSDOM environment. So in theory seems like we should be able to do basically the same thing except with Miniflare. |
Right that clears a lot up, thank you! Look at miniflare's code it, it just seems to talk to a local workerd runtime https://github.com/cloudflare/miniflare/blob/v3.0.0-next.2/packages/tre/src/index.ts Wouldn't it be better to have bindings to Miniflare(which does all the hard work of talking to workerd) then that are used for running tests locally? EDIT: I guess that's what you did in your |
With the new Miniflare, you are right that we would have a Node.js process calling to Miniflare calling to workerd. Which raises the question, why don't we just build a JSEnv that directly runs on workerd? And I think we've come full circle 😅 |
Many of these are very similar to existing Web APIs, but slightly different. So we should probably facade and wrap them ourselves :(
Typescript available here:
https://github.com/cloudflare/workers-types/tree/master/overrides
The text was updated successfully, but these errors were encountered: