Skip to content
84 changes: 84 additions & 0 deletions src/content/changelog/workers/2025-02-27-wrangler-v4-rc.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
---
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 `[email protected]`
products:
- workers
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 — `[email protected]`.

You can run the following command to install it and be one of the first to try it out:

<PackageManagers pkg="wrangler@v4-rc" />

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

##### 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.

##### 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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lrapoport-cf @penalosa for the things below, I think if you work on Wrangler it's easy to look at this list and know "oh yeah these are all old things that there are other ways of doing" — but right now this comes across as a long list without guidance on what people can do instead.

Especially since we already have a lot of the deprecations and guidance here:

https://developers.cloudflare.com/workers/wrangler/deprecations/#wrangler-v3

...should we just update that page with the RC v4 stuff, and in this post, link directly to it?

I think it could help us tighten up the post, and also help send the reader to the page that will give them the relevant details they need

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I included the list for completeness, but we could actually remove a fair few—a lot of these were deprecated in v2 and have never worked in v2+

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strawman suggestion:

  • keep any deprecations that are new, that we haven't communicated previously
  • for the ones we have already talked about for v2 and v3, just say that things previously deprecated are now removed, and link to that deprecations page
  • update the deprecations page with this list we have here so that it's concrete somewhere in dev docs

Sound good?

Then we can follow up and make the deprecations page slightly clearer

Think that would go a long way and then we're good here to ship this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, although maybe we shouldn't update the deprecation page at this point? Once v4 is released properly we'll have a full migration guide we can point people to, but that's not fully ready yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't feel strongly about it though—happy to update that now if you think that makes sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i left a couple really small comments, but overall looks good to me! agree with @irvinebroque we should update the deprecations page, for completeness

- `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`

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).
Loading