feat(wrangler): watch mode for Workers + Assets#6574
Conversation
🦋 Changeset detectedLatest commit: ee6ff15 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 |
|
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/10629771784/npm-package-wrangler-6574You can reference the automatically updated head of this PR with: npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/6574/npm-package-wrangler-6574Or you can use npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10629771784/npm-package-wrangler-6574 dev path/to/script.jsAdditional artifacts:npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10629771784/npm-package-create-cloudflare-6574 --no-auto-updatenpm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10629771784/npm-package-cloudflare-kv-asset-handler-6574npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10629771784/npm-package-miniflare-6574npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10629771784/npm-package-cloudflare-pages-shared-6574npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10629771784/npm-package-cloudflare-vitest-pool-workers-6574npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10629771784/npm-package-cloudflare-workers-editor-shared-6574npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10629771784/npm-package-cloudflare-workers-shared-6574Note that these links will no longer work once the GitHub Actions artifact expires.
Please ensure constraints are pinned, and |
d1b5f95 to
f1b3795
Compare
f1b3795 to
26eb214
Compare
packages/wrangler/src/dev.tsx
Outdated
There was a problem hiding this comment.
The two fns that can potentially throw here are readConfig and processExperimentalAssetsArg. Since we're in watch mode, we ideally don't want to error and exit every time there's a config file read error or we couldn't properly resolve the assets directory path. The better user experience IMO is to log the error and allow users to fix as they go, without having them re-start the dev process every single time. This brings the watch mode experience in line with pages dev, which we recently refactored for precisely the same reason.
There was a problem hiding this comment.
basically for the same reason as in https://github.com/cloudflare/workers-sdk/pull/6574/files#r1733250847. But I would like some sanity check on whether this gets executed only in watch mode. If not, we might need to rethink the logic here, in case throwing and exiting the dev process is expected to happen in some use cases
packages/wrangler/src/dev.tsx
Outdated
There was a problem hiding this comment.
I wonder if for this use case we shouldn't show a warning or log message reminding users that they are currently running wrangler dev with the -x--assets/--experimental-assets flag, and therefore config file changes related to experimental_assets will not be reflected in the current dev process, since args override config 🤔
There was a problem hiding this comment.
as per our async convo, I will put smth in place here
3d02114 to
0c87849
Compare
dd3e946 to
84b771a
Compare
84b771a to
1854c37
Compare
1854c37 to
ee6ff15
Compare
What this PR solves / how to test
This PR implements watch mode for Workers with assets, more specifically:
Fixes WC-2554
Clean commit history is caring 🫶 so pls review per commit
How this was tested
Beside e2e tests, these changes were also manually tested in the following scenarios:
[
wrangler dev|wrangler dev --x-dev-env]wrangler.toml+ file changes in new assets directory + file changes in old assets directory to ensure it is not watched anymore[
wrangler dev --x-assets="dist"|wrangler dev --x-dev-env --x-assets="dist"]wrangler.toml+ file changes in that assets directory to ensure we are still watching the assets dir specified by--x-assetsAuthor has addressed the following