Skip to content

Commit

Permalink
Support --x-dev-env for Pages (#6097)
Browse files Browse the repository at this point in the history
* Support `--x-dev-env` in `wrangler pages dev`

* reimplement enablePagesAssetsServiceBinding as a fetcher type binding
  • Loading branch information
RamIdeas authored Jul 29, 2024
1 parent 19c0672 commit 64f34e8
Show file tree
Hide file tree
Showing 6 changed files with 177 additions and 99 deletions.
5 changes: 5 additions & 0 deletions .changeset/young-doors-think.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wrangler": minor
---

feat: implements the `--experimental-dev-env` (shorthand: `--x-dev-env`) flag for `wrangler pages dev`
80 changes: 80 additions & 0 deletions packages/wrangler/e2e/__snapshots__/pages-dev.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`Pages 'wrangler pages dev --x-dev-env' > should merge (with override) \`wrangler.toml\` configuration with configuration provided via the command line, with command line args taking precedence 1`] = `
"✨ Compiled Worker successfully
▲ [WARNING] WARNING: You have Durable Object bindings that are not defined locally in the worker being developed.
Be aware that changes to the data stored in these Durable Objects will be permanent and affect the live instances.
Remote Durable Objects that are affected:
- {"name":"DO_BINDING_1_TOML","class_name":"DO_1_TOML","script_name":"DO_SCRIPT_1_TOML"}
- {"name":"DO_BINDING_2_TOML","class_name":"DO_2_TOML","script_name":"DO_SCRIPT_2_TOML"}
Your worker has access to the following bindings:
- Durable Objects:
- DO_BINDING_1_TOML: NEW_DO_1 (defined in NEW_DO_SCRIPT_1)
- DO_BINDING_2_TOML: DO_2_TOML (defined in DO_SCRIPT_2_TOML)
- DO_BINDING_3_ARGS: DO_3_ARGS (defined in DO_SCRIPT_3_ARGS)
- KV Namespaces:
- KV_BINDING_1_TOML: NEW_KV_ID_1
- KV_BINDING_2_TOML: KV_ID_2_TOML
- KV_BINDING_3_ARGS: KV_ID_3_ARGS
- D1 Databases:
- D1_BINDING_1_TOML: local-D1_BINDING_1_TOML=NEW_D1_NAME_1 (NEW_D1_NAME_1)
- D1_BINDING_2_TOML: D1_NAME_2_TOML (D1_ID_2_TOML)
- D1_BINDING_3_ARGS: local-D1_BINDING_3_ARGS=D1_NAME_3_ARGS (D1_NAME_3_ARGS)
- R2 Buckets:
- R2_BINDING_1_TOML: NEW_R2_BUCKET_1
- R2_BINDING_2_TOML: R2_BUCKET_2_TOML
- R2_BINDING_3_TOML: R2_BUCKET_3_ARGS
- Services:
- SERVICE_BINDING_1_TOML: NEW_SERVICE_NAME_1
- SERVICE_BINDING_2_TOML: SERVICE_NAME_2_TOML
- SERVICE_BINDING_3_TOML: SERVICE_NAME_3_ARGS
- AI:
- Name: AI_BINDING_2_TOML
- Vars:
- VAR1: "(hidden)"
- VAR2: "VAR_2_TOML"
- VAR3: "(hidden)"
▲ [WARNING] This worker is bound to live services: SERVICE_BINDING_1_TOML (NEW_SERVICE_NAME_1), SERVICE_BINDING_3_TOML (SERVICE_NAME_3_ARGS), SERVICE_BINDING_2_TOML (SERVICE_NAME_2_TOML)
▲ [WARNING] Using Workers AI always accesses your Cloudflare account in order to run AI models, and so will incur usage charges even in local development.
"
`;

exports[`Pages 'wrangler pages dev' > should merge (with override) \`wrangler.toml\` configuration with configuration provided via the command line, with command line args taking precedence 1`] = `
"✨ Compiled Worker successfully
▲ [WARNING] WARNING: You have Durable Object bindings that are not defined locally in the worker being developed.
Be aware that changes to the data stored in these Durable Objects will be permanent and affect the live instances.
Remote Durable Objects that are affected:
- {"name":"DO_BINDING_1_TOML","class_name":"DO_1_TOML","script_name":"DO_SCRIPT_1_TOML"}
- {"name":"DO_BINDING_2_TOML","class_name":"DO_2_TOML","script_name":"DO_SCRIPT_2_TOML"}
▲ [WARNING] This worker is bound to live services: SERVICE_BINDING_1_TOML (SERVICE_NAME_1_TOML), SERVICE_BINDING_2_TOML (SERVICE_NAME_2_TOML)
Your worker has access to the following bindings:
- Durable Objects:
- DO_BINDING_1_TOML: NEW_DO_1 (defined in NEW_DO_SCRIPT_1)
- DO_BINDING_2_TOML: DO_2_TOML (defined in DO_SCRIPT_2_TOML)
- DO_BINDING_3_ARGS: DO_3_ARGS (defined in DO_SCRIPT_3_ARGS)
- KV Namespaces:
- KV_BINDING_1_TOML: NEW_KV_ID_1
- KV_BINDING_2_TOML: KV_ID_2_TOML
- KV_BINDING_3_ARGS: KV_ID_3_ARGS
- D1 Databases:
- D1_BINDING_1_TOML: local-D1_BINDING_1_TOML=NEW_D1_NAME_1 (NEW_D1_NAME_1)
- D1_BINDING_2_TOML: D1_NAME_2_TOML (D1_ID_2_TOML)
- D1_BINDING_3_ARGS: local-D1_BINDING_3_ARGS=D1_NAME_3_ARGS (D1_NAME_3_ARGS)
- R2 Buckets:
- R2_BINDING_1_TOML: NEW_R2_BUCKET_1
- R2_BINDING_2_TOML: R2_BUCKET_2_TOML
- R2_BINDING_3_TOML: R2_BUCKET_3_ARGS
- Services:
- SERVICE_BINDING_1_TOML: NEW_SERVICE_NAME_1
- SERVICE_BINDING_2_TOML: SERVICE_NAME_2_TOML
- SERVICE_BINDING_3_TOML: SERVICE_NAME_3_ARGS
- AI:
- Name: AI_BINDING_2_TOML
- Vars:
- VAR1: "(hidden)"
- VAR2: "VAR_2_TOML"
- VAR3: "(hidden)"
▲ [WARNING] ⎔ Support for service bindings in local mode is experimental and may change.
▲ [WARNING] ⎔ Support for external Durable Objects in local mode is experimental and may change.
"
`;
Loading

0 comments on commit 64f34e8

Please sign in to comment.