-
Notifications
You must be signed in to change notification settings - Fork 710
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
implement getBindingsProxy
utility
#4523
Conversation
🦋 Changeset detectedLatest commit: f3c76bf The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
getBindingsProxy
utility
A wrangler prerelease is available for testing. You can install this latest build in your project with: npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/7586215045/npm-package-wrangler-4523 You can reference the automatically updated head of this PR with: npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/4523/npm-package-wrangler-4523 Or you can use npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/7586215045/npm-package-wrangler-4523 dev path/to/script.js Additional artifacts:npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/7586215045/npm-package-create-cloudflare-4523 --no-auto-update npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/7586215045/npm-package-miniflare-4523 npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/7586215045/npm-package-cloudflare-pages-shared-4523 Note that these links will no longer work once the GitHub Actions artifact expires.
Please ensure constraints are pinned, and |
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #4523 +/- ##
==========================================
- Coverage 75.66% 71.50% -4.17%
==========================================
Files 243 288 +45
Lines 13226 14834 +1608
Branches 3396 3729 +333
==========================================
+ Hits 10008 10607 +599
- Misses 3218 4227 +1009
|
🚀 docs for this would be here? https://developers.cloudflare.com/workers/wrangler/api/ |
I hadn't thought of that to be honest 😅 The page you linked makes sense to me 🙂👍 , I am not sure what the plan is for where the cc. @admah |
@dario-piotrowicz I can put up a docs PR based on the README from that PoC. I do think https://developers.cloudflare.com/workers/wrangler/api/ is the page that that makes the most sense for this documentation. I'll tag you there and link it to this PR. |
@admah, that sounds like a plan! Thank you very much 🙂 (PS: if you want I am can also open the docs PR, whatever you prefer 🙂) |
01bdf85
to
a3a8c82
Compare
a3a8c82
to
693f00c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally looks good to me. Left a few questions and nits. Nothing blocking.
I haven't actually tried this out yet though 😱
Co-authored-by: Pete Bacon Darwin <pete@bacondarwin.com>
Co-authored-by: Pete Bacon Darwin <pete@bacondarwin.com>
This PR introduces a new
getBindingsProxy
that can be used externally to get a proxy to Miniflare bindings that integrate well with wrangler (e.g. with the toml file and the local registry)You can see a demo of what this would look like here: getBindingsProxy-poc-demo
Note
Initially the utility was going to have two alternative argument APIs, one in which it would accept inline bindings (to use for Pages application) and one in which the bindings would instead be read from the
wrangler.toml
file (to use for Workers applications).We're currently considering if maybe it would be better to have this utility simply always only read the bindings from the
wrangler.toml
file (it would be a simpler API for users to use and for us to implement and maintain).I am not sure if both APIs will be implemented or if only the toml one will, regardless I'm scoping this PR only to the toml implementation, since the inline one could be then added afterwords as an additive non-breaking change anyways, so there is really no harm in reducing the PR's scope
To address:
persist
option, also, maybe we should just enable the utility to get the miniflare options and pass them to it as they are?1[ ] Implement utilities to get all the bindings of a certain type (e.g.2getD1Bindings
, etc...)[ ] to give maximum flexibility to users, maybe in the return object we should return the miniflare instance itself?1[ ] implement ai fetcher (if possible) to enable workers-ai bindings to be used locally2[ ] support reading env variables/secrets from2.dev.vars
wrangler.json
files (to do here if it's simple or in a followup PR otherwise)Footnotes
The fact that miniflare is used under the hood should be transparent to users, they shouldn't need to be aware of this, especially if/when in the future this utility uses
startDevWorker
or whatever else layer of abstraction (as discussed with @RamIdeas). ↩ ↩2Let's get this working with the classic/simple bindings and add things incrementally in followup PRs (incrementally iterating over this in non breaking manners looks to me like the way to go instead of trying to nail every single aspect right out of the gate) ↩ ↩2 ↩3