From 6674519c9167cbfbcae3a5d60943cb860ca5bff4 Mon Sep 17 00:00:00 2001 From: Samuel Macleod Date: Thu, 27 Feb 2025 12:32:25 +0000 Subject: [PATCH 01/13] Add v4 RC changelog entry --- .../workers/2025-02-27-wrangler-v4-rc.mdx | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/content/changelog/workers/2025-02-27-wrangler-v4-rc.mdx diff --git a/src/content/changelog/workers/2025-02-27-wrangler-v4-rc.mdx b/src/content/changelog/workers/2025-02-27-wrangler-v4-rc.mdx new file mode 100644 index 000000000000000..5dc1abde0bcae5d --- /dev/null +++ b/src/content/changelog/workers/2025-02-27-wrangler-v4-rc.mdx @@ -0,0 +1,54 @@ +--- +title: Introducing Wrangler v4's release candidate +description: You can now try out the v4 RC for Wrangler by installing `wrangler@4.0.0-rc.0` +products: + - workers +date: 2025-02-27T11:00:00Z +--- + +import { PackageManagers } from "~/components"; + +TLDR: Try out the Wrangler v4 RC by installing via your favourite package manager: + + + +Wrangler v3 was released in May 2023, and since then has seen amazing growth and usage—from just \~250,000 downloads a week back then to 1M+ now. It's time for the next chapter in Wrangler's journey: v4. This release will bring new features and unlock new possibilities for the developer platform, but for the vast majority of users you _won't need to make any changes to upgrade_. It'll be as simple as upgrading Wrangler. + +We're working on a more detailed migration guide, but here's a brief list of the changes to expect: + +#### Changes + +- **Upgraded `esbuild` version** + This has been a highly-requested feature for a long time, and will allow you to use more modern JavaScript features in your Workers, including import attributes and `using` statements + +- **`--local` by default for all commands** + All commands that access resources (e.g. `wrangler kv`, `wrangler r2`, `wrangler d1`) will now access local datastores by default + +- **Updated Node.js support policy** + Wrangler will now support the active, maintenance, and current versions of Node.js (currently v18+) + +- **Deprecated features removed** + All deprecated features have been removed from Wrangler, including + - Arguments: + - `wrangler dev/deploy --legacy-assets` + - `wrangler dev/deploy --format` + - Commands: + - `wrangler version` + - `wrangler publish` + - `wrangler generate` + - `wrangler config` + - `wrangler preview` + - `wrangler route` + - `wrangler subdomain` + - APIs + - `getBindingsProxy()` + - Config file properties + - `type` + - `webpack_config` + - `miniflare` + - `build.upload` + - `zone_id` + - `usage_model` + - `experimental_services` + - `kv-namespaces` + - `legacy_assets` From fb2ba5e87695dbb1309eeb667432e147a9c70078 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Somhairle=20MacLe=C3=B2id?= Date: Thu, 27 Feb 2025 20:26:22 +0000 Subject: [PATCH 02/13] Apply suggestions from code review Co-authored-by: lrapoport-cf <107272160+lrapoport-cf@users.noreply.github.com> Co-authored-by: hyperlint-ai[bot] <154288675+hyperlint-ai[bot]@users.noreply.github.com> --- .../changelog/workers/2025-02-27-wrangler-v4-rc.mdx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/content/changelog/workers/2025-02-27-wrangler-v4-rc.mdx b/src/content/changelog/workers/2025-02-27-wrangler-v4-rc.mdx index 5dc1abde0bcae5d..da44a86531e4467 100644 --- a/src/content/changelog/workers/2025-02-27-wrangler-v4-rc.mdx +++ b/src/content/changelog/workers/2025-02-27-wrangler-v4-rc.mdx @@ -1,5 +1,5 @@ --- -title: Introducing Wrangler v4's release candidate +title: Introducing Wrangler's v4 release candidate description: You can now try out the v4 RC for Wrangler by installing `wrangler@4.0.0-rc.0` products: - workers @@ -12,23 +12,23 @@ TLDR: Try out the Wrangler v4 RC by installing via your favourite package manage -Wrangler v3 was released in May 2023, and since then has seen amazing growth and usage—from just \~250,000 downloads a week back then to 1M+ now. It's time for the next chapter in Wrangler's journey: v4. This release will bring new features and unlock new possibilities for the developer platform, but for the vast majority of users you _won't need to make any changes to upgrade_. It'll be as simple as upgrading Wrangler. +Wrangler v3 was released in May 2023, and since then has seen amazing growth and usage—from just \~250,000 downloads a week back then to 1M+ now. It's time for the next chapter in Wrangler's journey: v4. This release will bring new features and unlock new possibilities for the developer platform. And for the vast majority of users, _no changes will be necessary to upgrade_—it'll be as simple as upgrading Wrangler. -We're working on a more detailed migration guide, but here's a brief list of the changes to expect: +We're working on a detailed migration guide that will accompany the v4 release. In the meantime, here's a brief list of the changes to expect: #### Changes - **Upgraded `esbuild` version** - This has been a highly-requested feature for a long time, and will allow you to use more modern JavaScript features in your Workers, including import attributes and `using` statements + A long-time highly-requested feature, this will now allow the use of more modern JavaScript features in Workers, including import attributes and `using` statements - **`--local` by default for all commands** - All commands that access resources (e.g. `wrangler kv`, `wrangler r2`, `wrangler d1`) will now access local datastores by default + All commands that access resources (for example, `wrangler kv`, `wrangler r2`, `wrangler d1`) will now access local datastores by default - **Updated Node.js support policy** Wrangler will now support the active, maintenance, and current versions of Node.js (currently v18+) - **Deprecated features removed** - All deprecated features have been removed from Wrangler, including + All deprecated features will be removed from Wrangler, including - Arguments: - `wrangler dev/deploy --legacy-assets` - `wrangler dev/deploy --format` From 3c5bea5fb62c410725cb21b6e3a4db9912c949fa Mon Sep 17 00:00:00 2001 From: Brendan Irvine-Broque Date: Fri, 28 Feb 2025 09:09:46 -0800 Subject: [PATCH 03/13] Copy and language updates --- .../workers/2025-02-27-wrangler-v4-rc.mdx | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/content/changelog/workers/2025-02-27-wrangler-v4-rc.mdx b/src/content/changelog/workers/2025-02-27-wrangler-v4-rc.mdx index da44a86531e4467..73f54c210122459 100644 --- a/src/content/changelog/workers/2025-02-27-wrangler-v4-rc.mdx +++ b/src/content/changelog/workers/2025-02-27-wrangler-v4-rc.mdx @@ -1,5 +1,5 @@ --- -title: Introducing Wrangler's v4 release candidate +title: Use the latest JavaScript features with Wrangler CLI v4 — release candidate description: You can now try out the v4 RC for Wrangler by installing `wrangler@4.0.0-rc.0` products: - workers @@ -8,26 +8,26 @@ date: 2025-02-27T11:00:00Z import { PackageManagers } from "~/components"; -TLDR: Try out the Wrangler v4 RC by installing via your favourite package manager: +We've released a release candidate of the next major version of [Wrangler](/workers/wrangler/), the CLI for Cloudflare Workers — `wrangler@4.0.0-rc.0`. You can run the following command to install it and be one of the first to try it out: -Wrangler v3 was released in May 2023, and since then has seen amazing growth and usage—from just \~250,000 downloads a week back then to 1M+ now. It's time for the next chapter in Wrangler's journey: v4. This release will bring new features and unlock new possibilities for the developer platform. And for the vast majority of users, _no changes will be necessary to upgrade_—it'll be as simple as upgrading Wrangler. +Unlike previous major versions of Wrangler, which were foundational rewrites and rearchitectures — Version 4 of Wrangler includes a much smaller set of changes. If you use Wrangler today, your workflow is very unlikely to change. Before we release Wrangler v4 and advance past the release candidate stage, we'll share a detailed migration guide in the Workers developer docs. But for the vast majority of cases, you won't need to do anything to migrate — things will just work as they do today. -We're working on a detailed migration guide that will accompany the v4 release. In the meantime, here's a brief list of the changes to expect: +Most notably, version 4 of Wrangler updates the version of [esbuild](https://esbuild.github.io/) that Wrangler uses internally, allowing you to use modern JavaScript language features, including: -#### Changes +- the [`using` keyword from the Explicit Resourece Management standard](https://github.com/tc39/proposal-explicit-resource-management), making it easier to work with the [JavaScript-native RPC system built into Workers](/workers/runtime-apis/rpc/). +- import attributes -- **Upgraded `esbuild` version** - A long-time highly-requested feature, this will now allow the use of more modern JavaScript features in Workers, including import attributes and `using` statements +Version 4 also introduces the following changes: -- **`--local` by default for all commands** - All commands that access resources (for example, `wrangler kv`, `wrangler r2`, `wrangler d1`) will now access local datastores by default +- **`--local` is now the default for all CLI commands** + All commands that access resources (for example, `wrangler kv`, `wrangler r2`, `wrangler d1`) now access local datastores by default, ensuring consistent behavior, intended to reduce confusion -- **Updated Node.js support policy** - Wrangler will now support the active, maintenance, and current versions of Node.js (currently v18+) +- **Clearer policy for the minimum required version of Node.js required to run Wrangler** + Moving forward, the [active, maintenance, and current versions of Node.js](https://nodejs.org/en/about/previous-releases) will be officially supported. This means the minimum officially supported version of Node.js for Wrangler v4 will e Node.js v18 or later. This policy mirrors how many other packages and CLIs support older versions of Node.js, and ensures that as long as you are using a version of Node.js that the Node.js project itself supports, this will be supported by Wrangler as well. -- **Deprecated features removed** +- **Features previously deprecated in Wrangler v3 are now removed in Wrangler v4** All deprecated features will be removed from Wrangler, including - Arguments: - `wrangler dev/deploy --legacy-assets` @@ -52,3 +52,5 @@ We're working on a detailed migration guide that will accompany the v4 release. - `experimental_services` - `kv-namespaces` - `legacy_assets` + +We'd love your feedback, etc. From e6ebd2130d937acaeb516fee214edbd3e68b40fc Mon Sep 17 00:00:00 2001 From: Brendan Irvine-Broque Date: Fri, 28 Feb 2025 09:30:44 -0800 Subject: [PATCH 04/13] More updates --- .../workers/2025-02-27-wrangler-v4-rc.mdx | 54 ++++++++++++++----- 1 file changed, 41 insertions(+), 13 deletions(-) diff --git a/src/content/changelog/workers/2025-02-27-wrangler-v4-rc.mdx b/src/content/changelog/workers/2025-02-27-wrangler-v4-rc.mdx index 73f54c210122459..997d2aa63fecc9f 100644 --- a/src/content/changelog/workers/2025-02-27-wrangler-v4-rc.mdx +++ b/src/content/changelog/workers/2025-02-27-wrangler-v4-rc.mdx @@ -8,27 +8,55 @@ date: 2025-02-27T11:00:00Z import { PackageManagers } from "~/components"; -We've released a release candidate of the next major version of [Wrangler](/workers/wrangler/), the CLI for Cloudflare Workers — `wrangler@4.0.0-rc.0`. You can run the following command to install it and be one of the first to try it out: +We've released a release candidate of the next major version of [Wrangler](/workers/wrangler/), the CLI for Cloudflare Workers — `wrangler@4.0.0-rc.0`. + +You can run the following command to install it and be one of the first to try it out: -Unlike previous major versions of Wrangler, which were foundational rewrites and rearchitectures — Version 4 of Wrangler includes a much smaller set of changes. If you use Wrangler today, your workflow is very unlikely to change. Before we release Wrangler v4 and advance past the release candidate stage, we'll share a detailed migration guide in the Workers developer docs. But for the vast majority of cases, you won't need to do anything to migrate — things will just work as they do today. +Unlike previous major versions of Wrangler, which were [foundational rewrites](https://blog.cloudflare.com/wrangler-v2-beta/) and [rearchitectures](https://blog.cloudflare.com/wrangler3/) — Version 4 of Wrangler includes a much smaller set of changes. If you use Wrangler today, your workflow is very unlikely to change. Before we release Wrangler v4 and advance past the release candidate stage, we'll share a detailed migration guide in the Workers developer docs. But for the vast majority of cases, you won't need to do anything to migrate — things will just work as they do today. We are sharing this release candidate in advance of the official release of v4, so that you can try it out early and share feedback. + +#### New JavaScript language features that you can now use with Wrangler v4 + +Version 4 of Wrangler updates the version of [esbuild](https://esbuild.github.io/) that Wrangler uses internally, allowing you to use modern JavaScript language features, including: + +##### The `using` keyword from Explicit Resource Management + +The [`using` keyword from the Explicit Resource Management standard](/workers/runtime-apis/rpc/lifecycle/#explicit-resource-management), making it easier to work with the [JavaScript-native RPC system built into Workers](/workers/runtime-apis/rpc/). This means that when you obtain a stub, you can ensure that it is automatically disposed when you exit scope it was created in: + +```js +function sendEmail(id, message) { + using user = await env.USER_SERVICE.findUser(id); + await user.sendEmail(message); + + // user[Symbol.dispose]() is implicitly called at the end of the scope. +} +``` + +##### Import attributes + +[Import attributes](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import/with) allow you to denote the type or other attributes of the module that your code imports. For example, you can import a JSON module, using the following syntax: + +```js +import data from "./data.json" with { type: "json" }; +``` + +#### Other changes + +##### `--local` is now the default for all CLI commands + +All commands that access resources (for example, `wrangler kv`, `wrangler r2`, `wrangler d1`) now access local datastores by default, ensuring consistent behavior, intended to reduce confusion -Most notably, version 4 of Wrangler updates the version of [esbuild](https://esbuild.github.io/) that Wrangler uses internally, allowing you to use modern JavaScript language features, including: +##### Clearer policy for the minimum required version of Node.js required to run Wrangler -- the [`using` keyword from the Explicit Resourece Management standard](https://github.com/tc39/proposal-explicit-resource-management), making it easier to work with the [JavaScript-native RPC system built into Workers](/workers/runtime-apis/rpc/). -- import attributes +Moving forward, the [active, maintenance, and current versions of Node.js](https://nodejs.org/en/about/previous-releases) will be officially supported. This means the minimum officially supported version of Node.js for Wrangler v4 will e Node.js v18 or later. This policy mirrors how many other packages and CLIs support older versions of Node.js, and ensures that as long as you are using a version of Node.js that the Node.js project itself supports, this will be supported by Wrangler as well. -Version 4 also introduces the following changes: +##### Features previously deprecated in Wrangler v3 are now removed in Wrangler v4 -- **`--local` is now the default for all CLI commands** - All commands that access resources (for example, `wrangler kv`, `wrangler r2`, `wrangler d1`) now access local datastores by default, ensuring consistent behavior, intended to reduce confusion +The following features, previously deprecated over one year ago in Wrangler v3, now can no longer be used in Wrangler v4: -- **Clearer policy for the minimum required version of Node.js required to run Wrangler** - Moving forward, the [active, maintenance, and current versions of Node.js](https://nodejs.org/en/about/previous-releases) will be officially supported. This means the minimum officially supported version of Node.js for Wrangler v4 will e Node.js v18 or later. This policy mirrors how many other packages and CLIs support older versions of Node.js, and ensures that as long as you are using a version of Node.js that the Node.js project itself supports, this will be supported by Wrangler as well. +(think these need a — instead do x...) -- **Features previously deprecated in Wrangler v3 are now removed in Wrangler v4** - All deprecated features will be removed from Wrangler, including - Arguments: - `wrangler dev/deploy --legacy-assets` - `wrangler dev/deploy --format` @@ -53,4 +81,4 @@ Version 4 also introduces the following changes: - `kv-namespaces` - `legacy_assets` -We'd love your feedback, etc. +We'd love your feedback! If you find a bug or hit a roadblock when upgrading to Wrangler v4, [open an issue on the `cloudflare/workers-sdk` repository on GitHub](https://github.com/cloudflare/workers-sdk/issues/new?template=bug-template.yaml). From dc892c476ceabbde7f56b93436c7e7054c4b97a8 Mon Sep 17 00:00:00 2001 From: Brendan Irvine-Broque Date: Fri, 28 Feb 2025 09:38:26 -0800 Subject: [PATCH 05/13] Update 2025-02-27-wrangler-v4-rc.mdx --- src/content/changelog/workers/2025-02-27-wrangler-v4-rc.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/changelog/workers/2025-02-27-wrangler-v4-rc.mdx b/src/content/changelog/workers/2025-02-27-wrangler-v4-rc.mdx index 997d2aa63fecc9f..e35e714a059d888 100644 --- a/src/content/changelog/workers/2025-02-27-wrangler-v4-rc.mdx +++ b/src/content/changelog/workers/2025-02-27-wrangler-v4-rc.mdx @@ -1,5 +1,5 @@ --- -title: Use the latest JavaScript features with Wrangler CLI v4 — release candidate +title: Use the latest JavaScript features with Wrangler CLI v4.0.0-rc.0 description: You can now try out the v4 RC for Wrangler by installing `wrangler@4.0.0-rc.0` products: - workers From 221cdcbfe6e86cacb1e890ee2188157af9c0ce15 Mon Sep 17 00:00:00 2001 From: Brendan Irvine-Broque Date: Fri, 28 Feb 2025 09:47:57 -0800 Subject: [PATCH 06/13] Apply suggestions from code review --- src/content/changelog/workers/2025-02-27-wrangler-v4-rc.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/content/changelog/workers/2025-02-27-wrangler-v4-rc.mdx b/src/content/changelog/workers/2025-02-27-wrangler-v4-rc.mdx index e35e714a059d888..39394cf5334e87d 100644 --- a/src/content/changelog/workers/2025-02-27-wrangler-v4-rc.mdx +++ b/src/content/changelog/workers/2025-02-27-wrangler-v4-rc.mdx @@ -45,11 +45,11 @@ import data from "./data.json" with { type: "json" }; ##### `--local` is now the default for all CLI commands -All commands that access resources (for example, `wrangler kv`, `wrangler r2`, `wrangler d1`) now access local datastores by default, ensuring consistent behavior, intended to reduce confusion +All commands that access resources (for example, `wrangler kv`, `wrangler r2`, `wrangler d1`) now access local datastores by default, ensuring consistent behavior. ##### Clearer policy for the minimum required version of Node.js required to run Wrangler -Moving forward, the [active, maintenance, and current versions of Node.js](https://nodejs.org/en/about/previous-releases) will be officially supported. This means the minimum officially supported version of Node.js for Wrangler v4 will e Node.js v18 or later. This policy mirrors how many other packages and CLIs support older versions of Node.js, and ensures that as long as you are using a version of Node.js that the Node.js project itself supports, this will be supported by Wrangler as well. +Moving forward, the [active, maintenance, and current versions of Node.js](https://nodejs.org/en/about/previous-releases) will be officially supported by Wrangler. This means the minimum officially supported version of Node.js you must have installed for Wrangler v4 will be Node.js v18 or later. This policy mirrors how many other packages and CLIs support older versions of Node.js, and ensures that as long as you are using a version of Node.js that the Node.js project itself supports, this will be supported by Wrangler as well. ##### Features previously deprecated in Wrangler v3 are now removed in Wrangler v4 From 419f9c6a25f8e05f5041e4495d353cbccaec256a Mon Sep 17 00:00:00 2001 From: Samuel Macleod Date: Fri, 28 Feb 2025 18:44:13 +0000 Subject: [PATCH 07/13] Add more detail to deprecations --- .../workers/2025-02-27-wrangler-v4-rc.mdx | 34 ++++--------------- 1 file changed, 7 insertions(+), 27 deletions(-) diff --git a/src/content/changelog/workers/2025-02-27-wrangler-v4-rc.mdx b/src/content/changelog/workers/2025-02-27-wrangler-v4-rc.mdx index 39394cf5334e87d..0e6e47cb5bae322 100644 --- a/src/content/changelog/workers/2025-02-27-wrangler-v4-rc.mdx +++ b/src/content/changelog/workers/2025-02-27-wrangler-v4-rc.mdx @@ -53,32 +53,12 @@ Moving forward, the [active, maintenance, and current versions of Node.js](https ##### Features previously deprecated in Wrangler v3 are now removed in Wrangler v4 -The following features, previously deprecated over one year ago in Wrangler v3, now can no longer be used in Wrangler v4: - -(think these need a — instead do x...) - - - Arguments: - - `wrangler dev/deploy --legacy-assets` - - `wrangler dev/deploy --format` - - Commands: - - `wrangler version` - - `wrangler publish` - - `wrangler generate` - - `wrangler config` - - `wrangler preview` - - `wrangler route` - - `wrangler subdomain` - - APIs - - `getBindingsProxy()` - - Config file properties - - `type` - - `webpack_config` - - `miniflare` - - `build.upload` - - `zone_id` - - `usage_model` - - `experimental_services` - - `kv-namespaces` - - `legacy_assets` +All previously deprecated features in [Wrangler v2](https://developers.cloudflare.com/workers/wrangler/deprecations/#wrangler-v2) and in [Wrangler v3](https://developers.cloudflare.com/workers/wrangler/deprecations/#wrangler-v3) have now been removed. Additionally, the following features that were deprecated during the Wrangler v3 release lifecycle have been removed: + +- Legacy Assets (using `wrangler dev/deploy --legacy-assets` or the `legacy_assets` config file property). Instead, we recommend you [migrate to Workers assets](https://developers.cloudflare.com/workers/static-assets/). +- Legacy Node.js compatibility (using `wrangler dev/deploy --node-compat` or the `node_compat` config file property). Instead, use the [`nodejs_compat` compatibility flag](https://developers.cloudflare.com/workers/runtime-apis/nodejs). This includes the functionality from legacy `node_compat` polyfills and natively implemented Node.js APIs. +- `wrangler version`. Instead, use `wrangler --version` to check the current version of Wrangler. +- `getBindingsProxy()` (via `import { getBindingsProxy } from "wrangler"`). Instead, use the [`getPlatformProxy()` API](https://developers.cloudflare.com/workers/wrangler/api/#getplatformproxy), which takes exactly the same arguments. +- `usage_model`. This no longer has any effect, after the [rollout of Workers Standard Pricing](https://blog.cloudflare.com/workers-pricing-scale-to-zero/). We'd love your feedback! If you find a bug or hit a roadblock when upgrading to Wrangler v4, [open an issue on the `cloudflare/workers-sdk` repository on GitHub](https://github.com/cloudflare/workers-sdk/issues/new?template=bug-template.yaml). From 33ac357efb10ae00124aed1a32484534fc31ff20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Somhairle=20MacLe=C3=B2id?= Date: Fri, 28 Feb 2025 19:41:46 +0000 Subject: [PATCH 08/13] Update src/content/changelog/workers/2025-02-27-wrangler-v4-rc.mdx Co-authored-by: lrapoport-cf <107272160+lrapoport-cf@users.noreply.github.com> --- src/content/changelog/workers/2025-02-27-wrangler-v4-rc.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/changelog/workers/2025-02-27-wrangler-v4-rc.mdx b/src/content/changelog/workers/2025-02-27-wrangler-v4-rc.mdx index 0e6e47cb5bae322..f66f6cfb5481baa 100644 --- a/src/content/changelog/workers/2025-02-27-wrangler-v4-rc.mdx +++ b/src/content/changelog/workers/2025-02-27-wrangler-v4-rc.mdx @@ -22,7 +22,7 @@ Version 4 of Wrangler updates the version of [esbuild](https://esbuild.github.io ##### The `using` keyword from Explicit Resource Management -The [`using` keyword from the Explicit Resource Management standard](/workers/runtime-apis/rpc/lifecycle/#explicit-resource-management), making it easier to work with the [JavaScript-native RPC system built into Workers](/workers/runtime-apis/rpc/). This means that when you obtain a stub, you can ensure that it is automatically disposed when you exit scope it was created in: +The [`using` keyword from the Explicit Resource Management standard](/workers/runtime-apis/rpc/lifecycle/#explicit-resource-management) makes it easier to work with the [JavaScript-native RPC system built into Workers](/workers/runtime-apis/rpc/). This means that when you obtain a stub, you can ensure that it is automatically disposed when you exit scope it was created in: ```js function sendEmail(id, message) { From 1f7e09a97febc204ba8fa5a72bbc6164e8d9953a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Somhairle=20MacLe=C3=B2id?= Date: Fri, 28 Feb 2025 19:41:56 +0000 Subject: [PATCH 09/13] Update src/content/changelog/workers/2025-02-27-wrangler-v4-rc.mdx Co-authored-by: lrapoport-cf <107272160+lrapoport-cf@users.noreply.github.com> --- src/content/changelog/workers/2025-02-27-wrangler-v4-rc.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/changelog/workers/2025-02-27-wrangler-v4-rc.mdx b/src/content/changelog/workers/2025-02-27-wrangler-v4-rc.mdx index f66f6cfb5481baa..09f6c5fbc0aa131 100644 --- a/src/content/changelog/workers/2025-02-27-wrangler-v4-rc.mdx +++ b/src/content/changelog/workers/2025-02-27-wrangler-v4-rc.mdx @@ -53,7 +53,7 @@ Moving forward, the [active, maintenance, and current versions of Node.js](https ##### Features previously deprecated in Wrangler v3 are now removed in Wrangler v4 -All previously deprecated features in [Wrangler v2](https://developers.cloudflare.com/workers/wrangler/deprecations/#wrangler-v2) and in [Wrangler v3](https://developers.cloudflare.com/workers/wrangler/deprecations/#wrangler-v3) have now been removed. Additionally, the following features that were deprecated during the Wrangler v3 release lifecycle have been removed: +All previously deprecated features in [Wrangler v2](https://developers.cloudflare.com/workers/wrangler/deprecations/#wrangler-v2) and in [Wrangler v3](https://developers.cloudflare.com/workers/wrangler/deprecations/#wrangler-v3) have now been removed. Additionally, the following features that were deprecated during the Wrangler v3 release have been removed: - Legacy Assets (using `wrangler dev/deploy --legacy-assets` or the `legacy_assets` config file property). Instead, we recommend you [migrate to Workers assets](https://developers.cloudflare.com/workers/static-assets/). - Legacy Node.js compatibility (using `wrangler dev/deploy --node-compat` or the `node_compat` config file property). Instead, use the [`nodejs_compat` compatibility flag](https://developers.cloudflare.com/workers/runtime-apis/nodejs). This includes the functionality from legacy `node_compat` polyfills and natively implemented Node.js APIs. From de7e3e8604d18e16e39fcf936e86a18b6b04f170 Mon Sep 17 00:00:00 2001 From: Samuel Macleod Date: Fri, 28 Feb 2025 21:46:04 +0000 Subject: [PATCH 10/13] Add current deprecations to v3 deprecations page --- .../docs/workers/wrangler/deprecations.mdx | 138 ++++++++++-------- 1 file changed, 80 insertions(+), 58 deletions(-) diff --git a/src/content/docs/workers/wrangler/deprecations.mdx b/src/content/docs/workers/wrangler/deprecations.mdx index eb66f60ab357e9e..9d5f6f948e9ac97 100644 --- a/src/content/docs/workers/wrangler/deprecations.mdx +++ b/src/content/docs/workers/wrangler/deprecations.mdx @@ -4,7 +4,6 @@ title: Deprecations head: [] description: The differences between Wrangler versions, specifically deprecations and breaking changes. - --- Review the difference between Wrangler versions, specifically deprecations and breaking changes. @@ -33,6 +32,10 @@ The `wrangler pages publish` command is deprecated, but still active in v3. `wra Use [`wrangler pages deploy`](/workers/wrangler/commands/#deploy-1) to deploy Pages. +#### `version` + +Instead, use `wrangler --version` to check the current version of Wrangler. + ### Deprecated options #### `--experimental-local` @@ -51,86 +54,105 @@ Use [`wrangler pages deploy`](/workers/wrangler/commands/#deploy-1) to deploy Pa These options prevent `wrangler pages dev` from being able to accurately emulate production's behavior for serving static assets and have therefore been deprecated. Instead of relying on Wrangler to proxy through to some other upstream dev server, you can emulate a more accurate behavior by building your static assets to a directory and pointing Wrangler to that directory with `wrangler pages dev `. +### `--legacy-assets` and the `legacy_assets` config file property + +We recommend you [migrate to Workers assets](https://developers.cloudflare.com/workers/static-assets/) + +### `--node-compat` and the `node_compat` config file property + +Instead, use the [`nodejs_compat` compatibility flag](https://developers.cloudflare.com/workers/runtime-apis/nodejs). This includes the functionality from legacy `node_compat` polyfills and natively implemented Node.js APIs. + +### The `usage_model` config file property + +This no longer has any effect, after the [rollout of Workers Standard Pricing](https://blog.cloudflare.com/workers-pricing-scale-to-zero/). + ## Wrangler v2 Wrangler v2 introduces new fields for configuration and new features for developing and deploying a Worker, while deprecating some redundant fields. -* `wrangler.toml` is no longer mandatory. -* `dev` and `publish` accept CLI arguments. -* `tail` can be run on arbitrary Worker names. -* `init` creates a project boilerplate. -* JSON bindings for `vars`. -* Local mode for `wrangler dev`. -* Module system (for both modules and service worker format Workers). -* DevTools. -* TypeScript support. -* Sharing development environment on the Internet. -* Wider platform compatibility. -* Developer hotkeys. -* Better configuration validation. +- `wrangler.toml` is no longer mandatory. +- `dev` and `publish` accept CLI arguments. +- `tail` can be run on arbitrary Worker names. +- `init` creates a project boilerplate. +- JSON bindings for `vars`. +- Local mode for `wrangler dev`. +- Module system (for both modules and service worker format Workers). +- DevTools. +- TypeScript support. +- Sharing development environment on the Internet. +- Wider platform compatibility. +- Developer hotkeys. +- Better configuration validation. The following video describes some of the major changes in Wrangler v2, and shows you how Wrangler v2 can help speed up your workflow. -
+
+ +
### Common deprecations Refer to the following list for common fields that are no longer required. -* `type` is no longer required. Wrangler will infer the correct project type automatically. -* `zone_id` is no longer required. It can be deduced from the routes directly. -* `build.upload.format` is no longer used. The format is now inferred automatically from the code. -* `build.upload.main` and `build.upload.dir` are no longer required. Use the top level `main` field, which now serves as the entry-point for the Worker. -* `site.entry-point` is no longer required. The entry point should be specified through the `main` field. -* `webpack_config` and `webpack` properties are no longer supported. Refer to [Migrate webpack projects from Wrangler version 1](/workers/wrangler/migration/v1-to-v2/eject-webpack/). +- `type` is no longer required. Wrangler will infer the correct project type automatically. +- `zone_id` is no longer required. It can be deduced from the routes directly. +- `build.upload.format` is no longer used. The format is now inferred automatically from the code. +- `build.upload.main` and `build.upload.dir` are no longer required. Use the top level `main` field, which now serves as the entry-point for the Worker. +- `site.entry-point` is no longer required. The entry point should be specified through the `main` field. +- `webpack_config` and `webpack` properties are no longer supported. Refer to [Migrate webpack projects from Wrangler version 1](/workers/wrangler/migration/v1-to-v2/eject-webpack/). Here are the Wrangler v1 commands that are no longer supported: -* `wrangler preview` - Use the `wrangler dev` command, for running your worker in your local environment. -* `wrangler generate` - If you want to use a starter template, clone its GitHub repository and manually initialize it. -* `wrangler route` - Routes are defined in the [Wrangler configuration file](/workers/wrangler/configuration/). -* `wrangler report` - If you find a bug, report it at [Wrangler issues](https://github.com/cloudflare/workers-sdk/issues/new/choose). -* `wrangler build` - If you wish to access the output from bundling your Worker, use `wrangler publish --outdir=path/to/output`. +- `wrangler preview` - Use the `wrangler dev` command, for running your worker in your local environment. +- `wrangler generate` - If you want to use a starter template, clone its GitHub repository and manually initialize it. +- `wrangler route` - Routes are defined in the [Wrangler configuration file](/workers/wrangler/configuration/). +- `wrangler report` - If you find a bug, report it at [Wrangler issues](https://github.com/cloudflare/workers-sdk/issues/new/choose). +- `wrangler build` - If you wish to access the output from bundling your Worker, use `wrangler publish --outdir=path/to/output`. #### New fields These are new fields that can be added to your [Wrangler configuration file](/workers/wrangler/configuration/). -* **`main`**: `string`, optional +- **`main`**: `string`, optional The `main` field is used to specify an entry point to the Worker. It may be in the established service worker format, or the newer, preferred modules format. An entry point is now explicitly required, and can be configured either via the `main` field, or passed directly as a command line, for example, `wrangler dev index.js`. This field replaces the legacy `build.upload.main` field (which only applied to modules format Workers). -* **`rules`**: `array`, optional +- **`rules`**: `array`, optional The `rules` field is an array of mappings between module types and file patterns. It instructs Wrangler to interpret specific files differently than JavaScript. For example, this is useful for reading text-like content as text files, or compiled WASM as ready to instantiate and execute. These rules can apply to Workers of both the established service worker format, and the newer modules format. This field replaces the legacy `build.upload.rules` field (which only applied to modules format Workers). -{/* */} +- When `legacy_env` is `true`, it uses the legacy-style environments, where each environment is treated as a separate Worker in the dashboard, and environment names are appended to the `name` when published. +- When `legacy_env` is `false`, it uses the newer service environments, where scripts for a given Worker are grouped under the same script name in the Cloudflare Workers dashboard, and environments are subdomains for a given published script (when `workers_dev = true`). + Read more at (ref:)[] --> \*/} -{/* */} +- **`public`**: TODO --> \*/} #### Non-mandatory fields A few configuration fields which were previously required, are now optional in particular situations. They can either be inferred, or added as an optimization. No fields are required anymore when starting with Wrangler v2, and you can gradually add configuration as the need arises. -* **`name`**: `string` +- **`name`**: `string` The `name` configuration field is now not required for `wrangler dev`, or any of the `wrangler kv:*` commands. Further, it can also be passed as a command line argument as `--name `. It is still required for `wrangler publish`. -* **`account_id`**: `string` +- **`account_id`**: `string` The `account_id` field is not required for any of the commands. Any relevant commands will check if you are logged in, and if not, will prompt you to log in. Once logged in, it will use your account ID and will not prompt you again until your login session expires. If you have multiple account IDs, you will be presented with a list of accounts to choose from. You can still configure `account_id` in your Wrangler file, or as an environment variable `CLOUDFLARE_ACCOUNT_ID`. This makes startup faster and bypasses the list of choices if you have multiple IDs. The `CLOUDFLARE_API_TOKEN` environment variable is also useful for situations where it is not possible to login interactively. To learn more, visit [Running in CI/CD](/workers/ci-cd/external-cicd/). -* **`workers_dev`** `boolean`, default: `true` when no routes are present +- **`workers_dev`** `boolean`, default: `true` when no routes are present The `workers_dev` field is used to indicate that the Worker should be published to a `*.workers.dev` subdomain. For example, for a Worker named `my-worker` and a previously configured `*.workers.dev` subdomain `username`, the Worker will get published to `my-worker.username.workers.dev.com`. This field is not mandatory, and defaults to `true` when `route` or `routes` are not configured. When routes are present, it defaults to `false`. If you want to neither publish it to a `*.workers.dev` subdomain nor any routes, set `workers_dev` to `false`. This useful when you are publishing a Worker as a standalone service that can only be accessed from another Worker with (`services`). @@ -138,27 +160,27 @@ A few configuration fields which were previously required, are now optional in p A few configuration fields are deprecated, but their presence is not a breaking change yet. It is recommended to read the warning messages and follow the instructions to migrate to the new configuration. They will be removed and stop working in a future version. -* **`zone_id`**: `string`, deprecated +- **`zone_id`**: `string`, deprecated The `zone_id` field is deprecated and will be removed in a future release. It is now inferred from `route`/`routes`, and optionally from `dev.host` when using `wrangler dev`. This also makes it simpler to deploy a single Worker to multiple domains. -* **`build.upload`**: `object`, deprecated +- **`build.upload`**: `object`, deprecated The `build.upload` field is deprecated and will be removed in a future release. Its usage results in a warning with suggestions on rewriting the configuration file to remove the warnings. - * `build.upload.main`/`build.upload.dir` are replaced by the `main` fields and are applicable to both service worker format and modules format Workers. - * `build.upload.rules` is replaced by the `rules` field and is applicable to both service worker format and modules format Workers. - * `build.upload.format` is no longer specified and is automatically inferred by `wrangler`. + - `build.upload.main`/`build.upload.dir` are replaced by the `main` fields and are applicable to both service worker format and modules format Workers. + - `build.upload.rules` is replaced by the `rules` field and is applicable to both service worker format and modules format Workers. + - `build.upload.format` is no longer specified and is automatically inferred by `wrangler`. #### Deprecated fields (breaking) A few configuration fields are deprecated and will not work as expected anymore. It is recommended to read the error messages and follow the instructions to migrate to the new configuration. -* **`site.entry-point`**: `string`, deprecated +- **`site.entry-point`**: `string`, deprecated The `site.entry-point` configuration was used to specify an entry point for Workers with a `[site]` configuration. This has been replaced by the top-level `main` field. -* **`type`**: `rust` | `javascript` | `webpack`, deprecated +- **`type`**: `rust` | `javascript` | `webpack`, deprecated The `type` configuration was used to specify the type of Worker. It has since been made redundant and is now inferred from usage. If you were using `type = "webpack"` (and the optional `webpack_config` field), you should read the [webpack migration guide](/workers/wrangler/migration/v1-to-v2/eject-webpack/) to modify your project and use a custom build instead. @@ -198,11 +220,11 @@ Routes are specified in the [Wrangler configuration file](/workers/wrangler/conf ### Other deprecated behavior -* Cloudflare dashboard-defined routes will not be added alongside Wrangler-defined routes. Wrangler-defined routes are the `route` or `routes` key in your `wrangler.toml`. If both are defined, only routes defined in `wrangler.toml` will be valid. To manage routes via the Cloudflare dashboard only, remove any `route` and `routes` keys from and add `workers_dev = false` to your Wrangler file. +- Cloudflare dashboard-defined routes will not be added alongside Wrangler-defined routes. Wrangler-defined routes are the `route` or `routes` key in your `wrangler.toml`. If both are defined, only routes defined in `wrangler.toml` will be valid. To manage routes via the Cloudflare dashboard only, remove any `route` and `routes` keys from and add `workers_dev = false` to your Wrangler file. -* Wrangler will no longer use `index.js` in the directory where `wrangler dev` is called as the entry point to a Worker. Use the `main` configuration field, or explicitly pass it as a command line argument, for example: `wrangler dev index.js`. +- Wrangler will no longer use `index.js` in the directory where `wrangler dev` is called as the entry point to a Worker. Use the `main` configuration field, or explicitly pass it as a command line argument, for example: `wrangler dev index.js`. -* Wrangler will no longer assume that bare specifiers are file names if they are not represented as a path. For example, in a folder like so: +- Wrangler will no longer assume that bare specifiers are file names if they are not represented as a path. For example, in a folder like so: ``` project @@ -216,7 +238,7 @@ Routes are specified in the [Wrangler configuration file](/workers/wrangler/conf import SomeDependency from "some-dependency.js"; addEventListener("fetch", (event) => { - // ... + // ... }); ``` @@ -231,8 +253,8 @@ Routes are specified in the [Wrangler configuration file](/workers/wrangler/conf #### Commands -| Command | v1 | v2 | Notes | -| ----------- | -- | -- | ---------------------------------------------- | +| Command | v1 | v2 | Notes | +| ----------- | --- | --- | ---------------------------------------------- | | `publish` | ✅ | ✅ | | | `dev` | ✅ | ✅ | | | `preview` | ✅ | ❌ | Removed, use `dev` instead. | @@ -243,7 +265,7 @@ Routes are specified in the [Wrangler configuration file](/workers/wrangler/conf | `route` | ✅ | ❌ | Removed, use `publish` instead. | | `tail` | ✅ | ✅ | | | `kv` | ✅ | ✅ | | -| `r2` | 🚧 | ✅ | Introduced in Wrangler v1.19.8. | +| `r2` | 🚧 | ✅ | Introduced in Wrangler v1.19.8. | | `pages` | ❌ | ✅ | | | `config` | ✅ | ❓ | | | `login` | ✅ | ✅ | | @@ -254,15 +276,15 @@ Routes are specified in the [Wrangler configuration file](/workers/wrangler/conf #### Configuration -| Property | v1 | v2 | Notes | -| --------------------- | -- | -- | ------------------------------------------------------------------------------------------------------------------------------------------------ | +| Property | v1 | v2 | Notes | +| --------------------- | --- | --- | ----------------------------------------------------------------------------------------------- | | `type = "webpack"` | ✅ | ❌ | Removed, refer to [this guide](/workers/wrangler/migration/v1-to-v2/eject-webpack/) to migrate. | -| `type = "rust"` | ✅ | ❌ | Removed, use [`workers-rs`](https://github.com/cloudflare/workers-rs) instead. | -| `type = "javascript"` | ✅ | 🚧 | No longer required, can be omitted. | +| `type = "rust"` | ✅ | ❌ | Removed, use [`workers-rs`](https://github.com/cloudflare/workers-rs) instead. | +| `type = "javascript"` | ✅ | 🚧 | No longer required, can be omitted. | #### Features -| Feature | v1 | v2 | Notes | -| ---------- | -- | -- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Feature | v1 | v2 | Notes | +| ---------- | --- | --- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | TypeScript | ❌ | ✅ | You can give wrangler a TypeScript file, and it will automatically transpile it to JavaScript using [`esbuild`](https://github.com/evanw/esbuild) under-the-hood. | | Local mode | ❌ | ✅ | `wrangler dev --local` will run your Worker on your local machine instead of on our network. This is powered by [Miniflare](https://github.com/cloudflare/workers-sdk/tree/main/packages/miniflare/). | From d231eb569d55695f801a9094379dc3c3403a4cbb Mon Sep 17 00:00:00 2001 From: Samuel Macleod Date: Fri, 28 Feb 2025 21:49:38 +0000 Subject: [PATCH 11/13] fix headers --- src/content/docs/workers/wrangler/deprecations.mdx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/content/docs/workers/wrangler/deprecations.mdx b/src/content/docs/workers/wrangler/deprecations.mdx index 9d5f6f948e9ac97..04b6210b412e2dc 100644 --- a/src/content/docs/workers/wrangler/deprecations.mdx +++ b/src/content/docs/workers/wrangler/deprecations.mdx @@ -54,15 +54,15 @@ Instead, use `wrangler --version` to check the current version of Wrangler. These options prevent `wrangler pages dev` from being able to accurately emulate production's behavior for serving static assets and have therefore been deprecated. Instead of relying on Wrangler to proxy through to some other upstream dev server, you can emulate a more accurate behavior by building your static assets to a directory and pointing Wrangler to that directory with `wrangler pages dev `. -### `--legacy-assets` and the `legacy_assets` config file property +#### `--legacy-assets` and the `legacy_assets` config file property We recommend you [migrate to Workers assets](https://developers.cloudflare.com/workers/static-assets/) -### `--node-compat` and the `node_compat` config file property +#### `--node-compat` and the `node_compat` config file property Instead, use the [`nodejs_compat` compatibility flag](https://developers.cloudflare.com/workers/runtime-apis/nodejs). This includes the functionality from legacy `node_compat` polyfills and natively implemented Node.js APIs. -### The `usage_model` config file property +#### The `usage_model` config file property This no longer has any effect, after the [rollout of Workers Standard Pricing](https://blog.cloudflare.com/workers-pricing-scale-to-zero/). From d51acd029f6961448273471c70491763436e5f22 Mon Sep 17 00:00:00 2001 From: Samuel Macleod Date: Fri, 28 Feb 2025 22:02:26 +0000 Subject: [PATCH 12/13] undo format --- .../docs/workers/wrangler/deprecations.mdx | 122 +++++++++--------- 1 file changed, 58 insertions(+), 64 deletions(-) diff --git a/src/content/docs/workers/wrangler/deprecations.mdx b/src/content/docs/workers/wrangler/deprecations.mdx index 04b6210b412e2dc..1cfe92f9a6f3d4d 100644 --- a/src/content/docs/workers/wrangler/deprecations.mdx +++ b/src/content/docs/workers/wrangler/deprecations.mdx @@ -4,6 +4,7 @@ title: Deprecations head: [] description: The differences between Wrangler versions, specifically deprecations and breaking changes. + --- Review the difference between Wrangler versions, specifically deprecations and breaking changes. @@ -70,89 +71,82 @@ This no longer has any effect, after the [rollout of Workers Standard Pricing](h Wrangler v2 introduces new fields for configuration and new features for developing and deploying a Worker, while deprecating some redundant fields. -- `wrangler.toml` is no longer mandatory. -- `dev` and `publish` accept CLI arguments. -- `tail` can be run on arbitrary Worker names. -- `init` creates a project boilerplate. -- JSON bindings for `vars`. -- Local mode for `wrangler dev`. -- Module system (for both modules and service worker format Workers). -- DevTools. -- TypeScript support. -- Sharing development environment on the Internet. -- Wider platform compatibility. -- Developer hotkeys. -- Better configuration validation. +* `wrangler.toml` is no longer mandatory. +* `dev` and `publish` accept CLI arguments. +* `tail` can be run on arbitrary Worker names. +* `init` creates a project boilerplate. +* JSON bindings for `vars`. +* Local mode for `wrangler dev`. +* Module system (for both modules and service worker format Workers). +* DevTools. +* TypeScript support. +* Sharing development environment on the Internet. +* Wider platform compatibility. +* Developer hotkeys. +* Better configuration validation. The following video describes some of the major changes in Wrangler v2, and shows you how Wrangler v2 can help speed up your workflow. -
- -
+
### Common deprecations Refer to the following list for common fields that are no longer required. -- `type` is no longer required. Wrangler will infer the correct project type automatically. -- `zone_id` is no longer required. It can be deduced from the routes directly. -- `build.upload.format` is no longer used. The format is now inferred automatically from the code. -- `build.upload.main` and `build.upload.dir` are no longer required. Use the top level `main` field, which now serves as the entry-point for the Worker. -- `site.entry-point` is no longer required. The entry point should be specified through the `main` field. -- `webpack_config` and `webpack` properties are no longer supported. Refer to [Migrate webpack projects from Wrangler version 1](/workers/wrangler/migration/v1-to-v2/eject-webpack/). +* `type` is no longer required. Wrangler will infer the correct project type automatically. +* `zone_id` is no longer required. It can be deduced from the routes directly. +* `build.upload.format` is no longer used. The format is now inferred automatically from the code. +* `build.upload.main` and `build.upload.dir` are no longer required. Use the top level `main` field, which now serves as the entry-point for the Worker. +* `site.entry-point` is no longer required. The entry point should be specified through the `main` field. +* `webpack_config` and `webpack` properties are no longer supported. Refer to [Migrate webpack projects from Wrangler version 1](/workers/wrangler/migration/v1-to-v2/eject-webpack/). Here are the Wrangler v1 commands that are no longer supported: -- `wrangler preview` - Use the `wrangler dev` command, for running your worker in your local environment. -- `wrangler generate` - If you want to use a starter template, clone its GitHub repository and manually initialize it. -- `wrangler route` - Routes are defined in the [Wrangler configuration file](/workers/wrangler/configuration/). -- `wrangler report` - If you find a bug, report it at [Wrangler issues](https://github.com/cloudflare/workers-sdk/issues/new/choose). -- `wrangler build` - If you wish to access the output from bundling your Worker, use `wrangler publish --outdir=path/to/output`. +* `wrangler preview` - Use the `wrangler dev` command, for running your worker in your local environment. +* `wrangler generate` - If you want to use a starter template, clone its GitHub repository and manually initialize it. +* `wrangler route` - Routes are defined in the [Wrangler configuration file](/workers/wrangler/configuration/). +* `wrangler report` - If you find a bug, report it at [Wrangler issues](https://github.com/cloudflare/workers-sdk/issues/new/choose). +* `wrangler build` - If you wish to access the output from bundling your Worker, use `wrangler publish --outdir=path/to/output`. #### New fields These are new fields that can be added to your [Wrangler configuration file](/workers/wrangler/configuration/). -- **`main`**: `string`, optional +* **`main`**: `string`, optional The `main` field is used to specify an entry point to the Worker. It may be in the established service worker format, or the newer, preferred modules format. An entry point is now explicitly required, and can be configured either via the `main` field, or passed directly as a command line, for example, `wrangler dev index.js`. This field replaces the legacy `build.upload.main` field (which only applied to modules format Workers). -- **`rules`**: `array`, optional +* **`rules`**: `array`, optional The `rules` field is an array of mappings between module types and file patterns. It instructs Wrangler to interpret specific files differently than JavaScript. For example, this is useful for reading text-like content as text files, or compiled WASM as ready to instantiate and execute. These rules can apply to Workers of both the established service worker format, and the newer modules format. This field replaces the legacy `build.upload.rules` field (which only applied to modules format Workers). -{/\* \*/} + - When `legacy_env` is `true`, it uses the legacy-style environments, where each environment is treated as a separate Worker in the dashboard, and environment names are appended to the `name` when published. + - When `legacy_env` is `false`, it uses the newer service environments, where scripts for a given Worker are grouped under the same script name in the Cloudflare Workers dashboard, and environments are subdomains for a given published script (when `workers_dev = true`). + Read more at (ref:)[] --> */} -{/\* \*/} +- **`public`**: TODO --> */} #### Non-mandatory fields A few configuration fields which were previously required, are now optional in particular situations. They can either be inferred, or added as an optimization. No fields are required anymore when starting with Wrangler v2, and you can gradually add configuration as the need arises. -- **`name`**: `string` +* **`name`**: `string` The `name` configuration field is now not required for `wrangler dev`, or any of the `wrangler kv:*` commands. Further, it can also be passed as a command line argument as `--name `. It is still required for `wrangler publish`. -- **`account_id`**: `string` +* **`account_id`**: `string` The `account_id` field is not required for any of the commands. Any relevant commands will check if you are logged in, and if not, will prompt you to log in. Once logged in, it will use your account ID and will not prompt you again until your login session expires. If you have multiple account IDs, you will be presented with a list of accounts to choose from. You can still configure `account_id` in your Wrangler file, or as an environment variable `CLOUDFLARE_ACCOUNT_ID`. This makes startup faster and bypasses the list of choices if you have multiple IDs. The `CLOUDFLARE_API_TOKEN` environment variable is also useful for situations where it is not possible to login interactively. To learn more, visit [Running in CI/CD](/workers/ci-cd/external-cicd/). -- **`workers_dev`** `boolean`, default: `true` when no routes are present +* **`workers_dev`** `boolean`, default: `true` when no routes are present The `workers_dev` field is used to indicate that the Worker should be published to a `*.workers.dev` subdomain. For example, for a Worker named `my-worker` and a previously configured `*.workers.dev` subdomain `username`, the Worker will get published to `my-worker.username.workers.dev.com`. This field is not mandatory, and defaults to `true` when `route` or `routes` are not configured. When routes are present, it defaults to `false`. If you want to neither publish it to a `*.workers.dev` subdomain nor any routes, set `workers_dev` to `false`. This useful when you are publishing a Worker as a standalone service that can only be accessed from another Worker with (`services`). @@ -160,27 +154,27 @@ A few configuration fields which were previously required, are now optional in p A few configuration fields are deprecated, but their presence is not a breaking change yet. It is recommended to read the warning messages and follow the instructions to migrate to the new configuration. They will be removed and stop working in a future version. -- **`zone_id`**: `string`, deprecated +* **`zone_id`**: `string`, deprecated The `zone_id` field is deprecated and will be removed in a future release. It is now inferred from `route`/`routes`, and optionally from `dev.host` when using `wrangler dev`. This also makes it simpler to deploy a single Worker to multiple domains. -- **`build.upload`**: `object`, deprecated +* **`build.upload`**: `object`, deprecated The `build.upload` field is deprecated and will be removed in a future release. Its usage results in a warning with suggestions on rewriting the configuration file to remove the warnings. - - `build.upload.main`/`build.upload.dir` are replaced by the `main` fields and are applicable to both service worker format and modules format Workers. - - `build.upload.rules` is replaced by the `rules` field and is applicable to both service worker format and modules format Workers. - - `build.upload.format` is no longer specified and is automatically inferred by `wrangler`. + * `build.upload.main`/`build.upload.dir` are replaced by the `main` fields and are applicable to both service worker format and modules format Workers. + * `build.upload.rules` is replaced by the `rules` field and is applicable to both service worker format and modules format Workers. + * `build.upload.format` is no longer specified and is automatically inferred by `wrangler`. #### Deprecated fields (breaking) A few configuration fields are deprecated and will not work as expected anymore. It is recommended to read the error messages and follow the instructions to migrate to the new configuration. -- **`site.entry-point`**: `string`, deprecated +* **`site.entry-point`**: `string`, deprecated The `site.entry-point` configuration was used to specify an entry point for Workers with a `[site]` configuration. This has been replaced by the top-level `main` field. -- **`type`**: `rust` | `javascript` | `webpack`, deprecated +* **`type`**: `rust` | `javascript` | `webpack`, deprecated The `type` configuration was used to specify the type of Worker. It has since been made redundant and is now inferred from usage. If you were using `type = "webpack"` (and the optional `webpack_config` field), you should read the [webpack migration guide](/workers/wrangler/migration/v1-to-v2/eject-webpack/) to modify your project and use a custom build instead. @@ -220,11 +214,11 @@ Routes are specified in the [Wrangler configuration file](/workers/wrangler/conf ### Other deprecated behavior -- Cloudflare dashboard-defined routes will not be added alongside Wrangler-defined routes. Wrangler-defined routes are the `route` or `routes` key in your `wrangler.toml`. If both are defined, only routes defined in `wrangler.toml` will be valid. To manage routes via the Cloudflare dashboard only, remove any `route` and `routes` keys from and add `workers_dev = false` to your Wrangler file. +* Cloudflare dashboard-defined routes will not be added alongside Wrangler-defined routes. Wrangler-defined routes are the `route` or `routes` key in your `wrangler.toml`. If both are defined, only routes defined in `wrangler.toml` will be valid. To manage routes via the Cloudflare dashboard only, remove any `route` and `routes` keys from and add `workers_dev = false` to your Wrangler file. -- Wrangler will no longer use `index.js` in the directory where `wrangler dev` is called as the entry point to a Worker. Use the `main` configuration field, or explicitly pass it as a command line argument, for example: `wrangler dev index.js`. +* Wrangler will no longer use `index.js` in the directory where `wrangler dev` is called as the entry point to a Worker. Use the `main` configuration field, or explicitly pass it as a command line argument, for example: `wrangler dev index.js`. -- Wrangler will no longer assume that bare specifiers are file names if they are not represented as a path. For example, in a folder like so: +* Wrangler will no longer assume that bare specifiers are file names if they are not represented as a path. For example, in a folder like so: ``` project @@ -238,7 +232,7 @@ Routes are specified in the [Wrangler configuration file](/workers/wrangler/conf import SomeDependency from "some-dependency.js"; addEventListener("fetch", (event) => { - // ... + // ... }); ``` @@ -253,8 +247,8 @@ Routes are specified in the [Wrangler configuration file](/workers/wrangler/conf #### Commands -| Command | v1 | v2 | Notes | -| ----------- | --- | --- | ---------------------------------------------- | +| Command | v1 | v2 | Notes | +| ----------- | -- | -- | ---------------------------------------------- | | `publish` | ✅ | ✅ | | | `dev` | ✅ | ✅ | | | `preview` | ✅ | ❌ | Removed, use `dev` instead. | @@ -265,7 +259,7 @@ Routes are specified in the [Wrangler configuration file](/workers/wrangler/conf | `route` | ✅ | ❌ | Removed, use `publish` instead. | | `tail` | ✅ | ✅ | | | `kv` | ✅ | ✅ | | -| `r2` | 🚧 | ✅ | Introduced in Wrangler v1.19.8. | +| `r2` | 🚧 | ✅ | Introduced in Wrangler v1.19.8. | | `pages` | ❌ | ✅ | | | `config` | ✅ | ❓ | | | `login` | ✅ | ✅ | | @@ -276,15 +270,15 @@ Routes are specified in the [Wrangler configuration file](/workers/wrangler/conf #### Configuration -| Property | v1 | v2 | Notes | -| --------------------- | --- | --- | ----------------------------------------------------------------------------------------------- | +| Property | v1 | v2 | Notes | +| --------------------- | -- | -- | ------------------------------------------------------------------------------------------------------------------------------------------------ | | `type = "webpack"` | ✅ | ❌ | Removed, refer to [this guide](/workers/wrangler/migration/v1-to-v2/eject-webpack/) to migrate. | -| `type = "rust"` | ✅ | ❌ | Removed, use [`workers-rs`](https://github.com/cloudflare/workers-rs) instead. | -| `type = "javascript"` | ✅ | 🚧 | No longer required, can be omitted. | +| `type = "rust"` | ✅ | ❌ | Removed, use [`workers-rs`](https://github.com/cloudflare/workers-rs) instead. | +| `type = "javascript"` | ✅ | 🚧 | No longer required, can be omitted. | #### Features -| Feature | v1 | v2 | Notes | -| ---------- | --- | --- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Feature | v1 | v2 | Notes | +| ---------- | -- | -- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | TypeScript | ❌ | ✅ | You can give wrangler a TypeScript file, and it will automatically transpile it to JavaScript using [`esbuild`](https://github.com/evanw/esbuild) under-the-hood. | | Local mode | ❌ | ✅ | `wrangler dev --local` will run your Worker on your local machine instead of on our network. This is powered by [Miniflare](https://github.com/cloudflare/workers-sdk/tree/main/packages/miniflare/). | From 93b911eb1eafa228d85eccada5f15b644e8e5021 Mon Sep 17 00:00:00 2001 From: Samuel Macleod Date: Fri, 28 Feb 2025 22:03:19 +0000 Subject: [PATCH 13/13] use today date --- ...5-02-27-wrangler-v4-rc.mdx => 2025-02-28-wrangler-v4-rc.mdx} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename src/content/changelog/workers/{2025-02-27-wrangler-v4-rc.mdx => 2025-02-28-wrangler-v4-rc.mdx} (99%) diff --git a/src/content/changelog/workers/2025-02-27-wrangler-v4-rc.mdx b/src/content/changelog/workers/2025-02-28-wrangler-v4-rc.mdx similarity index 99% rename from src/content/changelog/workers/2025-02-27-wrangler-v4-rc.mdx rename to src/content/changelog/workers/2025-02-28-wrangler-v4-rc.mdx index 09f6c5fbc0aa131..baf68eab12a1ff2 100644 --- a/src/content/changelog/workers/2025-02-27-wrangler-v4-rc.mdx +++ b/src/content/changelog/workers/2025-02-28-wrangler-v4-rc.mdx @@ -3,7 +3,7 @@ title: Use the latest JavaScript features with Wrangler CLI v4.0.0-rc.0 description: You can now try out the v4 RC for Wrangler by installing `wrangler@4.0.0-rc.0` products: - workers -date: 2025-02-27T11:00:00Z +date: 2025-02-28T22:30:00Z --- import { PackageManagers } from "~/components";