-
Notifications
You must be signed in to change notification settings - Fork 985
fix(wrangler): allow direct mutation of context.data with Pages Functions #3431
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
Conversation
🦋 Changeset detectedLatest commit: 42946ec 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 |
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/5237240505/npm-package-wrangler-3431 You can reference the automatically updated head of this PR with: npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/3431/npm-package-wrangler-3431 Or you can use npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/5237240505/npm-package-wrangler-3431 dev path/to/script.js Additional artifacts:npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/5237240505/npm-package-cloudflare-pages-shared-3431 Note that these links will no longer work once the GitHub Actions artifact expires. |
Codecov Report
@@ Coverage Diff @@
## main #3431 +/- ##
==========================================
+ Coverage 75.39% 75.44% +0.04%
==========================================
Files 182 182
Lines 11060 11060
Branches 2903 2903
==========================================
+ Hits 8339 8344 +5
+ Misses 2721 2716 -5 |
acfb115
to
8f40c2f
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.
Like this fix. Working well locally, but had a bit of an issue due to JS destructuring but sadly that's not easily solvable (Proxy could but Proxy... ugh).
Happy with this, it should unblock most people. Thanks for the tests too :)
Fixes #2797
What this PR solves / how to test:
Previously, Pages Functions exposed
context.data
like this:Which meant that users could set
context.data.foo = false
and it would work fine, since it's just a reference to the top-leveldata
per request, but the second they tried to overridecontext.data
entirely, such ascontext.data = {foo: false}
, the reference to the originaldata
is lost, so this data wouldn't actually show up.This PR fixes that by adding a getter/setter pair to
data
, so that folks can override this without any issues.Author has included the following, where applicable:
Reviewer is to perform the following, as applicable: