-
Notifications
You must be signed in to change notification settings - Fork 708
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
fix(wrangler): Support switching between static and dynamic Workers #6775
Conversation
🦋 Changeset detectedLatest commit: e6a366d The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
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 |
packages/wrangler/src/dev.tsx
Outdated
* in the `wrangler.toml` file, specifically the `main` configuration | ||
* key, and re-asses the entry point every time. | ||
*/ | ||
if (experimentalAssetsOptions?.directory) { |
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.
technically, we could support this for all Workers, not just Workers with assets. Is this something we would like to do?
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.
after internal discussions, the answer is yes. wrangler dev --x-dev-env
already supports this, no reason why wrangler dev
shouldn't
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/10958433741/npm-package-wrangler-6775 You can reference the automatically updated head of this PR with: npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/6775/npm-package-wrangler-6775 Or you can use npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10958433741/npm-package-wrangler-6775 dev path/to/script.js Additional artifacts:npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10958433741/npm-package-create-cloudflare-6775 --no-auto-update npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10958433741/npm-package-cloudflare-kv-asset-handler-6775 npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10958433741/npm-package-miniflare-6775 npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10958433741/npm-package-cloudflare-pages-shared-6775 npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10958433741/npm-package-cloudflare-vitest-pool-workers-6775 npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10958433741/npm-package-cloudflare-workers-editor-shared-6775 npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10958433741/npm-package-cloudflare-workers-shared-6775 Note that these links will no longer work once the GitHub Actions artifact expires.
Please ensure constraints are pinned, and |
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.
LGTM. Does this work with the --x-dev-env
flow as well?
it does yes! Tested manually, but also covered by our e2e tests |
77dcf22
to
e4c792d
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.
I assume this bug does not exist with --x-dev-env
because config+args are re-resolved correctly each time config is updated?
indeed. I didn't have to fix anything for |
In my testing, I see the following behaviors work: Switching between
RPC to a regular Worker
RPC to a Worker with both a script and assets
RPC to a Worker with just assets
|
66e9f97
to
9628d67
Compare
oh boy...this is def more complex than what I thought the expectation was here. My understanding was that this should support switching between assets only and W + A. I'm surprised tbh it works for anything other than. If. we want to support such a wide range of scenarios, I'll need to dbl check with the team to get a feel of whether this is smth we do want to support. |
We don't need RPC for launch, (other than just ensuring we don't break "RPC to a regular Worker"). But getting Worker to both and Worker to static would be nice if possible. |
I also think this PR improves the current state. It fixes going from "Static to both" and "Static to Worker", so feel free to merge this as-is and we can address "Worker to both" and "Worker to static" in a follow-up ticket. |
kk. I'll keep that in mind, but will bring this to the team anyway just so we have a clear picture of the general opinion here |
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.
I haven't thought this through but it feels like we could just say that any change to wrangler.toml causes a complete restart of the dev server and that would naturally pick up the change to asset config and worker main config? Avoiding any need to special case this?
technically yes, and I think that alternatively, we could do smth like ---- EDIT -----
yes it does, so no reason why
no we cannot, because |
This commit fixes the current behaviour of watch mode for Workers with assets, and adds support for switching between static and dynamic Workers within a single `wrangler dev` session.
00329da
to
f6b33b7
Compare
after discussing with the team, and doing some more testing, I'm going to go head and capture your suggestions @GregBrimble in this PR. I've addressed your feedback in f6b33b7. Please have a look and let me know how that test list is looking. I've tested a bunch of permutations, except RPC. With these changes, we are bringing the |
f6b33b7
to
e6a366d
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.
Updated my test sheet, and sure enough, everything works great! Thanks @CarmenPopoviciu !
What this PR solves / how to test
This commit fixes the current behaviour of watch mode for Workers with assets, and adds support for switching between static and dynamic Workers within a single
wrangler dev
session.Fixes WC-2721
Author has addressed the following