Changelog
New updates and improvements at Cloudflare. Subscribe to RSS
Use the latest JavaScript features with Wrangler CLI v4.0.0-rc.0
We've released a release candidate of the next major version of 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:
npm i wrangler@v4-rc
pnpm add wrangler@v4-rc
yarn add wrangler@v4-rc
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 are sharing this release candidate in advance of the official release of v4, so that you can try it out early and share feedback.
Version 4 of Wrangler updates the version of esbuild ↗ that Wrangler uses internally, allowing you to use modern JavaScript language features, including:
The using
keyword from the Explicit Resource Management standard makes it easier to work with the JavaScript-native RPC system built into Workers. This means that when you obtain a stub, you can ensure that it is automatically disposed when you exit scope it was created in:
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 ↗ 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:
import data from "./data.json" with { type: "json" };
All commands that access resources (for example, wrangler kv
, wrangler r2
, wrangler d1
) now access local datastores by default, ensuring consistent behavior.
Moving forward, the active, maintenance, and current versions of Node.js ↗ 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.
All previously deprecated features in Wrangler v2 ↗ and in 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 thelegacy_assets
config file property). Instead, we recommend you migrate to Workers assets ↗. - Legacy Node.js compatibility (using
wrangler dev/deploy --node-compat
or thenode_compat
config file property). Instead, use thenodejs_compat
compatibility flag ↗. This includes the functionality from legacynode_compat
polyfills and natively implemented Node.js APIs. wrangler version
. Instead, usewrangler --version
to check the current version of Wrangler.getBindingsProxy()
(viaimport { getBindingsProxy } from "wrangler"
). Instead, use thegetPlatformProxy()
API ↗, which takes exactly the same arguments.usage_model
. This no longer has any effect, after the rollout of Workers Standard Pricing ↗.
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 ↗.