feat(vite-plugin-cloudflare): surface binding info#11045
Conversation
🦋 Changeset detectedLatest commit: e09c669 The changes in this PR will be included in the next version bump. 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 |
create-cloudflare
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
67d69b5 to
f99b468
Compare
jamesopstad
left a comment
There was a problem hiding this comment.
This is looking good. I've added some minor changes but the main thing I've noticed is that the bindings don't update when the config file is updated. It will need to be updated so that the shortcut always display the latest bindings.
| process.stdout.columns; | ||
|
|
||
| logger.log(title); | ||
| log(title); |
There was a problem hiding this comment.
Can we add a blank line after the title?
There was a problem hiding this comment.
Let's updates the format of the bindings table in a seperate PR as it will impact a huge amounts of snapshots test.
| } | ||
| if (tailConsumers !== undefined && tailConsumers.length > 0) { | ||
| logger.log( | ||
| log( |
There was a problem hiding this comment.
I think we need a blank line after tail consumers or multiple Workers end up in the same paragraph.
7e5e016 to
d8791d1
Compare
d8791d1 to
22effc1
Compare
cafac13 to
1652a30
Compare
d28c425 to
a604f65
Compare
jamesopstad
left a comment
There was a problem hiding this comment.
Left some comments that need addressing but generally looks good.
| const require = createRequire(import.meta.url); | ||
|
|
||
| export function satisfiesViteVersion(minVersion: string): boolean { | ||
| const viteVersion = require("vite/package.json").version as string; |
There was a problem hiding this comment.
| const viteVersion = require("vite/package.json").version as string; | |
| const viteVersion = require("vite/package.json").version as string; |
This can be replaced with importing version from vite.
There was a problem hiding this comment.
The suggestions shown in your comment looks identical 😅 Do you mean import { version } from "vite"?
I tried that and it returns me the version we used for development instead of user's vite version.
There was a problem hiding this comment.
The suggestions shown in your comment looks identical 😅 Do you mean
import { version } from "vite"?
Haha, sorry, I didn't mean to add a suggestion
I tried that and it returns me the version we used for development instead of user's vite version.
I'm pretty sure this will only be the case if you're running in the monorepo and haven't updated the Vite version globally. Linked dependencies get resolved differently. Please build the Vite plugin and then run pnpm update -r --no-save vite@7.2.7 before testing to verify.
There was a problem hiding this comment.
Yeah, I understand it's a monorepo issue as the pre-release works. I just wasn't sure how to test that in our repo (instead of manually testing it)
There was a problem hiding this comment.
Yeah, it's a little annoying but there's no way to reliably run the playground tests with a different version of Vite to the plugin package so both need to be updated. Otherwise the tests actually run with two versions of Vite, which can lead to some strange behaviour.
packages/vite-plugin-cloudflare/playground/vitest.config.e2e.ts
Outdated
Show resolved
Hide resolved
| if (hasConnectionStatus && !isConnectedStatusExplained) { | ||
| log( | ||
| dim( | ||
| `\nService bindings, Durable Object bindings, and Tail consumers connect to other Wrangler or Vite dev processes running locally, with their connection status indicated by ${chalk.green("[connected]")} or ${chalk.red("[not connected]")}. For more details, refer to https://developers.cloudflare.com/workers/runtime-apis/bindings/service-bindings/#local-development\n` |
There was a problem hiding this comment.
| `\nService bindings, Durable Object bindings, and Tail consumers connect to other Wrangler or Vite dev processes running locally, with their connection status indicated by ${chalk.green("[connected]")} or ${chalk.red("[not connected]")}. For more details, refer to https://developers.cloudflare.com/workers/runtime-apis/bindings/service-bindings/#local-development\n` | |
| `\nService bindings, Durable Object bindings, and Tail consumers connect to other Wrangler or Vite processes running locally, with their connection status indicated by ${chalk.green("[connected]")} or ${chalk.red("[not connected]")}. For more details, refer to https://developers.cloudflare.com/workers/runtime-apis/bindings/service-bindings/#local-development\n` |
Removing dev as it could also be preview.
There was a problem hiding this comment.
I will update it in the follow up PR with all other message changes (as they impact a huge amount of snapshot tests in wrangler).
| env.NAME_4 (CLASS_4, defined in SCRIPT_B) Durable Object local [not connected] | ||
|
|
||
|
|
||
| Service bindings, Durable Object bindings, and Tail consumers connect to other Wrangler or Vite dev processes running locally, with their connection status indicated by [connected] or [not connected]. For more details, refer to https://developers.cloudflare.com/workers/runtime-apis/bindings/service-bindings/#local-development |
There was a problem hiding this comment.
| Service bindings, Durable Object bindings, and Tail consumers connect to other Wrangler or Vite dev processes running locally, with their connection status indicated by [connected] or [not connected]. For more details, refer to https://developers.cloudflare.com/workers/runtime-apis/bindings/service-bindings/#local-development | |
| Service bindings, Durable Object bindings, and Tail consumers connect to other Wrangler or Vite processes running locally, with their connection status indicated by [connected] or [not connected]. For more details, refer to https://developers.cloudflare.com/workers/runtime-apis/bindings/service-bindings/#local-development |
There was a problem hiding this comment.
I will update it in the follow up PR with all other message changes (as they impact a huge amount of snapshot tests in wrangler).
|
Nice! @emily-shen @NuroDev this might be worth looking at for what we work on in Q1 for the Vite presentation. |
jamesopstad
left a comment
There was a problem hiding this comment.
Great! Please could you rebase on main before merging so that the tests run against Vite 8 beta. Thanks.
963254d to
c311057
Compare
Fixes DEVX-2116
This PR adds keyboard shortcut (
b + enter) to display worker bindings during development and it works with both dev and preview server.