Skip to content

Latest commit

 

History

History
3859 lines (2248 loc) · 320 KB

CHANGELOG.md

File metadata and controls

3859 lines (2248 loc) · 320 KB

wrangler

2.1.9

Patch Changes

  • #1937 905fce4f Thanks @JacobMGEvans! - fix: fails to publish due to empty migrations After this change, wrangler init --from-dash will not attempt to add durable object migrations to wrangler.toml for Workers that don't have durable objects.

    fixes #1854

  • #1943 58a430f2 Thanks @cameron-robey! - chore: add env and ctx params to fetch in javascript example template

    Just like in the typescript templates, and the javascript template for scheduled workers, we include env and ctx as parameters to the fetch export. This makes it clearer where environment variables live.

  • #1939 5854cb69 Thanks @rozenmd! - fix: respect variable binding type when printing

    After this change, when printing the bindings it has access to, wrangler will correctly only add quotes around string variables, and serialize objects via JSON.stringify (rather than printing "[object Object]").

  • #1930 56798155 Thanks @rozenmd! - fix: use node http instead of faye-websocket in proxy server

    We change how websockets are handled in the proxy server, fixing multiple issues of websocket behaviour, particularly to do with headers.

    In particular this fixes:

    • the protocol passed between the client and the worker was being stripped out by wrangler
    • wrangler was discarding additional headesr from websocket upgrade response
    • websocket close code and reason was not being propagated by wrangler

2.1.8

Patch Changes

  • #1894 ed646cf9 Thanks @mrbbot! - Add experimental support for using the open-source Workers runtime workerd in wrangler dev. Use wrangler dev --experimental-local to try it out! 🚀 Note this feature is still under active development.

2.1.7

Patch Changes

  • #1881 6ff5a030 Thanks @Skye-31! - Chore: correctly log all listening ports on remote mode (closes #1652)
  • #1913 9f7cc5a0 Thanks @threepointone! - feat: expose port and address on (Unstable)DevWorker

    when using unstable_dev(), I think we want to expose the port/address that the server has started on. The usecase is when trying to connect to the server without calling .fetch() (example: when making a websocket connection).

  • #1911 16c28502 Thanks @rozenmd! - fix: put config cache log behind logger.debug

    Prior to this change, wrangler would print Retrieving cached values for... after almost every single command.

    After this change, you'll only see this message if you add WRANGLER_DEBUG=true before your command.

    Closes #1808

2.1.6

Patch Changes

  • #1895 1b53bf9d Thanks @rozenmd! - fix: rename keep_bindings to keep_vars, and make it opt-in, to keep wrangler.toml compatible with being used for Infrastructure as Code

    By default, wrangler.toml is the source of truth for your environment configuration, like a terraform file.

    If you change your settings (particularly your vars) in the dashboard, wrangler will override them. If you want to disable this behavior, set this field to true.

    Between wrangler 2.0.28 and 2.1.5, by default wrangler would not delete your vars by default, breaking expected wrangler.toml behaviour.

  • #1889 98f756c7 Thanks @penalosa! - fix: Correctly place the .wrangler/state local state directory in the same directory as wrangler.toml by default
  • #1886 8b647175 Thanks @JacobMGEvans! - fix: potential missing compatibility_date in wrangler.toml when running wrangler init --from-dash Fixed a bug where compatibility_date wasn't being added to wrangler.toml when initializing a worker via wrangler init --from-dash

    fixes #1855

2.1.5

Patch Changes

  • #1815 d8fe95d2 Thanks @cameron-robey! - feat: testing scheduled events with wrangler dev remote mode

    Using the new middleware (#1735), we implement a way of testing scheduled workers from a fetch using wrangler dev in remote mode, by passing a new command line flag --test-scheduled. This exposes a route /__scheduled which will trigger the scheduled event.

    $ npx wrangler dev index.js --test-scheduled
    
    $ curl http://localhost:8787/__scheduled

    Closes #570

  • #1801 07fc90d6 Thanks @rozenmd! - feat: multi-worker testing

    This change introduces the ability to test multi-worker setups via the wrangler API's unstable_dev function.

    Usage:

    import { unstable_dev } from "wrangler";
    
    /**
     * Note: if you shut down the first worker you spun up,
     * the parent worker won't know the child worker exists
     * and your tests will fail
     */
    describe("multi-worker testing", () => {
    	let childWorker;
    	let parentWorker;
    
    	beforeAll(async () => {
    		childWorker = await unstable_dev(
    			"src/child-worker.js",
    			{ config: "src/child-wrangler.toml" },
    			{ disableExperimentalWarning: true }
    		);
    		parentWorker = await unstable_dev(
    			"src/parent-worker.js",
    			{ config: "src/parent-wrangler.toml" },
    			{ disableExperimentalWarning: true }
    		);
    	});
    
    	afterAll(async () => {
    		await childWorker.stop();
    		await parentWorker.stop();
    	});
    
    	it("childWorker should return Hello World itself", async () => {
    		const resp = await childWorker.fetch();
    		if (resp) {
    			const text = await resp.text();
    			expect(text).toMatchInlineSnapshot(`"Hello World!"`);
    		}
    	});
    
    	it("parentWorker should return Hello World by invoking the child worker", async () => {
    		const resp = await parentWorker.fetch();
    		if (resp) {
    			const parsedResp = await resp.text();
    			expect(parsedResp).toEqual("Parent worker sees: Hello World!");
    		}
    	});
    });
  • #1865 adfc52d6 Thanks @JacobMGEvans! - polish: loglevel flag Added a '--log-level' flag that allows the user to specify between 'debug', 'info', 'log', 'warning', 'error', 'none' Currently 'none' will turn off all outputs in Miniflare (local mode), however, Wrangler will still output Errors.

    resolves #185

2.1.4

Patch Changes

  • #1839 2660872a Thanks @cameron-robey! - feat: make it possible to specify a path for unstable_dev()'s fetch method

    const worker = await unstable_dev(
      "script.js"
    );
    const res = await worker.fetch(req);
    

    where req can be anything from RequestInfo: string | URL | Request.

  • #1851 afca1b6c Thanks @cameron-robey! - feat: summary output for secret:bulk

    When wrangler secret:bulk <json> is run, a summary is outputted at the end with the number of secrets successfully / unsuccessfully created.

  • #1846 f450e387 Thanks @rozenmd! - fix: when running wrangler init, add a test script to package.json when the user asks us to write their first test

2.1.3

Patch Changes

  • #1836 3583f313 Thanks @rozenmd! - fix: wrangler publish for CI after a manual deployment

    Prior to this change, if you edited your Worker via the Cloudflare Dashboard, then used CI to deploy your script, wrangler publish would fail.

    This change logs a warning that your manual changes are going to be overriden, but doesn't require user input to proceed.

    Closes #1832

  • #1644 dc1c9595 Thanks @geelen! - Deprecated --experimental-enable-local-persistence.

    Added --persist and --persist-to in its place. Changed the default persistence directory to .wrangler/state, relative to wrangler.toml.

    To migrate to the new flag, run mkdir -p .wrangler && mv wrangler-local-state .wrangler/state then use --persist. Alternatively, you can use --persist-to=./wrangler-local-state to keep using the files in the old location.

2.1.2

Patch Changes

2.1.1

Patch Changes

  • #1827 32a58fee Thanks @JacobMGEvans! - fix: Publish error when deploying new Workers

    This fix adds a try/catch when checking when the Worker was last deployed.

    The check was failing when a Worker had never been deployed, causing deployments of new Workers to fail.

    fixes #1824

  • #1799 a89786ba Thanks @JacobMGEvans! - feat: Bulk Secret Upload Created a flag that allows for passing in a JSON file with key/value's of secrets.

    resolve #1610

2.1.0

Minor Changes

  • #1713 82451e9d Thanks @jspspike! - Tail now uses updated endpoint. Allows tailing workers that are above the normal "invocations per second" limit when using the --ip self filter.

Patch Changes

  • #1782 cc43e3c4 Thanks @jahands! - fix: Update Pages test to assert version in package.json

    This test was asserting a hardcoded wrangler version which broke after release.

  • #1786 1af49b68 Thanks @rozenmd! - fix: refactor unstable_dev to avoid race conditions with ports

    Prior to this change, wrangler would check to see if a port was available, do a bit more work, then try use that port when starting miniflare. With this change, we're using port 0 to tell Node to assign us a random free port.

    To make this change work, we had to do some plumbing so miniflare can tell us the host and port it's using, so we can call fetch against it.

  • #1788 152a1e81 Thanks @GregBrimble! - chore: Refactor 'wrangler pages dev' to use the same code as we do in production

    This will make our dev implementation an even closer simulation of production, and will make maintenance easier going forward.

  • #1789 b21ee41a Thanks @JacobMGEvans! - fix: getMonth compatibility date Set correct month for compatibility_date when initializing a new Worker

    resolves #1766

  • #1694 3fb730a3 Thanks @yjl9903! - feat: starting pages dev server doesn't require command when proxy port provided
  • #1729 ebb5b88f Thanks @JacobMGEvans! - feat: autogenerated config from dash

    Makes wrangler init's --from-dash option pull in data from Cloudflare's dashboard to generate a wrangler.toml file populated with configuration from an existing Worker. This is a first step towards making wrangler init more useful for folks who are already using Cloudflare's products on the Dashboard.

    related discussion #1623 resolves #1638

  • #1781 603d0b35 Thanks @JacobMGEvans! - feat: Publish Origin Messaging feat: warn about potential conflicts during publish and init --from-dash.

    • If publishing to a worker that has been modified in the dashboard, warn that the dashboard changes will be overwritten.
    • When initializing from the dashboard, warn that future changes via the dashboard will not automatically appear in the local Worker config.

    resolves #1737

  • #1735 de29a445 Thanks @cameron-robey! - feat: new internal middleware

    A new way of registering middleware that gets bundled and executed on the edge.

    • the same middleware functions can be used for both modules workers and service workers
    • only requires running esbuild a fixed number of times, rather than for each middleware added

2.0.29

Patch Changes

  • #1762 23f89216 Thanks @petebacondarwin! - Use getBasePath() when trying to specify paths to files relative to the base of the Wrangler package directory rather than trying to compute the path from Node.js constants like **dirname and **filename. This is because the act of bundling the source code can move the file that contains these constants around potentially breaking the relative path to the desired files.

    Fixes #1755

  • #1763 75f3ae82 Thanks @CarmenPopoviciu! - Add description field to _routes.json

    When generating routes for Functions projects, let's add a description so we know what wrangler version generated this config

  • #1538 2c9caf74 Thanks @rozenmd! - chore: refactor wrangler.dev API to not need React/Ink

    Prior to this change, wrangler.unstable_dev() would only support running one instance of wrangler at a time, as Ink only lets you render one instance of React. This resulted in test failures in CI.

    This change creates pure JS/TS versions of these React hooks:

    • useEsbuild
    • useLocalWorker
    • useCustomBuild
    • useTmpDir

    As a side-effect of removing React, tests should run faster in CI.

    Closes #1432 Closes #1419

2.0.28

Patch Changes

  • #1725 eb75413e Thanks @threepointone! - rename: worker_namespaces / dispatch_namespaces

    The Worker-for-Platforms team would like to rename this field to more closely match what it's called internally. This fix does a search+replace on this term. This feature already had an experimental warning, and no one's using it at the moment, so we're not going to add a warning/backward compat for existing customers.

  • #1736 800f8553 Thanks @threepointone! - fix: do not delete previously defined plain_text/json bindings on publish

    Currently, when we publish a worker, we delete an pre-existing bindings if they're not otherwise defined in wrangler.toml, and overwrite existing ones. But folks may be deploying with wrangler, and changing environment variables on the fly (like marketing messages, etc). It's annoying when deploying via wrangler blows away those values.

    This patch fixes one of those issues. It will not delete any older bindings that are not in wrangler.toml. It still does overwrite existing vars, but at least this gives a way for developers to have some vars that are not blown away on every publish.

  • #1726 0b83504c Thanks @GregBrimble! - fix: Multiworker and static asset dev bug preventing both from being used

    There was previously a collision on the generated filenames which resulted in the generated scripts looping and crashing in Miniflare with error code 7. By renaming one of the generated files, this is avoided.

  • #1718 02f1fe9b Thanks @threepointone! - fix: use config.dev.ip when provided

    Because we'd used a default for 0.0.0.0 for the --ip flag, wrangler dev was overriding the value specified in wrangler.toml under dev.ip. This fix removes the default value (since it's being set when normalising config anyway).

    Fixes #1714

  • #1727 3f9e8f63 Thanks @rozenmd! - fix: refresh token when we detect that the preview session has expired (error code 10049)

    When running wrangler dev, from time to time the preview session token would expire, and the dev server would need to be manually restarted. This fixes this, by refreshing the token when it expires.

    Closes #1446

  • #1730 27ad80ee Thanks @threepointone! - feat: --var name:value and --define name:value

    This enables passing values for [vars] and [define] via the cli. We have a number of usecases where the values to be injected during dev/publish aren't available statically (eg: a version string, some identifier for 3p libraries, etc) and reading those values only from wrangler.toml isn't good ergonomically. So we can now read those values when passed through the CLI.

    Example: add a var during dev: wrangler dev --var xyz:123 will inject the var xyz with string "123"

    (note, only strings allowed for --var)

    substitute a global value: wrangler dev --define XYZ:123 will replace every global identifier XYZ with the value 123.

    The same flags also work with wrangler publish.

    Also, you can use actual environment vars in these commands. e.g.: wrangler dev --var xyz:$XYZ will set xyz to whatever XYZ has been set to in the terminal environment.

  • #1700 d7c23e49 Thanks @penalosa! - Closes #1505 by extending wrangler tail to allow for passing worker routes as well as worker script names.

    For example, if you have a worker example-worker assigned to the route example.com/*, you can retrieve it's logs by running either wrangler tail example.com/* or wrangler tail example-worker—previously only wrangler tail example-worker was supported.

  • #1691 5b2c3ee2 Thanks @cameron-robey! - chore: bump undici and increase minimum node version to 16.13

    • We bump undici to version to 5.9.1 to patch some security vulnerabilities in previous versions
    • This requires bumping the minimum node version to >= 16.8 so we update the minimum to the LTS 16.13

    Fixes #1679 Fixes #1684

2.0.27

Patch Changes

  • #1686 a0a3ffde Thanks @Skye-31! - fix: pages dev correctly escapes regex characters in function paths (fixes #1685)
  • #1628 61e3f00b Thanks @Skye-31! - fix: pages dev process exit when proxied process exits

    Currently, if the process pages dev is proxying exists or crashes, pages dev does not clean it up, and attempts to continue proxying requests to it, resulting in it throwing 502 errors. This fixes that behaviour to make wrangler exit with the code the child_process exits with.

  • #1710 9943e647 Thanks @rozenmd! - fix: pass create-cloudflare the correct path

    wrangler generate was passing create-cloudflare an absolute path, rather than a folder name, resulting in "doubled-up" paths

  • #1663 a9f9094c Thanks @GregBrimble! - feat: Adds --compatibility-date and --compatibility-flags to wrangler pages dev

    Soon to follow in production.

  • #1653 46b73b52 Thanks @WalshyDev! - Fixed R2 create bucket API endpoint. The wrangler r2 bucket create command should work again

2.0.26

Patch Changes

  • #1655 fed80faa Thanks @jahands! - fix: Pages Functions custom _routes.json not being used

    Also cleaned up when we were reading generated _routes.json

  • #1626 f650a0b2 Thanks @JacobMGEvans! - fix: Added pathname to the constructed URL service bindings + wrangler dev ignores pathname when making a request.

    resolves #1598

  • #1622 02bdfde0 Thanks @Skye-31! - fix: Handle static files with multiple extensions, e.g. /a.b should resolve /a.b.html, if /a.b as a file does not exist
  • #1666 662dfdf9 Thanks @jahands! - fix: Consolidate routes that are over the limit to prevent failed deployments

    Rather than failing a deployment because a route is too long (>100 characters), it will now be shortened to the next available level. Eg. /foo/aaaaaaa... -> /foo/*

  • #1670 1b232aaf Thanks @Skye-31! - fix: dev.tsx opens 127.0.0.1 instead of 0.0.0.0 (doesn't work on windows)
  • #1656 37852672 Thanks @jahands! - fix: Warn when Pages Functions have no routes

    Building/publishing pages functions with no valid handlers would result in a Functions script containing no routes, often because the user is using the functions directory for something unrelated. This will no longer add an empty Functions script to the deployment, needlessly consuming Functions quota.

  • #1645 ac397480 Thanks @JacobMGEvans! - feat: download & initialize a wrangler project from dashboard worker

    Added wrangler init --from-dash <worker-name>, which allows initializing a wrangler project from a pre-existing worker in the dashboard.

    Resolves #1624 Discussion: #1623

    Notes: multiplart/form-data parsing is not currently supported in Undici, so a temporary workaround to slice off top and bottom boundaries is in place.

  • #1639 d86382a5 Thanks @matthewdavidrodgers! - fix: support 'exceededMemory' error status in tail

    While the exception for 'Worker exceeded memory limits' gets logged correctly when tailing, the actual status wasn't being counted as an error, and was falling through a switch case to 'unknown'

    This ensures filtering and logging reflects that status correctly

2.0.25

Patch Changes

  • #1609 fa8cb73f Thanks @jahands! - patch: Consolidate redundant routes when generating _routes.generated.json

    Example: ["/foo/:name", "/foo/bar"] => ["/foo/*"]

  • #1595 d4fbd0be Thanks @caass! - Add support for Alarm Events in wrangler tail

    wrangler tail --format pretty now supports receiving events from Durable Object Alarms, and will display the time the alarm was triggered.

    Additionally, any future unknown events will simply print "Unknown Event" instead of crashing the wrangler process.

    Closes #1519

  • #1642 a3e654f8 Thanks @jrf0110! - feat: Add output-routes-path to functions build

    This controls the output path of the _routes.json file. Also moves _routes.json generation to tmp directory during functions build + publish

  • #1606 24327289 Thanks @Skye-31! - chore: make prettier also fix changesets, as it causes checks to fail if they're not formatted
  • #1611 3df0fe04 Thanks @GregBrimble! - feat: Durable Object multi-worker bindings in local dev.

    Building on the recent work for multi-worker Service bindings in local dev, this now adds support for direct Durable Object namespace bindings.

    A parent (calling) Worker will look for child Workers (where the Durable Object has been defined) by matching the script_name configuration option with the child's Service name. For example, if you have a Worker A which defines a Durable Object, MyDurableObject, and Worker B which references A's Durable Object:

    name = "A"
    
    [durable_objects]
    bindings = [
    	{ name = "MY_DO", class_name = "MyDurableObject" }
    ]
    name = "B"
    
    [durable_objects]
    bindings = [
    	{ name = "REFERENCED_DO", class_name = "MyDurableObject", script_name = "A" }
    ]

    MY_DO will work as normal in Worker A. REFERENCED_DO in Worker B will point at A's Durable Object.

    Note: this only works in local mode (wrangler dev --local) at present.

  • #1602 ebd1d631 Thanks @huw! - fix: Pass usageModel to Miniflare in local dev

    This allows Miniflare to dynamically update the external subrequest limit for Unbound workers.

  • #1518 85ab8a93 Thanks @jahands! - feature: Reduce Pages Functions executions for Asset-only requests in _routes.json

    Manually create a _routes.json file in your build output directory to specify routes. This is a set of inclusion/exclusion rules to indicate when to run a Pages project's Functions. Note: This is an experemental feature and is subject to change.

  • #1641 5f5466ab Thanks @GregBrimble! - feat: Add support for using external Durable Objects from wrangler pages dev.

    An external Durable Object can be referenced using npx wrangler pages dev ./public --do MyDO=MyDurableObject@api where the Durable Object is made available on env.MyDO, and is described in a Workers service (name = "api") with the class name MyDurableObject.

    You must have the api Workers service running in as another wrangler dev process elsewhere already in order to reference that object.

  • #1605 9e632cdd Thanks @kimyvgy! - refactor: add --ip argument for wrangler pages dev & defaults IP to 0.0.0.0

    Add new argument --ip for the command wrangler pages dev, defaults to 0.0.0.0. The command wrangler dev is also defaulting to 0.0.0.0 instead of localhost.

  • #1604 9732fafa Thanks @WalshyDev! - Added R2 support for wrangler pages dev. You can add an R2 binding with --r2 <BINDING>.
  • #1608 9f02758f Thanks @jrf0110! - feat: Generate _routes.generated.json for Functions routing

    When using Pages Functions, a _routes.generated.json file is created to inform Pages how to route requests to a project's Functions Worker.

  • #1603 7ae059b3 Thanks @JacobMGEvans! - feat: R2 Object Deletequote Improving the R2 objects management, added the functionality to delete objects in a bucket.

    resolves #1584

2.0.24

Patch Changes

  • #1438 0a9fe918 Thanks @caass! - Initial implementation of wrangler generate

    • wrangler generate and wrangler generate <name> delegate to wrangler init.
    • wrangler generate <name> <template> delegates to create-cloudflare

    Naming behavior is replicated from wrangler 1, and will auto-increment the worker name based on pre-existing directories.

  • #1534 d3ae16cf Thanks @cameron-robey! - feat: publish full url on wrangler publish for workers.dev workers

    When the url is printed out on wrangler publish, the full url is printed out so that it can be accessed from the terminal easily by doing cmd+click. Implemented only for workers.dev workers.

    Resolves #1530

  • #1550 aca9c3e7 Thanks @cameron-robey! - feat: describe current permissions in wrangler whoami

    Often users experience issues due to tokens not having the correct permissions associated with them (often due to new scopes being created for new products). With this, we print out a list of permissions associated with OAuth tokens with the wrangler whoami command to help them debug for OAuth tokens. We cannot access the permissions on an API key, so we direct the user to the location in the dashboard to achieve this. We also cache the scopes of OAuth tokens alongside the access and refresh tokens in the .wrangler/config file to achieve this.

    Currently unable to implement #1371 - instead directs the user to the dashboard. Resolves #1540

  • #1575 5b1f68ee Thanks @JacobMGEvans! - feat: legacy "kv-namespace" not supported In previous Wrangler 1, there was a legacy configuration that was considered a "bug" and removed. Before it was removed, tutorials, templates, blogs, etc... had utlized that configuration property to handle this in Wrangler 2 we will throw a blocking error that tell the user to utilize "kv_namespaces"

    resolves #1421

  • #1404 17f5b576 Thanks @threepointone! - feat: add cache control options to config.assets

    This adds cache control options to config.assets. This is already supported by the backing library (@cloudflare/kv-asset-handler) so we simply pass on the options at its callsite.

    Additionally, this adds a configuration field to serve an app in "single page app" mode, where a root index.html is served for all html/404 requests (also powered by the same library).

  • #1578 cf552192 Thanks @cameron-robey! - feat: source-map function names

    Following on from #1535, using new functionality from esbuild v0.14.50 of generation of names field in generated sourcemaps, we output the original function name in the stack trace.

  • #1503 ebc1aa57 Thanks @threepointone! - feat: zero config multiworker development (local mode)

    Preamble: Typically, a Worker has been the unit of a javascript project on our platform. Any logic that you need, you fit into one worker, ~ 1MB of javascript and bindings. If you wanted to deploy a larger application, you could define different workers on different routes. This is fine for microservice style architectures, but not all projects can be cleaved along the route boundaries; you lose out on sharing code and resources, and can still cross the size limit with heavy dependencies.

    Service bindings provide a novel mechanism for composing multiple workers into a unified architecture. You could deploy shared code into a worker, and make requests to it from another worker. This lets you architect your code along functional boundaries, while also providing some relief to the 1MB size limit.

    I propose a model for developing multiple bound workers in a single project.

    Consider Worker A, at workers/a.js, with a wrangler.toml like so:

    name = 'A'
    
    [[services]]
    binding = 'Bee'
    service = 'B'

    and content like so:

    export default {
    	fetch(req, env) {
    		return env.Bee.fetch(req);
    	}
    };

    Consider Worker B, at workers/b.js, with a wrangler.toml like so:

    name = 'B'

    and content like so:

    export default {
    	fetch(req, env) {
    		return new Response("Hello World");
    	}
    };

    So, a worker A, bound to B, that simply passes on the request to B.

    Local mode:

    Currently, when I run wrangler dev --local on A (or switch from remote to local mode during a dev session), and make requests to A, they'll fail because the bindings don't exist in local mode.

    What I'd like, is to be able to run wrangler dev --local on B as well, and have my dev instance of A make requests to the dev instance of B. When I'm happy with my changes, I'd simply deploy both workers (again, ideally as a batched publish).

    Proposal: A local dev registry for workers.

    • Running wrangler dev on a machine should start up a local service registry (if there isn't one loaded already) as a server on a well known port.
    • Further, it should then "register" itself with the registry with metadata about itself; whether it's running in remote/local mode, the port and ip its dev server is listening on, and any additional configuration (eg: in remote mode, a couple of extra headers have to be added to every request made to the dev session, so we'd add that data into the registry as well.)
    • Every worker that has service bindings configured, should intercept requests to said binding, and instead make a request to the locally running instance of the service. It could rewrite these requests as it pleases.

    (In future PRs, we'll introduce a system for doing the same with remote mode dev, as well as mixed mode. )

    Related to #1182 Fixes #1040

  • #1551 1b54b54f Thanks @threepointone! - internal: middleware for modifying worker behaviour

    This adds an internal mechanism for applying multiple "middleware"/facades on to workers. This lets us add functionality during dev and/or publish, where we can modify requests or env, or other ideas. (See #1466 for actual usecases)

    As part of this, I implemented a simple facade that formats errors in dev. To enable it you need to set an environment variable FORMAT_WRANGLER_ERRORS=true. This isn't a new feature we're shipping with wrangler, it's simply to demonstrate how to write middleware. We'll probably remove it in the future.

  • #1539 95d0f863 Thanks @threepointone! - fix: export durable objects correctly when using --assets

    The facade for static assets doesn't export any exports from the entry point, meaning Durable Objects will fail. This fix adds all exports to the facade's exports.

  • #1564 69713c5c Thanks @JacobMGEvans! - chore: updated wrangler readme providing additional context on configuration, deep link to init and fixing old link to beta docs.
  • #1581 3da184f1 Thanks @threepointone! - fix: apply multiworker dev facade only when required

    This fix makes sure the multiworker dev facade is applied to the input worker only where there are other wrangler dev instances running that are bound to the input worker. We also make sure we don't apply it when we already have a binding (like in remote mode).

  • #1576 f696ebb5 Thanks @petebacondarwin! - feat: add metricsEnabled header to CF API calls when developing or deploying a worker

    This allows us to estimate from API requests what proportion of Wrangler instances have enabled usage tracking, without breaking the agreement not to send data for those who have not opted in.

  • #1525 a692ace3 Thanks @threepointone! - feat: config.first_party_worker + dev facade

    This introduces configuration for marking a worker as a "first party" worker, to be used inside cloudflare to develop workers. It also adds a facade that's applied for first party workers in dev.

  • #1545 b3424e43 Thanks @Martin-Eriksson! - fix: Throw error if both directory and command is specified for pages dev

    The previous behavior was to silently ignore the command argument.

  • #1574 c61006ca Thanks @jahands! - fix: Retry check-missing call to make wrangler pages publish more reliable

    Before uploading files in wrangler pages publish, we make a network call to check what files need to be uploaded. This call could sometimes fail, causing the publish to fail. This change will retry that network call.

  • #1565 2b5a2e9a Thanks @threepointone! - fix: export durable object bindings when using service bindings in dev

    A similar fix to #1539, this exports correctly when using service bindings in dev.

  • #1510 4dadc414 Thanks @matthewdavidrodgers! - refactor: touch up publishing to custom domains

    Couple things cleaned up here:

    Originally the usage of the /domains api (for publishing to custom domains) was a bit clumsy: we would attempt to optimistically publish, but the api would eagerly fail with specific error codes on why it occurred. This made for some weird control flow for retries with override flags, as well as fragile extraction of error messages.

    Now we use the new /domains/changeset api to generate a changeset of actions required to get to a new state of custom domains, which informs us up front of which domains would need to be updated and overridden, and we can pass flags as needed. I do make an extra hop back to the api to lookup what the custom domains requiring updates are already attached to, but given how helpful I imagine that to be, I'm for it.

    I also updated the api used for publishing the domains, from /domains to /domains/records. The latter was added to allow us to add flexibility for things like the /domains/changeset resource, and thus the former is being deprecated

  • #1535 eee7333b Thanks @cameron-robey! - feat: source maps support in wrangler dev remote mode

    Previously stack traces from runtime errors in wrangler dev remote mode, would give unhelpful stack traces from the bundled build that was sent to the server. Here, we use source maps generated as part of bundling to provide better stack traces for errors, referencing the unbundled files.

    Resolves #1509

2.0.23

Patch Changes

  • #1523 e1e2ee5c Thanks @threepointone! - fix: don't log version spam in tests

    Currently in tests, we see a bunch of logspam from yargs about "version" being a reserved word, this patch removes that spam.

  • #1498 fe3fbd95 Thanks @cameron-robey! - feat: change version command to give update information When running version command, we want to display update information if current version is not up to date. Achieved by replacing default output with the wrangler banner. Previous behaviour (just outputting current version) reamins when !isTTY. Version command changed from inbuilt .version() from yargs, to a regular command to allow for asynchronous behaviour.

    Implements #1492

  • #1431 a2e3a6b7 Thanks @Skye-31! - chore: Refactor wrangler pages dev to use Wrangler-proper's own dev server.

    This:

    • fixes some bugs (e.g. not proxying WebSockets correctly),
    • presents a much nicer UI (with the slick keybinding controls),
    • adds features that pages dev was missing (e.g. --local-protocol),
    • and reduces the maintenance burden of wrangler pages dev going forward.
  • #1528 60bdc31a Thanks @threepointone! - fix: prevent local mode restart

    In dev, we inject a patch for fetch() to detect bad usages. This patch is copied into the destination directory before it's used. esbuild appears to have a bug where it thinks a dependency has changed so it restarts once in local mode. The fix here is to copy the file to inject into a separate temporary dir.

    Fixes #1515

  • #1502 be4ffde5 Thanks @threepointone! - polish: recommend using an account id when user details aren't available.

    When using an api token, sometimes the call to get a user's membership details fails with a 9109 error. In this scenario, a workaround to skip the membership check is to provide an account_id in wrangler.toml or via CLOUDFLARE_ACCOUNT_ID. This bit of polish adds this helpful tip into the error message.

  • #1479 862f14e5 Thanks @threepointone! - fix: read process.env.NODE_ENV correctly when building worker

    We replace process.env.NODE_ENV in workers with the value of the environment variable. However, we have a bug where when we make an actual build of wrangler (which has NODE_ENV set as "production"), we were also replacing the expression where we'd replace it in a worker. The result was that all workers would have process.env.NODE_ENV set to production, no matter what the user had set. The fix here is to use a "dynamic" value for the expression so that our build system doesn't replace it.

    Fixes #1477

  • #1471 0953af8e Thanks @JacobMGEvans! - ci: implement CodeCov Integration CodeCov is used for analyzing code and tests to improve stability and maintainability. It does this by utilizing static code analysis and testing output to provide insights into things that need improving, security concerns, missing test coverage of critical code, and more, which can be missed even after exhaustive human review.
  • #1516 e178d6fb Thanks @threepointone! - polish: don't log an error message if wrangler dev startup is interrupted.

    When we quit wrangler dev, any inflight requests are cancelled. Any error handlers for those requests are ignored if the request was cancelled purposely. The check for this was missing for the prewarm request for a dev session, and this patch adds it so it dorsn't get logged to the terminal.

  • #1496 8eb91142 Thanks @threepointone! - fix: add fetch() dev helper correctly for pnp style package managers

    In #992, we added a dev-only helper that would warn when using fetch() in a manner that wouldn't work as expected (because of a bug we currently have in the runtime). We did this by injecting a file that would override usages of fetch(). When using pnp style package managers like yarn, this file can't be resolved correctly. So to fix that, we extract it into the temporary destination directory that we use to build the worker (much like a similar fix we did in #1154)

    Reported at #1320 (comment)

  • #1529 1a0ac8d0 Thanks @GregBrimble! - feat: Adds the --experimental-enable-local-persistence option to wrangler pages dev

    Previously, this was implicitly enabled and stored things in a .mf directory. Now we move to be in line with what wrangler dev does, defaults disabled, and stores in a wrangler-local-state directory.

  • #1514 9271680d Thanks @threepointone! - feat: add config.inspector_port

    This adds a configuration option for the inspector port used by the debugger in wrangler dev. This also includes a bug fix where we weren't passing on this configuration to local mode.

2.0.22

Patch Changes

  • #1482 9eb28ec Thanks @petebacondarwin! - feat: support controlling metrics gathering via WRANGLER_SEND_METRICS environment variable

    Setting the WRANGLER_SEND_METRICS environment variable will override any other metrics controls, such as the send_metrics property in wrangler.toml and cached user preference.

2.0.21

Patch Changes

  • #1474 f602df7 Thanks @threepointone! - fix: enable debugger in local mode

    During a refactor, we missed enabling the inspector by default in local mode. We also broke the logic that detects the inspector url exposed by the local server. This patch passes the argument correctly, fixes the detection logic. Further, it also lets you disable the inspector altogether with --inspect false, if required (for both remote and local mode).

    Fixes #1436

  • #1470 01f49f1 Thanks @petebacondarwin! - fix: ensure that metrics user interactions do not break other UI

    The new metrics usage capture may interact with the user if they have not yet set their metrics permission. Sending metrics was being done concurrently with other commands, so there was a chance that the metrics UI broke the other command's UI. Now we ensure that metrics UI will happen synchronously.

2.0.20

Patch Changes

  • #1464 0059d84 Thanks @petebacondarwin! - ci: ensure that the SPARROW_SOURCE_KEY is included in release builds

    Previously, we were including the key in the "build" step of the release job. But this is only there to check that the build doesn't fail. The build is re-run inside the publish step, which is part of the "changeset" step. Now, we include the key in the "changeset" step to ensure it is there in the build that is published.

2.0.19

Patch Changes

  • #1410 52fb634 Thanks @petebacondarwin! - feat: add opt-in usage metrics gathering

    This change adds support in Wrangler for sending usage metrics to Cloudflare. This is an opt-in only feature. We will ask the user for permission only once per device. The user must grant permission, on a per device basis, before we send usage metrics to Cloudflare. The permission can also be overridden on a per project basis by setting send_metrics = false in the wrangler.toml. If Wrangler is running in non-interactive mode (such as in a CI job) and the user has not already given permission we will assume that we cannot send usage metrics.

    The aim of this feature is to help us learn what and how features of Wrangler (and also the Cloudflare dashboard) are being used in order to improve the developer experience.

  • #1463 a7ae733 Thanks @threepointone! - fix: ensure that a helpful error message is shown when on unsupported versions of node.js

    Our entrypoint for wrangler (bin/wrangler.js) needs to run in older versions of node and log a message to the user that they need to upgrade their version of node. Sometimes we use syntax in this entrypoint that doesn't run in older versions of node. crashing the script and failing to log the message. This fix adds a test in CI to make sure we don't regress on that behaviour (as well as fixing the current newer syntax usage)

    Fixes #1443

  • #1459 4e425c6 Thanks @sidharthachatterjee! - fix: wrangler pages publish now more reliably retries an upload in case of a failure

    When wrangler pages publish is run, we make calls to an upload endpoint which could be rate limited and therefore fail. We currently retry those calls after a linear backoff. This change makes that backoff exponential which should reduce the likelihood of subsequent calls being rate limited.

2.0.18

Patch Changes

  • #1451 62649097 Thanks @WalshyDev! - Fixed an issue where Pages upload would OOM. This was caused by us loading all the file content into memory instead of only when required.
  • #1375 e9e98721 Thanks @JacobMGEvans! - polish: Compliance with the XDG Base Directory Specification Wrangler was creating a config file in the home directory of the operating system ~/.wrangler. The XDG path spec is a standard for storing files, these changes include XDG pathing compliance for .wrangler/* location and backwards compatibility with previous ~/.wrangler locations.

    resolves #1053

  • #1449 ee6c421b Thanks @alankemp! - Output additional information about uploaded scripts at WRANGLER_LOG=log level

2.0.17

Patch Changes

  • #1389 eab9542 Thanks @caass! - Remove delegation message when global wrangler delegates to a local installation

    A message used for debugging purposes was accidentally left in, and confused some folks. Now it'll only appear when WRANGLER_LOG is set to debug.

  • #1406 0f35556 Thanks @rozenmd! - fix: use fork to let wrangler know miniflare is ready

    This PR replaces our use of spawn in favour of fork to spawn miniflare in wrangler's dev function. This lets miniflare let wrangler know when we're ready to send requests.

    Closes #1408

  • #999 238b546 Thanks @caass! - Include devtools in wrangler monorepo

    Previously, wrangler relied on @threepointone's built-devtools. Now, these devtools are included in the wrangler repository.

  • #1424 8cf0008 Thanks @caass! - fix: Check config.assets when deciding whether to include a default entry point.

    An entry point isn't mandatory when using --assets, and we can use a default worker when doing so. This fix enables that same behaviour when config.assets is configured.

  • #1448 0d462c0 Thanks @threepointone! - polish: set checkjs: false and jsx: "react" in newly created projects

    When we create a new project, it's annoying having to set jsx: "react" when that's the overwhelmingly default choice, our compiler is setup to do it automatically, and the tsc error message isn't helpful. So we set jsx: "react" in the generated tsconfig.

    Setting checkJs: true is also annoying because it's not a common choice. So we set checkJs: false in the generated tsconfig.

  • #1450 172310d Thanks @threepointone! - polish: tweak static assets facade to log only real errors

    This prevents the abundance of NotFoundErrors being unnecessaryily logged.

  • #1415 f3a8452 Thanks @caass! - Emit type declarations for wrangler

    This is a first go-round of emitting type declarations alongside the bundled JS output, which should make it easier to use wrangler as a library.

  • #1433 1c1214f Thanks @threepointone! - polish: adds an actionable message when a worker name isn't provided to tail/secret

    Just a better error message when a Worker name isn't available for wrangler secret or wrangler tail.

    Closes #1380

  • #1427 3fa5041 Thanks @caass! - Check npm_config_user_agent to guess a user's package manager

    The environment variable npm_config_user_agent can be used to guess the package manager that was used to execute wrangler. It's imperfect (just like regular user agent sniffing!) but the package managers we support all set this property:

2.0.16

Patch Changes

  • #992 ee6b413 Thanks @petebacondarwin! - fix: add warning to fetch() calls that will change the requested port

    In Workers published to the Edge (rather than previews) there is a bug where a custom port on a downstream fetch request is ignored, defaulting to the standard port. For example, https://my.example.com:668 will actually send the request to https://my.example.com:443.

    This does not happen when using wrangler dev (both in remote and local mode), but to ensure that developers are aware of it this change displays a runtime warning in the console when the bug is hit.

    Closes #1320

  • #1378 2579257 Thanks @rozenmd! - chore: fully deprecate the preview command

    Before, we would warn folks that preview was deprecated in favour of dev, but then ran dev on their behalf. To avoid maintaining effectively two versions of the dev command, we're now just telling folks to run dev.

  • #1213 1bab3f6 Thanks @threepointone! - fix: pass routes to dev session

    We can pass routes when creating a dev session. The effect of this is when you visit a path that doesn't match the given routes, then it instead does a fetch from the deployed worker on that path (if any). We were previously passing */*, i.e, matching all routes in dev; this fix now passes configured routes instead.

  • #1374 215c4f0 Thanks @threepointone! - feat: commands to manage worker namespaces

    This adds commands to create, delete, list, and get info for "worker namespaces" (name to be bikeshed-ed). This is based on work by @aaronlisman in #1310.

  • #1403 9c6c3fb Thanks @threepointone! - feat: config.no_bundle as a configuration option to prevent bundling

    As a configuration parallel to --no-bundle (introduced in #1300 as --no-build, renamed in #1399 to --no-bundle), this introduces a configuration field no_bundle to prevent bundling of the worker before it's published. It's inheritable, which means it can be defined inside environments as well.

  • #1355 61c31a9 Thanks @williamhorning! - fix: Fallback to non-interactive mode on error

    If the terminal isn't a TTY, fallback to non-interactive mode instead of throwing an error. This makes it so users of Bash on Windows can pipe to wrangler without an error being thrown.

    resolves #1303

  • #1337 1d778ae Thanks @JacobMGEvans! - polish: bundle reporter was not printing during publish errors

    The reporter is now called before the publish API call, printing every time.

    resolves #1328

  • #1393 b36ef43 Thanks @threepointone! - chore: enable node's experimental fetch flag

    We'd previously had some funny behaviour with undici clashing with node's own fetch supporting classes, and had turned off node's fetch implementation. Recent updates to undici appear to have fixed the issue, so let's turn it back on.

    Closes #834

  • #1335 49cf17e Thanks @JacobMGEvans! - feat: resolve --assets cli arg relative to current working directory

    Before we were resolving the Asset directory relative to the location of wrangler.toml at all times. Now the --assets cli arg is resolved relative to current working directory.

    resolves #1333

  • #1350 dee034b Thanks @rozenmd! - feat: export an (unstable) function that folks can use in their own scripts to invoke wrangler's dev CLI

    Closes #1350

  • #1401 6732d95 Thanks @threepointone! - fix: log pubsub beta usage warnings consistently

    This fix makes sure the pubsub beta warnings are logged consistently, once per help menu, through the hierarchy of its command tree.

    Fixes #1370

  • #1386 4112001 Thanks @rozenmd! - feat: implement fetch for wrangler's unstable_dev API, and write our first integration test.

    Prior to this PR, users of unstable_dev had to provide their own fetcher, and guess the address and port that the wrangler dev server was using.

    With this implementation, it's now possible to test wrangler, using just wrangler (and a test framework):

    describe("worker", async () => {
      const worker = await wrangler.unstable_dev("src/index.ts");
    
      const resp = await worker.fetch();
    
      expect(resp).not.toBe(undefined);
      if (resp) {
        const text = await resp.text();
        expect(text).toMatchInlineSnapshot(`"Hello World!"`);
      }
    
      worker.stop();
    }

    Closes #1383 Closes #1384 Closes #1385

  • #1399 1ab71a7 Thanks @threepointone! - fix: rename --no-build to --no-bundle

    This fix renames the --no-build cli arg to --no-bundle. no-build wasn't a great name because it would imply that we don't run custom builds specified under [build] which isn't true. So we rename closer to what wrangler actually does, which is bundling the input. This also makes it clearer that it's a single file upload.

  • #1348 eb948b0 Thanks @threepointone! - polish: add an experimental warning if --assets is used

    We already have a warning when config.assets is used, this adds it for the cli argument as well.

  • #1326 12f2703 Thanks @timabb031! - fix: show console.error/console.warn logs when using dev --local.

    Prior to this change, logging with console.error/console.warn in a Worker wouldn't output anything to the console when running in local mode. This was happening because stderr data event handler was being removed after the Debugger listening... string was found.

    This change updates the stderr data event handler to forward on all events to process.stderr.

    Closes #1324

  • #1395 88f2702 Thanks @threepointone! - feat: cache account id selection

    This adds caching for account id fetch/selection for all wrangler commands.

    Currently, if we have an api/oauth token, but haven't provided an account id, we fetch account information from cloudflare. If a user has just one account id, we automatically choose that. If there are more than one, then we show a dropdown and ask the user to pick one. This is convenient, and lets the user not have to specify their account id when starting a project.

    However, if does make startup slow, since it has to do that fetch every time. It's also annoying for folks with multiple account ids because they have to pick their account id every time.

    So we now cache the account details into node_modules/.cache/wrangler (much like pages already does with account id and project name).

    This patch also refactors config-cache.ts; it only caches if there's a node_modules folder, and it looks for the closest node_modules folder (and not directly in cwd). I also added tests for when a node_modules folder isn't available. It also trims the message that we log to terminal.

    Closes #300

  • #1391 ea7ee45 Thanks @threepointone! - fix: create a single session during remote dev

    Previously, we would be creating a fresh session for every script change during remote dev. While this worked, it makes iterating slower, and unnecessarily discards state. This fix makes it so we create only a single session for remote dev, and reuses that session on every script change. This also means we can use a single script id for every worker in a session (when a name isn't already given). Further, we also make the prewarming call of the preview space be non-blocking.

    Fixes #1191

  • #1365 b9f7200 Thanks @threepointone! - fix: normalise account_id = '' to account_id: undefined

    In older templates, (i.e made for wrangler 1.x), account_id ='' is considered as a valid input, but then ignored. With wrangler 2, when running wrangler dev, we log an error, but it fixes itself after we get an account id. Much like #1329, the fix here is to normalise that value when we see it, and replace it with undefined while logging a warning.

    This fix also tweaks the messaging for a blank route value to suggest some user action.

  • #1300 dcffc93 Thanks @threepointone! - feat: publish --no-build

    This adds a --no-build flag to wrangler publish. We've had a bunch of people asking to be able to upload a worker directly, without any modifications. While there are tradeoffs to this approach (any linked modules etc won't work), we understand that people who need this functionality are aware of it (and the usecases that have presented themselves all seem to match this).

  • #1392 ff2e7cb Thanks @threepointone! - fix: keep site upload batches under 98 mb

    The maximum request size for a batch upload is 100 MB. We were previously calculating the upload key value to be under 100 MiB. Further, with a few bytes here and there, the size of the request can exceed 100 MiB. So this fix calculate using MB instead of MiB, but also brings down our own limit to 98 MB so there's some wiggle room for uploads.

    Fixes #1367

  • #1377 a6f1cee Thanks @threepointone! - feat: bind a worker with [worker_namespaces]

    This feature les you bind a worker to a dynamic dispatch namespaces, which may have other workers bound inside it. (See https://blog.cloudflare.com/workers-for-platforms/). Inside your wrangler.toml, you would add

    [[worker_namespaces]]
    binding = 'dispatcher' # available as env.dispatcher in your worker
    namespace = 'namespace-name' # the name of the namespace being bound

    Based on work by @aaronlisman in #1310

  • #1297 40036e2 Thanks @threepointone! - feat: implement config.define

    This implements config.define. This lets the user define a map of keys to strings that will be substituted in the worker's source. This is particularly useful when combined with environments. A common usecase is for values that are sent along with metrics events; environment name, public keys, version numbers, etc. It's also sometimes a workaround for the usability of module env vars, which otherwise have to be threaded through request function stacks.

  • #1351 c770167 Thanks @geelen! - feat: add support for CLOUDFLARE_API_KEY + CLOUDFLARE_EMAIL to authorise

    This adds support for using the CLOUDFLARE_API_KEY + CLOUDFLARE_EMAIL env vars for authorising a user. This also adds support for CF_API_KEY + CF_EMAIL from wrangler 1, with a deprecation warning.

  • #1352 4e03036 Thanks @JacobMGEvans! - bugfix: Allow route setting to be "" Previously Wrangler1 behavior had allowed for route = "". To keep parity it will be possible to set route = "" in the config file and represent not setting a route, while providing a warning.

    resolves #1329

  • 4ad084e Thanks @sbquinlan! - feature By @sbquinlan: Set "upstream" miniflare option when running dev in local mode

2.0.15

Patch Changes

  • #1272 f7d362e Thanks @JacobMGEvans! - feat: print bundle size during publish and dev

    This logs the complete bundle size of the Worker (as well as when compressed) during publish and dev.

    Via #405 (comment))

  • #1287 2072e27 Thanks @f5io! - fix: kv:key put/get binary file

    As raised in #1254, it was discovered that binary uploads were being mangled by wrangler 2, whereas they worked in wrangler 1. This is because they were read into a string by providing an explicit encoding of utf-8. This fix reads provided files into a node Buffer that is then passed directly to the request.

    Subsequently #1273 was raised in relation to a similar issue with gets from wrangler 2. This was happening due to the downloaded file being converted to utf-8 encoding as it was pushed through console.log. By leveraging process.stdout.write we can push the fetched ArrayBuffer to std out directly without inferring any specific encoding value.

  • #1265 e322475 Thanks @petebacondarwin! - fix: support all git versions for wrangler init

    If git does not support the --initial-branch argument then just fallback to the default initial branch name.

    We tried to be more clever about this but there are two many weird corner cases with different git versions on different architectures. Now we do our best, with recent versions of git, to ensure that the branch is called main but otherwise just make sure we don't crash.

    Fixes #1228

  • #1311 374655d Thanks @JacobMGEvans! - feat: add --text flag to decode kv:key get response values as utf8 strings

    Previously, all kv values were being rendered directly as bytes to the stdout, which makes sense if the value is a binary blob that you are going to pipe into a file, but doesn't make sense if the value is a simple string.

    resolves #1306

  • #1327 4880d54 Thanks @JacobMGEvans! - feat: resolve --site cli arg relative to current working directory

    Before we were resolving the Site directory relative to the location of wrangler.toml at all times. Now the --site cli arg is resolved relative to current working directory.

    resolves #1243

  • #1270 7ed5e1a Thanks @caass! - Delegate to a local install of wrangler if one exists.

    Users will frequently install wrangler globally to run commands like wrangler init, but we also recommend pinning a specific version of wrangler in a project's package.json. Now, when a user invokes a global install of wrangler, we'll check to see if they also have a local installation. If they do, we'll delegate to that version.

  • #1289 0d6098c Thanks @threepointone! - feat: entry point is not mandatory if --assets is passed

    Since we use a facade worker with --assets, an entry point is not strictly necessary. This makes a common usecase of "deploy a bunch of static assets" extremely easy to start, as a one liner npx wrangler dev --assets path/to/folder (and same with publish).

  • #1293 ee57d77 Thanks @petebacondarwin! - fix: do not crash in wrangler dev if user has multiple accounts

    When a user has multiple accounts we show a prompt to allow the user to select which they should use. This was broken in wrangler dev as we were trying to start a new ink.js app (to show the prompt) from inside a running ink.js app (the UI for wrangler dev).

    This fix refactors the ChooseAccount component so that it can be used directly within another component.

    Fixes #1258

  • #1299 0fd0c30 Thanks @threepointone! - polish: include a copy-pastable message when trying to publish without a compatibility date
  • #1269 fea87cf Thanks @petebacondarwin! - fix: do not consider ancestor files when initializing a project with a specified name

    When initializing a new project (via wrangler init) we attempt to reuse files in the current directory, or in an ancestor directory. In particular we look up the directory tree for package.json and tsconfig.json and use those instead of creating new ones.

    Now we only do this if you do not specify a name for the new Worker. If you do specify a name, we now only consider files in the directory where the Worker will be initialized.

    Fixes #859

  • #1321 8e2b92f Thanks @GregBrimble! - fix: Correctly resolve directories for 'wrangler pages publish'

    Previously, attempting to publish a nested directory or the current directory would result in parsing mangled paths which broke deployments. This has now been fixed.

  • #1293 ee57d77 Thanks @petebacondarwin! - fix: do not hang waiting for account choice when in non-interactive mode

    The previous tests for non-interactive only checked the stdin.isTTY, but you can have scenarios where the stdin is interactive but the stdout is not. For example when writing the output of a kv:key get command to a file.

    We now check that both stdin and stdout are interactive before trying to interact with the user.

  • #1294 f6836b0 Thanks @threepointone! - fix: serve --assets in dev + local mode

    A quick bugfix to make sure --assets/config.assets gets served correctly in dev --local.

  • #1237 e1b8ac4 Thanks @threepointone! - feat: --assets / config.assets to serve a folder of static assets

    This adds support for defining assets in wrangler.toml. You can configure it with a string path, or a {bucket, include, exclude} object (much like [site]). This also renames the --experimental-public arg as --assets.

    Via #1162

2.0.14

Patch Changes

  • a4ba42a Thanks @threepointone! - Revert "Take 2 at moving .npmrc to the root of the repository (#1281)"

  • #1267 c667398 Thanks @rozenmd! - fix: let folks know the URL we're opening during login

    Closes #1259

2.0.12

Patch Changes

  • #1229 e273e09 Thanks @timabb031! - fix: parsing of node inspector url

    This fixes the parsing of the url returned by Node Inspector via stderr which could be received partially in multiple chunks or in a single chunk.

    Closes #1226

  • #1255 2d806dc Thanks @f5io! - fix: kv:key put binary file upload

    As raised in #1254, it was discovered that binary uploads were being mangled by wrangler 2, whereas they worked in wrangler 1. This is because they were read into a string by providing an explicit encoding of utf-8. This fix reads provided files into a node Buffer that is then passed directly to the request.

  • #1248 db8a0bb Thanks @threepointone! - fix: instruct api to exclude script content on worker upload

    When we upload a script bundle, we get the actual content of the script back in the response. Sometimes that script can be large (depending on whether the upload was large), and currently it may even be a badly escaped string. We can pass a queryparam excludeScript that, as it implies, exclude the script content in the response. This fix does that.

    Fixes #1222

  • #1250 e3278fa Thanks @rozenmd! - fix: pass localProtocol to miniflare for https server

    Closes #1247

  • #1253 eee5c78 Thanks @threepointone! - fix: resolve asset handler for --experimental-path

    In #1241, we removed the vendored version of @cloudflare/kv-asset-handler, as well as the build configuration that would point to the vendored version when compiling a worker using --experimental-public. However, wrangler can be used where it's not installed in the package.json for the worker, or even when there's no package.json at all (like when wrangler is installed globally, or used with npx). In this situation, if the user doesn't have @cloudflare/kv-asset-handler installed, then building the worker will fail. We don't want to make the user install this themselves, so instead we point to a barrel import for the library in the facade for the worker.

  • #1234 3e94bc6 Thanks @threepointone! - feat: support --experimental-public in local mode

    --experimental-public is an abstraction over Workers Sites, and we can leverage miniflare's inbuilt support for Sites to serve assets in local mode.

  • #1236 891d128 Thanks @threepointone! - fix: generate site assets manifest relative to site.bucket

    We had a bug where we were generating asset manifest keys incorrectly if we ran wrangler from a different path to wrangler.toml. This fixes the generation of said keys, and adds a test for it.

    Fixes #1235

  • #1216 4eb70f9 Thanks @JacobMGEvans! - feat: reload server on configuration changes, the values passed into the server during restart will be bindings

    resolves #439

  • #1231 5206c24 Thanks @threepointone! - feat: build.watch_dir can be an array of paths

    In projects where:

    • all the source code isn't in one folder (like a monorepo, or even where the worker has non-standard imports across folders),
    • we use a custom build, so it's hard to statically determine folders to watch for changes

    ...we'd like to be able to specify multiple paths for custom builds, (the config build.watch_dir config). This patch enables such behaviour. It now accepts a single path as before, or optionally an array of strings/paths.

    Fixes #1095

  • #1241 471cfef Thanks @threepointone! - use @cloudflare/kv-asset-handler for --experimental-public

    We'd previously vendored in @cloudflare/kv-asset-handler and mime for --experimental-public. We've since updated @cloudflare/kv-asset-handler to support module workers correctly, and don't need the vendored versions anymore. This patch uses the lib as a dependency, and deletes the vendor folder.

2.0.11

Patch Changes

  • #1239 df55709 Thanks @threepointone! - polish: don't include folder name in Sites kv asset keys

    As reported in #1189, we're including the name of the folder in the keys of the KV store that stores the assets. This doesn't match v1 behaviour. It makes sense not to include these since, we should be able to move around the folder and not have to reupload the entire folder again.

    Fixes #1189

  • #1210 785d418 Thanks @GregBrimble! - feat: Upload the delta for wrangler pages publish

    We now keep track of the files that make up each deployment and intelligently only upload the files that we haven't seen. This means that similar subsequent deployments should only need to upload a minority of files and this will hopefully make uploads even faster.

  • #1218 f8a21ed Thanks @threepointone! - fix: warn on unexpected fields on config.triggers

    This adds a warning when we find unexpected fields on the triggers config (and any future fields that use the isObjectWith() validation helper)

2.0.9

Patch Changes

  • #1192 bafa5ac Thanks @threepointone! - fix: use worker name as a script ID when generating a preview session

    When generating a preview session on the edge with wrangler dev, for a zoned worker we were using a random id as the script ID. This would make the backend not associate the dev session with any resources that were otherwise assigned to the script (specifically for secrets, but other stuff as well) The fix is simply to use the worker name (when available) as the script ID.

    Fixes #1003 Fixes #1172

  • #1212 101342e Thanks @petebacondarwin! - fix: do not crash when not logged in and switching to remote dev mode

    Previously, if you are not logged in when running wrangler dev it will only try to log you in if you start in "remote" mode. In "local" mode there is no need to be logged in, so it doesn't bother to try to login, and then will crash if you switch to "remote" mode interactively.

    The problem was that we were only attempting to login once before creating the <Remote> component. Now this logic has been moved into a useEffect() inside <Remote> so that it will be run whether starting in "remote" or transitioning to "remote" from "local".

    The fact that the check is no longer done before creating the components is proven by removing the mockAccountId() and mockApiToken() calls from the dev.test.ts files.

    Fixes #18

  • #1188 b44cc26 Thanks @petebacondarwin! - fix: fallback on old zone-based API when account-based route API fails

    While we wait for changes to the CF API to support API tokens that do not have "All Zone" permissions, this change provides a workaround for most scenarios.

    If the bulk-route request fails with an authorization error, then we fallback to the Wrangler 1 approach, which sends individual route updates via a zone-based endpoint.

    Fixes #651

  • #1209 2d42882 Thanks @petebacondarwin! - fix: ensure wrangler init works with older versions of git

    Rather than using the recently added --initial-branch option, we now just renamed the initial branch using git branch -m main.

    Fixes #1168

2.0.8

Patch Changes

  • #1184 4a10176 Thanks @timabb031! - polish: add cron trigger to wrangler.toml when new Scheduled Worker is created

    When wrangler init is used to create a new Scheduled Worker a cron trigger (1 * * * *) will be added to wrangler.toml, but only if wrangler.toml is being created during init. If wrangler.toml exists prior to running wrangler init then wrangler.toml will remain unchanged even if the user selects the "Scheduled Handler" option. This is as per existing tests in init.test.ts that ensure wrangler.toml is never overwritten after agreeing to prompts. That can change if it needs to.

  • #1163 52c0bf0 Thanks @threepointone! - fix: only log available bindings once in dev

    Because we were calling printBindings during the render phase of <Dev/>, we were logging the bindings multiple times (render can be called multiple times, and the interaction of Ink's stdout output intermingled with console is a bit weird). We could have put it into an effect, but I think a better solution here is to simply log it before we even start rendering <Dev/> (so we could see the bindings even if Dev fails to load, for example).

    This also adds a fix that masks any overriden values so that we don't accidentally log potential secrets into the terminal.

  • #1154 5d6de58 Thanks @threepointone! - fix: extract Cloudflare_CA.pem to temp dir before using it

    With package managers like yarn, the cloudflare cert won't be available on the filesystem as expected (since the module is inside a .zip file). This fix instead extracts the file out of the module, copies it to a temporary directory, and directs node to use that as the cert instead, preventing warnings like #1136.

    Fixes #1136

  • #1166 08e3a49 Thanks @threepointone! - fix: warn on unexpected fields on migrations

    This adds a warning for unexpected fields on [migrations] config, reported in #1165. It also adds a test for incorrect renamed_classes in a migration.

  • #1122 c2d2f44 Thanks @petebacondarwin! - fix: display chained errors from the CF API

    For example if you have an invalid CF_API_TOKEN and try running wrangler whoami you now get the additional 6111 error information:

    ✘ [ERROR] A request to the Cloudflare API (/user) failed.
    
      Invalid request headers [code: 6003]
      - Invalid format for Authorization header [code: 6111]
    
  • #1152 b817136 Thanks @threepointone! - polish: Give a copy-paste config when [migrations] are missing

    This gives a slightly better message when migrations are missing for declared durable objcts. Specifically, it gives a copy-pastable section to add to wrangler.toml, and doesn't show the warning at all for invalid class names anymore.

    Partially makes #1076 better.

  • #1141 a8c509a Thanks @rozenmd! - fix: rename "publish" package.json script to "deploy"

    Renaming the default "publish" package.json script to "deploy" to avoid confusion with npm's publish command.

    Closes #1121

  • #1175 e978986 Thanks @timabb031! - feature: allow user to select a handler template with wrangler init

    This allows the user to choose which template they'd like to use when they are prompted to create a new worker. The options are currently "None"/"Fetch Handler"/"Scheduled Handler". Support for new handler types such as email can be added easily in future.

2.0.7

Patch Changes

  • #1110 515a52f Thanks @rozenmd! - fix: print instructions even if installPackages fails to fetch npm packages
  • #1051 7e2e97b Thanks @rozenmd! - feat: add support for using wrangler behind a proxy

    Configures the undici library (the library wrangler uses for fetch) to send all requests via a proxy selected from the first non-empty environment variable from "https_proxy", "HTTPS_PROXY", "http_proxy" and "HTTP_PROXY".

  • #1089 de59ee7 Thanks @rozenmd! - fix: batch package manager installs so folks only have to wait once

    When running wrangler init, we install packages as folks confirm their options. This disrupts the "flow", particularly on slower internet connections.

    To avoid this disruption, we now only install packages once we're done asking questions.

    Closes #1036

  • #1073 6bb2564 Thanks @caass! - Add a better message when a user doesn't have a Chromium-based browser.

    Certain functionality we use in wrangler depends on a Chromium-based browser. Previously, we would throw a somewhat arcane error that was hard (or impossible) to understand without knowing what we needed. While ideally all of our functionality would work across all major browsers, as a stopgap measure we can at least inform the user what the actual issue is.

    Additionally, add support for Brave as a Chromium-based browser.

  • #1079 fb0dec4 Thanks @caass! - Print the bindings a worker has access to during dev and publish

    It can be helpful for a user to know exactly what resources a worker will have access to and where they can access them, so we now log the bindings available to a worker during wrangler dev and wrangler publish.

  • #1097 c73a3c4 Thanks @petebacondarwin! - fix: ensure all line endings are normalized before parsing as TOML

    Only the last line-ending was being normalized not all of them.

    Fixes #1094

  • #1058 1a59efe Thanks @threepointone! - refactor: detect missing [migrations] during config validation

    This does a small refactor -

    • During publish, we were checking whether [migrations] were defined in the presence of [durable_objects], and warning if not. This moves it into the config validation step, which means it'll check for all commands (but notably dev)
    • It moves the code to determine current migration tag/migrations to upload into a helper. We'll be reusing this soon when we upload migrations to dev.
  • #1090 85fbfe8 Thanks @petebacondarwin! - refactor: remove use of any

    This "quick-win" refactors some of the code to avoid the use of any where possible. Using any can cause type-checking to be disabled across the code in unexpectedly wide-impact ways.

    There is one other use of any not touched here because it is fixed by #1088 separately.

  • #1088 d63d790 Thanks @petebacondarwin! - fix: ensure that the proxy server shuts down to prevent wrangler dev from hanging

    When running wrangler dev we create a proxy to the actual remote Worker. After creating a connection to this proxy by a browser request the proxy did not shutdown. Now we use a HttpTerminator helper library to force the proxy to close open connections and shutdown correctly.

    Fixes #958

  • #1099 175737f Thanks @petebacondarwin! - fix: delegate wrangler build to wrangler publish

    Since wrangler publish --dry-run --outdir=dist is basically the same result as what Wrangler 1 did with wrangler build let's run that for the user if they try to run wrangler build.

  • #1081 8070763 Thanks @rozenmd! - fix: friendlier error for when a subdomain hasn't been configured in dev mode
  • #1123 15e5c12 Thanks @timabb031! - chore: updated new worker ts template with env/ctx parameters and added Env interface
  • #1080 4a09c1b Thanks @caass! - Improve messaging when bulk deleting or uploading KV Pairs

    Closes #555

  • #1000 5a8e8d5 Thanks @JacobMGEvans! - pages dev <dir> & wrangler pages functions build will have a --node-compat flag powered by @esbuild-plugins/node-globals-polyfill (which in itself is powered by rollup-plugin-node-polyfills). The only difference in pages will be it does not check the wrangler.toml so the node_compat = truewill not enable it for wrangler pages functionality.

    resolves #890

  • #1028 b7a9ce6 Thanks @GregBrimble! - feat: Use new bulk upload API for 'wrangler pages publish'

    This raises the file limit back up to 20k for a deployment.

2.0.6

Patch Changes

  • #1018 cd2c42f Thanks @threepointone! - fix: strip leading */*. from routes when deducing a host for dev

    When given routes, we use the host name from the route to deduce a zone id to pass along with the host to set with dev session. Route patterns can include leading */*., which we don't account for when deducing said zone id, resulting in subtle errors for the session. This fix strips those leading characters as appropriate.

    Fixes #1002

  • #1052 233eef2 Thanks @petebacondarwin! - fix: display the correct help information when a subcommand is invalid

    Previously, when an invalid subcommand was used, such as wrangler r2 foo, the help that was displayed showed the top-level commands prefixed by the command in used. E.g.

    wrangler r2 init [name]       📥 Create a wrangler.toml configuration file
    wrangler r2 dev [script]      👂 Start a local server for developing your worker
    wrangler r2 publish [script]  🆙 Publish your Worker to Cloudflare.
    ...
    

    Now the correct command help is displayed:

    $ wrangler r2 foo
    
    ✘ [ERROR] Unknown argument: foo
    

wrangler r2

📦 Interact with an R2 store

Commands: wrangler r2 bucket Manage R2 buckets

Flags: -c, --config Path to .toml configuration file [string] -h, --help Show help [boolean] -v, --version Show version number [boolean]


Fixes #871

* [#906](https://github.com/cloudflare/wrangler2/pull/906) [`3279f10`](https://github.com/cloudflare/wrangler2/commit/3279f103fb3b1c27addb4c69c30ad970ab0d5f77) Thanks [@threepointone](https://github.com/threepointone)! - feat: implement support for service bindings

This adds experimental support for service bindings, aka worker-to-worker bindings. It's lets you "call" a worker from another worker, without incurring any network cost, and (ideally) with much less latency. To use it, define a `[services]` field in `wrangler.toml`, which is a map of bindings to worker names (and environment). Let's say you already have a worker named "my-worker" deployed. In another worker's configuration, you can create a service binding to it like so:

```toml
[[services]]
binding = "MYWORKER"
service = "my-worker"
environment = "production" # optional, defaults to the worker's `default_environment` for now

And in your worker, you can call it like so:

export default {
	fetch(req, env, ctx) {
		return env.MYWORKER.fetch(new Request("http://domain/some-path"));
	}
};

Fixes #1026

  • #1045 8eeef9a Thanks @jrf0110! - fix: Incorrect extension extraction from file paths.

    Our extension extraction logic was taking into account folder names, which can include periods. The logic would incorrectly identify a file path of .well-known/foo as having the extension of well-known/foo when in reality it should be an empty string.

  • #1033 ffce3e3 Thanks @petebacondarwin! - fix: wrangler init should not crash if Git is not available on Windows

    We check for the presence of Git by trying to run git --version. On non-Windows we get an Error with code set to "ENOENT". One Windows we get a different error:

    {
      "shortMessage":"Command failed with exit code 1: git --version",
      "command":"git --version",
      "escapedCommand":"git --version",
      "exitCode":1,
      "stdout":"",
      "stderr":"'git' is not recognized as an internal or external command,\r\noperable program or batch file.",
      "failed":true,
      "timedOut":false,
      "isCanceled":false,
      "killed":false
    }
    

    Since we don't really care what the error is, now we just assume that Git is not available if an error is thrown.

    Fixes #1022

  • #982 6791703 Thanks @matthewdavidrodgers! - feature: add support for publishing to Custom Domains

    With the release of Custom Domains for workers, users can publish directly to a custom domain on a route, rather than creating a dummy DNS record first and manually pointing the worker over - this adds the same support to wrangler.

    Users declare routes as normal, but to indicate that a route should be treated as a custom domain, a user simply uses the object format in the toml file, but with a new key: custom_domain (i.e. routes = [{ pattern = "api.example.com", custom_domain = true }])

    When wrangler sees a route like this, it peels them off from the rest of the routes and publishes them separately, using the /domains api. This api is very defensive, erroring eagerly if there are conflicts in existing Custom Domains or managed DNS records. In the case of conflicts, wrangler prompts for confirmation, and then retries with parameters to indicate overriding is allowed.

  • #1019 5816eba Thanks @threepointone! - feat: bind a durable object by environment

    For durable objects, instead of just { name, class_name, script_name}, this lets you bind by environment as well, like so { name, class_name, script_name, environment }.

    Fixes #996

  • #1057 608dcd9 Thanks @petebacondarwin! - fix: pages "command" can consist of multiple words

    On Windows, the following command wrangler pages dev -- foo bar would error saying that bar was not a known argument. This is because foo and bar are passed to Yargs as separate arguments.

    A workaround is to put the command in quotes: wrangler pages dev -- "foo bar". But this fix makes the command argument variadic, which also solves the problem.

    Fixes #965

  • #1027 3545e41 Thanks @rozenmd! - feat: trying to use node builtins should recommend you enable node_compat in wrangler.toml
  • #1024 110f340 Thanks @threepointone! - polish: validate payload for kv:bulk put on client side

    This adds client side validation for the paylod for kv:bulk put, importantly ensuring we're uploading only string key/value pairs (as well as validation for the other fields).

    Fixes #571

2.0.5

Patch Changes

2.0.4

Patch Changes

  • #987 bb94038 Thanks @threepointone! - fix: encode key when calling kv:ket get, don't encode when deleting a namespace

    This cleans up some logic from #964.

    • we shouldn't be encoding the id when deleting a namespace, since that'll already be an alphanumeric id
    • we should be encoding the key when we call kv:key get, or we get a similar issue as in #961
    • adds KV to all the KV-related function names
    • moves the api calls to kv:namespace delete and kv:key delete inside kv.ts helpers.
  • #980 202f37d Thanks @threepointone! - fix: throw appropriate error when we detect an unsupported version of node

    When we start up the CLI, we check what the minimum version of supported node is, and throw an error if it isn't at least 16.7. However, the script that runs this, imports node:child_process and node:path, which was only introduced in 16.7. It was backported to older versions of node, but only in last updates to majors. So for example, if someone used 14.15.4, the script would throw because it wouldn't be able to find node:child_process (but it would work on v14.19.2).

    The fix here is to not use the prefixed versions of these built-ins in the bootstrap script. Fixes #979

2.0.3

Patch Changes

  • #956 1caa5f7 Thanks @threepointone! - fix: don't crash during init if git is not installed

    When a command isn't available on a system, calling execa() on it throws an error, and not just a non zero exitCode. This patch fixes the flow so we don't crash the whole process when that happens on testing the presence of git when calling wrangler init.

    Fixes #950

  • #970 35e780b Thanks @GregBrimble! - fix: Fixes Pages Plugins and static asset routing.

    There was previously a bug where a relative pathname would be missing the leading slash which would result in routing errors.

  • #957 e0a0509 Thanks @JacobMGEvans! - refactor: Moving --legacy-env out of global The --legacy-env flag was in global scope, which only certain commands utilize the flag for functionality, and doesnt do anything for the other commands.

    resolves #933

  • #948 82165c5 Thanks @petebacondarwin! - fix: improve error message if custom build output is not found

    The message you get if Wrangler cannot find the output from the custom build is now more helpful. It will even look around to see if there is a suitable file nearby and make suggestions about what should be put in the main configuration.

    Closes #946

  • #952 ae3895e Thanks @d3lm! - feat: use host specific callback url

    To allow OAuth to work on environments such as WebContainer we have to generate a host-specific callback URL. This PR uses @webcontainer/env to generate such URL only for running in WebContainer. Otherwise the callback URL stays unmodified.

  • #951 09196ec Thanks @petebacondarwin! - fix: look for an alternate port in the dev command if the configured one is in use

    Previously, we were only calling getPort() if the configured port was undefined. But since we were setting the default for this during validation, it was never undefined.

    Fixes #949

  • #964 0dfd95f Thanks @JacobMGEvans! - fix: KV not setting correctly The KV has URL inputs, which in the case of / would get collapsed and lost. T:o handle special characters encodeURIComponent is implemented.

    resolves #961

2.0.2

Patch Changes

  • #941 d84b568 Thanks @threepointone! - fix: bundle worker as iife if detected as a service worker

    We detect whether a worker is a "modules" format worker by the presence of a default export. This is a pretty good heuristic overall, but sometimes folks can make mistakes. One situation that's popped up a few times, is people writing exports, but still writing it in "service worker" format. We detect this fine, and log a warning about the exports, but send it up with the exports included. Unfortunately, our runtime throws when we mark a worker as a service worker, but still has exports. This patch fixes it so that the exports are not included in a service-worker worker.

    Note that if you're missing an event listener, it'll still error with "No event handlers were registered. This script does nothing." but that's a better error than the SyntaxError even when the listener was there.

    Fixes #937

2.0.1

Patch Changes

  • #932 e95e5a0 Thanks @threepointone! - fix: log proper response status codes in dev

    During dev we log the method/url/statuscode for every req+res. This fix logs the correct details for every request.

    Fixes #931

  • #930 bc28bea Thanks @GregBrimble! - fix: Default to creating a new project when no existing ones are available for 'wrangler pages publish'

2.0.0

Major Changes

  • #928 7672f99 Thanks @threepointone! - ⛅️ Wrangler 2.0.0

    Wrangler 2.0 is a full rewrite. Every feature has been improved, while retaining as much backward compatibility as we could. We hope you love it. It'll only get better.

0.0.34

Patch Changes

  • #926 7b38a7c Thanks @threepointone! - polish: show paths of created files with wrangler init

    This patch modifies the terminal when running wrangler init, to show the proper paths of files created during it (like package.json, tsconfig.json, etc etc). It also fixes a bug where we weren't detecting the existence of src/index.js for a named worker before asking to create it.

0.0.33

Patch Changes

  • #924 3bdba63 Thanks @threepointone! - fix: withwrangler init, test for existence of package.json/ tsconfig.json / .git in the right locations

    When running wrangler.init, we look for the existence of package.json, / tsconfig.json / .git when deciding whether we should create them ourselves or not. Because name can be a relative path, we had a bug where we don't starting look from the right directory. We also had a bug where we weren't even testing for the existence of the .git directory correctly. This patch fixes that initial starting location, tests for .git as a directory, and correctly decides when to create those files.

0.0.32

Patch Changes

  • #922 e2f9bb2 Thanks @threepointone! - feat: offer to create a git repo when calling wrangler init

    Worker projects created by wrangler init should also be managed by source control (popularly, git). This patch adds a choice in wrangler init to make the created project into a git repository.

    Additionally, this fixes a bug in our tests where mocked confirm() and prompt() calls were leaking between tests.

    Closes #847

0.0.31

Patch Changes

  • #916 4ef5fbb Thanks @petebacondarwin! - fix: display and error and help for wrangler init --site

    The --site option is no longer supported. This change adds information about how to create a new Sites project by cloning a repository. It also adds links to the Worker Sites and Cloudflare Pages docs.

  • #908 f8dd31e Thanks @threepointone! - fix: fix isolate prewarm logic for wrangler dev

    When calling wrangler dev, we make a request to a special URL that "prewarms" the isolate running our Worker so that we can attach devtools etc to it before actually making a request. We'd implemented it wrongly, and because we'd silenced its errors, we weren't catching it. This patch fixes the logic (based on wrangler 1.x's implementation) and enables logging errors when the prewarm request fails.

    As a result, profiling starts working again as expected. Fixes #907

  • #919 13078e1 Thanks @threepointone! - fix: don't crash when tail event is null

    Sometime the "event" on a tail can be null. This patch makes sure we don't crash when that happens. Fixes #918

  • #913 dfeed74 Thanks @threepointone! - polish: add a deprecation warning to --inspect on dev

    We have a blogposts and docs that says you need to pass --inspect to use devtools and/or profile your Worker. In wrangler v2, we don't need to pass the flag anymore. Using it right now will throw an error, so this patch makes it a simple warning instead.

  • #920 57cf221 Thanks @threepointone! - chore: don't minify bundles

    When errors in wrangler happen, it's hard to tell where the error is coming from in a minified bundle. This patch removes the minification. We still set process.env.NODE_ENV = 'production' in the bundle so we don't run dev-only paths in things like React.

    This adds about 2 mb to the bundle, but imo it's worth it.

  • #910 fe0344d Thanks @taylorlee! - fix: support preview buckets for r2 bindings

    Allows wrangler2 to perform preview & dev sessions with a different bucket than the published worker's binding.

    This matches kv's preview_id behavior, and brings the wrangler2 implementation in sync with wrangler1.

0.0.30

Patch Changes

  • #901 b246066 Thanks @threepointone! - chore: minify bundle, don't ship sourcemaps

    We haven't found much use for sourcemaps in production, and we should probably minify the bundle anyway. This will also remove an dev only warnings react used to log.

  • #904 641cdad Thanks @GregBrimble! - feat: Adds 'assets:' loader for Pages Functions.

    This lets users and Plugin authors include a folder of static assets in Pages Functions.

    export { onRequest } from "assets:../folder/of/static/assets";

    More information in our docs.

  • #905 c57ff0e Thanks @JacobMGEvans! - chore: removed Sentry and related reporting code. Automated reporting of Wrangler errors will be reimplemented after further planning.

0.0.29

Patch Changes

  • #897 d0801b7 Thanks @threepointone! - polish: tweak the message when .dev.vars is used

    This tweaks the mssage when a .dev.vars file is used so that it doesn't imply that the user has to copy the values from it into their wrangler.toml.

  • #880 aad1418 Thanks @GregBrimble! - fix: Stop unnecessarily amalgamating duplicate headers in Pages Functions

    Previously, set-cookie multiple headers would be combined because of unexpected behavior in the spec.

  • #892 b08676a Thanks @GregBrimble! - fix: Adds the leading slash to Pages deployment manifests that the API expects, and fixes manifest generation on Windows machines.
  • #852 6283ad5 Thanks @JacobMGEvans! - feat: non-TTY check for required variables Added a check in non-TTY environments for account_id, CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN. If account_id exists in wrangler.toml then CLOUDFLARE_ACCOUNT_ID is not needed in non-TTY scope. The CLOUDFLARE_API_TOKEN is necessary in non-TTY scope and will always error if missing.

    resolves #827

  • #893 5bf17ca Thanks @petebacondarwin! - fix: remove bold font from additional lines of warnings and errors

    Previously, when a warning or error was logged, the entire message was formatted in bold font. This change makes only the first line of the message bold, and the rest is formatted with a normal font.

  • #894 57c1354 Thanks @threepointone! - polish: s/DO NOT USE THIS/ Ignored

    Followup to #888, this replaces some more scary capitals with a more chill word.

  • #882 1ad7570 Thanks @petebacondarwin! - feat: add support for reading build time env variables from a .env file

    This change will automatically load up a .env file, if found, and apply its values to the current environment. An example would be to provide a specific CLOUDFLARE_ACCOUNT_ID value.

    Related to #190

  • #887 2bb4d30 Thanks @threepointone! - polish: accept Enter as a valid key in confirm dialogs

    Instead of logging "Unrecognised input" when hitting return/enter in a confirm dialog, we should accept it as a confirmation. This patch also makes the default choice "y" bold in the dialog.

  • #891 bae5ba4 Thanks @GregBrimble! - feat: Adds interactive prompts for the 'wrangler pages publish' and related commands.

    Additionally, those commands now read from node_modules/.cache/wrangler/pages.json to persist users' account IDs and project names.

  • #888 b77aa38 Thanks @threepointone! - polish: s/DEPRECATION/Deprecation

    This removes the scary uppercase from DEPRECATION warnings. It also moves the service environment usage warning into diagnostics instead of logging it directly.

  • #879 f694313 Thanks @petebacondarwin! - feat: read vars overrides from a local file for wrangler dev

    The vars bindings can be specified in the wrangler.toml configuration file. But "secret" vars are usually only provided at the server - either by creating them in the Dashboard UI, or using the wrangler secret command.

    It is useful during development, to provide these types of variable locally. When running wrangler dev we will look for a file called .dev.vars, situated next to the wrangler.toml file (or in the current working directory if there is no wrangler.toml). Any values in this file, formatted like a dotenv file, will add to or override vars bindings provided in the wrangler.toml.

    Related to #190

0.0.28

Patch Changes

  • #843 da12cc5 Thanks @threepointone! - fix: site.entry-point is no longer a hard deprecation

    To make migration of v1 projects easier, Sites projects should still work, including the entry-point field (which currently errors out). This enables site.entry-point as a valid entry point, with a deprecation warning.

  • #877 97f945f Thanks @caass! - Treat the "name" parameter in wrangler init as a path.

    This means that running wrangler init . will create a worker in the current directory, and the worker's name will be the name of the current directory.

    You can also run wrangler init path/to/my-worker and a worker will be created at [CWD]/path/to/my-worker with the name my-worker,

  • #851 277b254 Thanks @threepointone! - polish: do not log the error object when refreshing a token fails

    We handle the error anyway (by doing a fresh login) which has its own logging and messaging. In the future we should add a DEBUG mode that logs all requests/errors/warnings, but that's for later.

  • #869 f1423bf Thanks @threepointone! - feat: experimental --node-compat / config.node_compat

    This adds an experimental node.js compatibility mode. It can be enabled by adding node_compat = true in wrangler.toml, or by passing --node-compat as a command line arg for dev/publish commands. This is currently powered by @esbuild-plugins/node-globals-polyfill (which in itself is powered by rollup-plugin-node-polyfills).

    We'd previously added this, and then removed it because the quality of the polyfills isn't great. We're reintroducing it regardless so we can start getting feedback on its usage, and it sets up a foundation for replacing it with our own, hopefully better maintained polyfills.

    Of particular note, this means that what we promised in https://blog.cloudflare.com/announcing-stripe-support-in-workers/ now actually works.

    This patch also addresses some dependency issues, specifically leftover entries in package-lock.json.

  • #866 8b227fc Thanks @caass! - Add a runtime check for wrangler dev local mode to avoid erroring in environments with no AsyncLocalStorage class

    Certain runtime APIs are only available to workers during the "request context", which is any code that returns after receiving a request and before returning a response.

    Miniflare emulates this behavior by using an AsyncLocalStorage and checking at runtime to see if you're using those APIs during the request context.

    In certain environments AsyncLocalStorage is unavailable, such as in a webcontainer. This function figures out if we're able to run those "request context" checks and returns a set of options that indicate to miniflare whether to run the checks or not.

  • #829 f08aac5 Thanks @JacobMGEvans! - feat: Add validation to the name field in configuration. The validation will warn users that the field can only be "type string, alphanumeric, underscores, and lowercase with dashes only" using the same RegEx as the backend

    resolves #795 #775

  • #868 6ecb1c1 Thanks @threepointone! - feat: implement service environments + durable objects

    Now that the APIs for getting migrations tags of services works as expected, this lands support for publishing durable objects to service environments, including migrations. It also removes the error we used to throw when attempting to use service envs + durable objects.

    Fixes #739

0.0.27

Patch Changes

  • #838 9c025c4 Thanks @threepointone! - fix: remove timeout on custom builds, and make sure logs are visible

    This removes the timeout we have for custom builds. We shouldn't be applying this timeout anyway, since it doesn't block wrangler, just the user themselves. Further, in #759, we changed the custom build's process stdout/stderr config to "pipe" to pass tests, however that meant we wouldn't see logs in the terminal anymore. This patch removes the timeout, and brings back proper logging for custom builds.

  • #349 9d04a68 Thanks @GregBrimble! - chore: rename --script-path to --outfile for wrangler pages functions build command.
  • #836 28e3b17 Thanks @threepointone! - fix: toggle workers.dev subdomains only when required

    This fix -

    • passes the correct query param to check whether a workers.dev subdomain has already been published/enabled
    • thus enabling it only when it's not been enabled
    • it also disables it only when it's explicitly knows it's already been enabled

    The effect of this is that publishes are much faster.

  • #794 ee3475f Thanks @JacobMGEvans! - fix: Error messaging from failed login would dump a JSON.parse error in some situations. Added a fallback if .json fails to parse it will attempt .text() then throw result. If both attempts to parse fail it will throw an UnknownError with a message showing where it originated.

    resolves #539

  • #840 32f6108 Thanks @threepointone! - fix: make wrangler work on node v18

    There's some interference between our data fetching library undici and node 18's new fetch and co. (powered by undici internally) which replaces the filename of Files attached to FormDatas with a generic blob (likely this code - https://github.com/nodejs/undici/blob/615f6170f4bd39630224c038d1ea5bf505d292af/lib/fetch/formdata.js#L246-L250). It's still not clear why it does so, and it's hard to make an isolated example of this.

    Regardless, disabling the new fetch functionality makes undici use its own base classes, avoiding the problem for now, and unblocking our release. We'll keep investigating and look for a proper fix.

    Unblocks #834

  • #824 62af4b6 Thanks @threepointone! - feat: publish --dry-run

    It can be useful to do a dry run of publishing. Developers want peace of mind that a project will compile before actually publishing to live servers. Combined with --outdir, this is also useful for testing the output of publish. Further, it gives developers a chance to upload our generated sourcemap to a service like sentry etc, so that errors from the worker can be mapped against actual source code, but before the service actually goes live.

  • #839 f2d6de6 Thanks @threepointone! - fix: persist dev experimental storage state in feature specific dirs

    With --experimental-enable-local-persistence in dev, we were clobbering a single folder with data from kv/do/cache. This patch gives individual folders for them. It also enables persistence even when this is not true, but that stays only for the length of a session, and cleans itself up when the dev session ends.

    Fixes #830

  • #820 60c409a Thanks @petebacondarwin! - fix: display a warning if the user has a miniflare section in their wrangler.toml.

    Closes #799

  • #796 3e0db3b Thanks @GregBrimble! - fix: Makes Response Headers object mutable after a call to next() in Pages Functions
  • #814 51fea7c Thanks @threepointone! - fix: disallow setting account_id in named service environments

    Much like #641, we don't want to allow setting account_id with named service environments. This is so that we use the same account_id for multiple environments, and have them group together in the dashboard.

  • #823 4a00910 Thanks @threepointone! - fix: don't log an error when wrangler dev is cancelled early

    We currently log an AbortError with a stack if we exit wrangler dev's startup process before it's done. This fix skips logging that error (since it's not an exception).

    Test plan:

    cd packages/wrangler
    npm run build
    cd ../../examples/workers-chat-demo
    npx wrangler dev
    # hit [x] as soon as the hotkey shortcut bar shows
    
  • #815 025c722 Thanks @threepointone! - fix: ensure that bundle is generated to es2020 target

    The default tsconfig generated by tsc uses target: "es5", which we don't support. This fix ensures that we output es2020 modules, even if tsconfig asks otherwise.

  • #349 9d04a68 Thanks @GregBrimble! - feature: Adds a --plugin option to wrangler pages functions build which compiles a Pages Plugin. More information about Pages Plugins can be found here. This wrangler build is required for both the development of, and inclusion of, plugins.
  • #822 4302172 Thanks @GregBrimble! - chore: Add help messages for wrangler pages project and wrangler pages deployment
  • #837 206b9a5 Thanks @threepointone! - polish: replace 🦺 with ⚠️

    I got some feedback that the construction worker jacket (?) icon for deprecations is confusing, especially because it's an uncommon icon and not very big in the terminal. This patch replaces it with a more familiar warning symbol.

  • #824 62af4b6 Thanks @threepointone! - feat: publish --outdir <path>

    It can be useful to introspect built assets. A leading usecase is to upload the sourcemap that we generate to services like sentry etc, so that errors from the worker can be mapped against actual source code. We introduce a --outdir cli arg to specify a path to generate built assets at, which doesn't get cleaned up after publishing. We are not adding this to wrangler.toml just yet, but could in the future if it looks appropriate there.

  • #811 8c2c7b7 Thanks @JacobMGEvans! - feat: Added minify as a configuration option and a cli arg, which will minify code for dev and publish

    resolves #785

0.0.26

Patch Changes

  • #782 34552d9 Thanks @GregBrimble! - feature: Add 'pages create project [name]' command.

    This command will create a Pages project with a given name, and optionally set its --production-branch=[production].

  • #772 a852e32 Thanks @JacobMGEvans! - fix: We want to prevent any user created code from sending Events to Sentry, which can be captured by uncaughtExceptionMonitor listener. Miniflare code can run user code on the same process as Wrangler, so we want to return null if @miniflare is present in the Event frames.
  • #778 85b0c31 Thanks @threepointone! - feat: optionally send zone_id with a route

    This enables optionally passing a route as {pattern: string, zone_id: string}. There are scenarios where we need to explicitly pass a zone_id to the api, so this enables that.

    Some nuance: The errors from the api aren't super useful when invalid values are passed, but that's something to further work on.

    This also fixes some types in our cli parsing.

    Fixes #774

  • #813 5c59f97 Thanks @threepointone! - add a warning if service environments are being used.

    Service environments are not ready for widespread usage, and their behaviour is going to change. This adds a warning if anyone uses them.

    Closes #809

  • #789 5852bba Thanks @threepointone! - polish: don't log all errors when logging in

    This removes a couple of logs we had for literally every error in our oauth flow. We throw the error and handle it separately anyway, so this is a safe cleanup.

    Fixes #788

  • #806 b24aeb5 Thanks @threepointone! - fix: check for updates on the right channel

    This makes the update checker run on the channel that the version being used runs on.

  • #807 7e560e1 Thanks @threepointone! - fix: read isLegacyEnv correctly

    This fixes the signature for isLegacyEnv() since it doesn't use args, and we fix reading legacy_env correctly when creating a draft worker when creating a secret.

  • #779 664803e Thanks @threepointone! - chore: update packages

    This updates some dependencies. Some highlights -

    • updates to @iarna/toml means we can have mixed types for inline arrays, which is great for #774 / #778
    • I also moved timeago.js to devDependencies since it already gets compiled into the bundle
    • updates to esbuild brings along a number of smaller fixes for modern js
  • #810 0ce47a5 Thanks @caass! - Make wrangler tail TTY-aware, and stop printing non-JSON in JSON mode

    Closes #493

    2 quick fixes:

    • Check process.stdout.isTTY at runtime to determine whether to default to "pretty" or "json" output for tailing.
    • Only print messages like "Connected to {worker}" if in "pretty" mode (errors still throw strings)

0.0.25

Patch Changes

  • #767 836ad59 Thanks @threepointone! - fix: use cwd for --experiment-enable-local-persistence

    This sets up --experiment-enable-local-persistence to explicitly use process.cwd() + wrangler-local-state as a path to store values. Without it, local mode uses the temp dir that we use to bundle the worker, which gets wiped out on ending wrangler dev. In the future, based on usage, we may want to make the path configurable as well.

    Fixes #766

  • #723 7942936 Thanks @threepointone! - fix: spread tail messages when logging

    Logged messages (via console, etc) would previously be logged as an array of values. This spreads it when logging to match what is expected.

  • #756 8e38442 Thanks @threepointone! - fix: resolve raw file bindings correctly in wrangler dev local mode

    For wasm_modules/text_blobs/data_blobs in local mode, we need to rewrite the paths as absolute so that they're resolved correctly by miniflare. This also expands some coverage for local mode wrangler dev.

    Fixes #740 Fixes #416

  • #728 0873049 Thanks @threepointone! - fix: only send durable object migrations when required

    We had a bug where even if you'd published a script with migrations, we would still send a blank set of migrations on the next round. The api doesn't accept this, so the fix is to not do so. I also expanded test coverage for migrations.

    Fixes #705

  • #763 f72c943 Thanks @JacobMGEvans! - feat: Added the update check that will check the package once a day against the beta release, distTag can be changed later, then prints the latestbeta version to the user.

    resolves #762

  • #695 48fa89b Thanks @caass! - fix: stop wrangler spamming console after login

    If a user hasn't logged in and then they run a command that needs a login they'll get bounced to the login flow. The login flow (if completed) would write their shiny new OAuth2 credentials to disk, but wouldn't reload the in-memory state. This led to issues like #693, where even though the user was logged in on-disk, wrangler wouldn't be aware of it.

    We now update the in-memory login state each time new credentials are written to disk.

  • #734 a1dadac Thanks @threepointone! - fix: exit dev if build fails on first run

    Because of evanw/esbuild#1037, we can't recover dev if esbuild fails on first run. The workaround is to end the process if it does so, until we have a better fix.

    Reported in #731

  • #747 db6b830 Thanks @petebacondarwin! - refactor: remove process.exit() from the pages code

    This enables simpler testing, as we do not have to spawn new child processes to avoid the process.exit() from killing the jest process.

    As part of the refactor, some of the Error classes have been moved to a shared errors.ts file.

  • #726 c4e5dc3 Thanks @threepointone! - fix: assume a worker is a module worker only if it has a default export

    This tweaks the logic that guesses worker formats to check whether a default export is defined on an entry point before assuming it's a module worker.

  • #735 c38ae3d Thanks @threepointone! - text_blobs/Text module support for service worker format in local mode

    This adds support for text_blobs/Text module support in local mode. Now that cloudflare/miniflare#228 has landed in miniflare (thanks @caass!), we can use that in wrangler as well.

  • #743 ac5c48b Thanks @threepointone! - feat: implement [data_blobs]

    This implements [data_blobs] support for service-worker workers, as well as enabling Data module support for service-worker workers. data_blob is a supported binding type, but we never implemented support for it in v1. This implements support, and utilises it for supporting Data modules in service worker format. Implementation wise, it's incredibly similar to how we implemented text_blobs, with relevant changes.

    Partial fix for #740 pending local mode support.

  • #733 91873e4 Thanks @JacobMGEvans! - polish: improved visualization of the deprecation messages between serious and warnings with emojis. This also improves the delineation between messages.
  • #738 c04791c Thanks @petebacondarwin! - fix: add support for cron triggers in dev --local mode

    Currently, I don't know if there is support for doing this in "remote" dev mode.

    Resolves #737

  • #732 c63ea3d Thanks @JacobMGEvans! - fix: abort async operations in the Remote component to avoid unwanted side-effects When the Remote component is unmounted, we now signal outstanding fetch() requests, and waitForPortToBeAvailable() tasks to cancel them. This prevents unexpected requests from appearing after the component has been unmounted, and also allows the process to exit cleanly without a delay.

    fixes #375

0.0.24

Patch Changes

  • #719 6503ace Thanks @petebacondarwin! - fix: ensure the correct worker name is published in legacy environments

    When a developer uses --env to specify an environment name, the Worker name should be computed from the top-level Worker name and the environment name.

    When the given environment name does not match those in the wrangler.toml, we error. But if no environments have been specified in the wrangler.toml, at all, then we only log a warning and continue.

    In this second case, we were reusing the top-level environment, which did not have the correct legacy environment fields set, such as the name. Now we ensure that such an environment is created as needed.

    See #680 (comment)

  • #708 763dcb6 Thanks @threepointone! - fix: unexpected commands and arguments should throw

    This enables strict mode in our command line parser (yargs), so that unexpected commands and options uniformly throw errors.

    Fixes #706

  • #713 18d09c7 Thanks @threepointone! - fix: don't fetch zone id for wrangler dev --local

    We shouldn't try to resolve a domain/route to a zone id when starting in local mode (since there may not even be network).

  • #692 52ea60f Thanks @threepointone! - fix: do not deploy to workers.dev when routes are defined in an environment

    When workers_dev is not configured, we had a bug where it would default to true inside an environment even when there were routes defined, thus publishing both to a workers.dev subdomain as well as the defined routes. The fix is to default workers_dev to undefined, and check when publishing whether or not to publish to workers.dev/defined routes.

    Fixes #690

  • #687 8f7ac7b Thanks @petebacondarwin! - fix: add warning about wrangler dev with remote Durable Objects

    Durable Objects that are being bound by script_name will not be isolated from the live data during development with wrangler dev. This change simply warns the developer about this, so that they can back out before accidentally changing live data.

    Fixes #319

  • #661 6967086 Thanks @JacobMGEvans! - polish: add "Beta" messaging around the CLI command for Pages. Explicitly specifying the command is Beta, not to be confused with Pages itself which is production ready.
  • #709 7e8ec9a Thanks @threepointone! - fix: trigger login flow if refreshtoken isn't valid

    If the auth refresh token isn't valid, then we should trigger the login flow. Reported in #316

  • #702 241000f Thanks @threepointone! - fix: setup jsx loaders when guessing worker format

    • We consider jsx to be regular js, and have setup our esbuild process to process js/mjs/cjs files as jsx.
    • We use a separate esbuild run on an entry point file when trying to guess the worker format, but hadn't setup the loaders there.
    • So if just the entrypoint file has any jsx in it, then we error because it can't parse the code.

    The fix is to add the same loaders to the esbuild run that guesses the worker format.

    Reported in #701

  • #712 fb53fda Thanks @threepointone! - feat: Non-interactive mode

    Continuing the work from #325, this detects when wrangler is running inside an environment where "raw" mode is not available on stdin, and disables the features for hot keys and the shortcut bar. This also adds stubs for testing local mode functionality in local-mode-tests, and deletes the previous hacky dev2.test.tsx.

    Fixes #322

  • #716 6987cf3 Thanks @threepointone! - feat: path to a custom tsconfig

    This adds a config field and a command line arg tsconfig for passing a path to a custom typescript configuration file. We don't do any typechecking, but we do pass it along to our build process so things like compilerOptions.paths get resolved correctly.

  • #665 62a89c6 Thanks @caass! - fix: validate that bindings have unique names

    We don't want to have, for example, a KV namespace named "DATA" and a Durable Object also named "DATA". Then it would be ambiguous what exactly would live at env.DATA (or in the case of service workers, the DATA global) which could lead to unexpected behavior -- and errors.

    Similarly, we don't want to have multiple resources of the same type bound to the same name. If you've been working with some KV namespace called "DATA", and you add a second namespace but don't change the binding to something else (maybe you're copying-and-pasting and just changed out the id), you could be reading entirely the wrong stuff out of your KV store.

    So now we check for those sorts of situations and throw an error if we find that we've encountered one.

  • #698 e3e3243 Thanks @threepointone! - feat: inject process.env.NODE_ENV into scripts

    An extremely common pattern in the js ecosystem is to add additional behaviour gated by the value of process.env.NODE_ENV. For example, React leverages it heavily to add dev-time checks and warnings/errors, and to load dev/production versions of code. By doing this substitution ourselves, we can get a significant runtime boost in libraries/code that leverage this.

    This does NOT tackle the additional features of either minification, or proper node compatibility, or injecting wrangler's own environment name, which we will tackle in future PRs.

  • #680 8e2cbaf Thanks @JacobMGEvans! - refactor: support backwards compatibility with environment names and related CLI flags

    1. When in Legacy environment mode we should not compute name field if specified in an environment.
    2. Throw an Error when --env and --name are used together in Legacy Environment, except for Secrets & Tail which are using a special case getLegacyScriptName for parity with Wrangler1
    3. Started the refactor for args being utilized at the Config level, currently checking for Legacy Environment only.

    Fixes #672

  • #684 82ec7c2 Thanks @GregBrimble! - fix: Fix --binding option for wrangler pages dev.

    We'd broken this with #581. This reverts that PR, and fixes it slightly differently. Also added an integration test to ensure we don't regress in the future.

  • #678 82e4143 Thanks @threepointone! - fix: cleanup after pages dev tests

    We weren't killing the process started by wrangler whenever its parent was killed. This fix is to listen on SIGINT/SIGTERM and kill that process. I also did some minor configuration cleanups.

    Fixes #397 Fixes #618

0.0.23

Patch Changes

  • #675 e88a54e Thanks @threepointone! - fix: resolve non-js modules correctly in local mode

    In #633, we missed passing a cwd to the process that runs the miniflare cli. This broke how miniflare resolves modules, and led back to the dreaded "path should be a path.relative()d string" error. The fix is to simply pass the cwd to the spawn call.

    Test plan:

    cd packages/wrangler
    npm run build
    cd ../workers-chat-demo
    npx wrangler dev --local
    
  • #668 3dcdb0d Thanks @petebacondarwin! - fix: tighten up the named environment configuration

    Now, when we normalize and validate the raw config, we pass in the currently active environment name, and the config that is returned contains all the environment fields correctly normalized (including inheritance) at the top level of the config object. This avoids other commands from having to check both the current named environment and the top-level config for such fields.

    Also, now, handle the case where the active environment name passed in via the --env command line argument does not match any of the named environments in the configuration:

    • This is an error if there are named environments configured;
    • or only a warning if there are no named environments configured.
  • #633 003f3c4 Thanks @JacobMGEvans! - refactor: create a custom CLI wrapper around Miniflare API

    This allows us to tightly control the options that are passed to Miniflare. The current CLI is setup to be more compatible with how Wrangler 1 works, which is not optimal for Wrangler 2.

  • #633 84c857e Thanks @JacobMGEvans! - fix: ensure asset keys are relative to the project root

    Previously, asset file paths were computed relative to the current working directory, even if we had used -c to run Wrangler on a project in a different directory to the current one.

    Now, assets file paths are computed relative to the "project root", which is either the directory containing the wrangler.toml or the current working directory if there is no config specified.

  • #673 456e1da Thanks @petebacondarwin! - fix: allow the build field to be inherited/overridden in a named environment"

    Now the build field can be specified within a named environment, overriding whatever may appear at the top level.

    Resolves #588

  • #662 612952b Thanks @JacobMGEvans! - bugfix: use alias -e for --env to prevent scripts using Wrangler 1 from breaking when switching to Wrangler 2.
  • #671 ef0aaad Thanks @GregBrimble! - fix: don't exit on initial Pages Functions compilation failure

    Previously, we'd exit the wrangler pages dev process if we couldn't immediately compile a Worker from the functions directory. We now log the error, but don't exit the process. This means that proxy processes can be cleaned up cleanly on SIGINT and SIGTERM, and it matches the behavior of if a compilation error is introduced once already running (we don't exit then either).

  • #640 2a2d50c Thanks @caass! - Error if the user is trying to implement DO's in a service worker

    Durable Objects can only be implemented in Module Workers, so we should throw if we detect that the user is trying to implement a Durable Object but their worker is in Service Worker format.

0.0.22

Patch Changes

  • #656 aeb0fe0 Thanks @threepointone! - fix: resolve npm modules correctly

    When implementing legacy module specifiers, we didn't throughly test the interaction when there weren't any other files next to the entry worker, and importing npm modules. It would create a Regex that matched every import, and fail because a file of that name wasn't present in the source directory. This fix constructs a better regex, applies it only when there are more files next to the worker, and increases test coverage for that scenario.

    Fixes #655

0.0.21

Patch Changes

  • #647 f3f3907 Thanks @petebacondarwin! - feat: add support for --ip and config.dev.ip in the dev command

    Note that this change modifies the default listening address to localhost, which is different to 127.0.0.1, which is what Wrangler 1 does. For most developers this will make no observable difference, since the default host mapping in most OSes from localhost to 127.0.0.1.

    Resolves #584

0.0.20

Patch Changes

  • #649 e0b9366 Thanks @threepointone! - fix: use expiration_ttl to expire assets with [site]

    This switches how we expire static assets with [site] uploads to use expiration_ttl instead of expiration. This is because we can't trust the time that a deploy target may provide (like in cloudflare/wrangler-legacy#2224).

  • #599 7d4ea43 Thanks @caass! - Force-open a chromium-based browser for devtools

    We rely on Chromium-based devtools for debugging workers, so when opening up the devtools URL, we should force a chromium-based browser to launch. For now, this means checking (in order) for Chrome and Edge, and then failing if neither of those are available.

  • #567 05b81c5 Thanks @threepointone! - fix: consolidate getEntry() logic

    This consolidates some logic into getEntry(), namely including guessWorkerFormat() and custom builds. This simplifies the code for both dev and publish.

    • Previously, the implementation of custom builds inside dev assumed it could be a long running process; however it's not (else consider that publish would never work).
    • By running custom builds inside getEntry(), we can be certain that the entry point exists as we validate it and before we enter dev/publish, simplifying their internals
    • We don't have to do periodic checks inside wrangler dev because it's now a one shot build (and always should have been)
    • This expands test coverage a little for both dev and publish.
    • The 'format' of a worker is intrinsic to its contents, so it makes sense to establish its value inside getEntry()
    • This also means less async logic inside <Dev/>, which is always a good thing
  • #628 b640ab5 Thanks @caass! - Validate that if route exists in wrangler.toml, routes does not (and vice versa)
  • #591 42c2c0f Thanks @petebacondarwin! - fix: add warning about setting upstream-protocol to http

    We have not implemented setting upstream-protocol to http and currently do not intend to.

    This change just adds a warning if a developer tries to do so and provides a link to an issue where they can add their use-case.

  • #596 187264d Thanks @threepointone! - feat: support wrangler 1.x module specifiers with a deprecation warning

    This implements wrangler 1.x style module specifiers, but also logs a deprecation warning for every usage.

    Consider a project like so:

      project
      ├── index.js
      └── some-dependency.js
    

    where the content of index.js is:

    import SomeDependency from "some-dependency.js";
    addEventListener("fetch", event => {
    	// ...
    });

    wrangler 1.x would resolve import SomeDependency from "some-dependency.js"; to the file some-dependency.js. This will work in wrangler v2, but it will log a deprecation warning. Instead, you should rewrite the import to specify that it's a relative path, like so:

    - import SomeDependency from "some-dependency.js";
    + import SomeDependency from "./some-dependency.js";

    In a near future version, this will become a breaking deprecation and throw an error.

    (This also updates workers-chat-demo to use the older style specifier, since that's how it currently is at https://github.com/cloudflare/workers-chat-demo)

    Known issue: This might not work as expected with .js/.cjs/.mjs files as expected, but that's something to be fixed overall with the module system.

    Closes #586

  • #559 16fb5e6 Thanks @petebacondarwin! - feat: support adding secrets in non-interactive mode

    Now the user can pipe in the secret value to the wrangler secret put command. For example:

    cat my-secret.txt | wrangler secret put secret-key --name worker-name
    

    This requires that the user is logged in, and has only one account, or that the account_id has been set in wrangler.toml.

    Fixes #170

  • #597 94c2698 Thanks @caass! - Deprecate wrangler route, wrangler route list, and wrangler route delete

    Users should instead modify their wrangler.toml or use the --routes flag when publishing to manage routes.

  • #638 06f9278 Thanks @threepointone! - polish: add a small banner for commands

    This adds a small banner for most commands. Specifically, we avoid any commands that maybe used as a parse input (like json into jq). The banner itself simply says "⛅️ wrangler" with an orange underline.

  • #561 6e9a219 Thanks @threepointone! - fix: resolve modules correctly in wrangler dev --local

    This is an alternate fix to cloudflare/miniflare#205, and fixes the error where miniflare would get confused resolving relative modules on macs because of /var//private/var being symlinks. Instead, we realpathSync the bundle path before passing it on to miniflare, and that appears to fix the problem.

    Test plan:

    cd packages/wrangler
    npm run build
    cd ../workers-chat-demo
    npx wrangler dev --local
    

    Fixes #443

  • #592 56886cf Thanks @caass! - Stop reporting breadcrumbs to sentry

    Sentry's SDK automatically tracks "breadcrumbs", which are pieces of information that get tracked leading up to an exception. This can be useful for debugging errors because it gives better insight into what happens before an error occurs, so you can more easily understand and recreate exactly what happened before an error occurred.

    Unfortunately, Sentry automatically includes all console statements. And since we use the console a lot (e.g. logging every request received in wrangler dev), this is mostly useless. Additionally, since developers frequently use the console to debug their workers we end up with a bunch of data that is not only irrelevant to the reported error, but also contains data that could be potentially sensitive.

    For now, we're turning off breadcrumbs entirely. Later, we might wish to add our own breadcrumbs manually (e.g. add a "wrangler dev" breadcrumb when a user runs wrangler dev), at which point we can selectively enable breadcrumbs to catch only the ones we've put in there ourselves.

  • #645 61aea30 Thanks @petebacondarwin! - fix: improve authentication logging and warnings

    • If a user has previously logged in via Wrangler 1 with an API token, we now display a helpful warning.
    • When logging in and out, we no longer display the path to the internal user auh config file.
    • When logging in, we now display an initial message to indicate the authentication flow is starting.

    Fixes #526

  • #608 a7fa544 Thanks @sidharthachatterjee! - fix: Ensure generateConfigFromFileTree generates config correctly for multiple splats

    Functions with multiple parameters, like /near/[latitude]/[longitude].ts wouldn't work. This fixes that.

  • #580 8013e0a Thanks @petebacondarwin! - feat: add support for --local-protocol=https to wrangler dev

    This change adds full support for the setting the protocol that the localhost proxy server listens to. Previously, it was only possible to use HTTP. But now you can set it to HTTPS as well.

    To support HTTPS, Wrangler needs an SSL certificate. Wrangler now generates a self-signed certificate, as needed, and caches it in the ~/.wrangler/local-cert directory. These certificates expire after 30 days and are regenerated by Wrangler as needed.

    Note that if you use HTTPS then your browser will complain about the self-signed and you must tell it to accept the certificate before it will let you access the page.

  • #639 5161e1e Thanks @petebacondarwin! - refactor: initialize the user auth state synchronously

    We can now initialize the user state synchronously, which means that we can remove the checks for whether it has been done or not in each of the user auth functions.

  • #568 b6f2266 Thanks @caass! - Show an actionable error message when publishing to a workers.dev subdomain that hasn't been created yet.

    When publishing a worker to workers.dev, you need to first have registered your workers.dev subdomain (e.g. my-subdomain.workers.dev). We now check to ensure that the user has created their subdomain before uploading a worker to workers.dev, and if they haven't, we provide a link to where they can go through the workers onboarding flow and create one.

  • #641 21ee93e Thanks @petebacondarwin! - fix: error if a non-legacy service environment tries to define a worker name

    Given that service environments all live off the same worker, it doesn't make sense for them to have different names.

    This change adds validation to tell the developer to remove such name fields in service environment config.

    Fixes #623

  • #646 c75cfb8 Thanks @threepointone! - fix: default watch_dir to src of project directory

    Via wrangler 1, when using custom builds in wrangler dev, watch_dir should default to src of the "project directory" (i.e - wherever the wrangler.toml is defined if it exists, else in the cwd.

    Fixes #631

  • #621 e452a04 Thanks @petebacondarwin! - fix: stop checking for open port once it has timed out in waitForPortToBeAvailable()

    Previously, if waitForPortToBeAvailable() timed out, the checkPort() function would continue to be called. Now we clean up fully once the promise is resolved or rejected.

  • #600 1bbd834 Thanks @skirsten! - fix: use environment specific and inherited config values in publish
  • #577 7faf0eb Thanks @threepointone! - fix: config.site.entry-point as a breaking deprecation

    This makes configuring site.entry-point in config as a breaking deprecation, and throws an error. We do this because existing apps with site.entry-point won't work in v2.

  • #578 c56847c Thanks @threepointone! - fix: gracefully fail if we can't create ~/.wrangler/reporting.toml

    In some scenarios (CI/CD, docker, etc), we won't have write access to ~/.wrangler. We already don't write a configuration file there if one passes a CF_API_TOKEN/CLOUDFLARE_API_TOKEN env var. This also adds a guard when writing the error reporting configuration file.

  • #621 e452a04 Thanks @petebacondarwin! - fix: check for the correct inspector port in local dev

    Previously, the useLocalWorker() hook was being passed the wrong port for the inspectorPort prop.

    Once this was fixed, it became apparent that we were waiting for the port to become free in the wrong place, since this port is already being listened to in useInspector() by the time we were starting the check.

    Now, the check to see if the inspector port is free is done in useInspector(), which also means that Remote benefits from this check too.

  • #587 49869a3 Thanks @threepointone! - feat: expire unused assets in [site] uploads

    This expires any previously uploaded assets when using a Sites / [site] configuration. Because we currently do a full iteration of a namespace's keys when publishing, for rapidly changing sites this means that uploads get slower and slower. We can't just delete unused assets because it leads to occasional 404s on older publishes while we're publishing. So we expire previous assets while uploading new ones. The implementation/constraints of the kv api means that uploads may become slower, but should hopefully be faster overall. These optimisations also only matter for rapidly changing sites, so common usecases still have the same perf characteristics.

0.0.19

Patch Changes

  • #557 835c3ae Thanks @threepointone! - fix: wrangler dev on unnamed workers in remote mode

    With unnamed workers, we use the filename as the name of the worker, which isn't a valid name for workers because of the . (This break was introduced in #545). The preview service accepts unnamed workers and generates a hash anyway, so the fix is to simply not send it, and use the host that the service provides.

0.0.18

Patch Changes

  • #523 8c99449 Thanks @threepointone! - feat: secrets + environments

    This implements environment support for wrangler secret (both legacy and services). We now consistently generate the right script name across commands with the getScriptName() helper.

    Based on the work by @mitchelvanbever in #95.

  • #554 18ac439 Thanks @petebacondarwin! - fix: limit bulk put API requests to batches of 5,000

    The kv:bulk put command now batches up put requests in groups of 5,000, displaying progress for each request.

  • #437 2805205 Thanks @jacobbednarz! - feat: use CLOUDFLARE_... environment variables deprecating CF_...

    Now one should use CLOUDFLARE_API_TOKEN, CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_BASE_URL rather than CF_API_TOKEN, CF_ACCOUNT_ID and CF_API_BASE_URL, which have been deprecated.

    If you use the deprecated variables they will still work but you will see a warning message.

    Within the Cloudflare tooling ecosystem, we have a mix of CF_ and CLOUDFLARE_ for prefixing environment variables. Until recently, many of the tools were fine with CF_ however, there started to be conflicts with external tools (such as Cloudfoundary CLI), which also uses CF_ as a prefix, and would potentially be reading and writing the same value the Cloudflare tooling.

    The Go SDK1, Terraform2 and cf-terraforming3 have made the jump to the CLOUDFLARE_ prefix for environment variable prefix.

    In future, all SDKs will use this prefix for consistency and to allow all the tooling to reuse the same environment variables in the scenario where they are present.

  • #530 fdb4afd Thanks @threepointone! - feat: implement rules config field

    This implements the top level rules configuration field. It lets you specify transport rules for non-js modules. For example, you can specify *.md files to be included as a text file with -

    [[rules]]
    {type = "Text", globs = ["**/*.md"]}
    

    We also include a default ruleset -

      { type: "Text", globs: ["**/*.txt", "**/*.html"] },
      { type: "Data", globs: ["**/*.bin"] },
      { type: "CompiledWasm", globs: ["**/*.wasm"] },
    

    More info at https://developers.cloudflare.com/workers/cli-wrangler/configuration/#build.

    Known issues -

    • non-wasm module types do not work in --local mode
    • Data type does not work in service worker format, in either mode
  • #517 201a6bb Thanks @threepointone! - fix: publish environment specific routes

    This adds some tests for publishing routes, and fixes a couple of bugs with the flow.

    • fixes publishing environment specific routes, closes #513
    • default workers_dev to false if there are any routes specified
    • catches a hanging promise when we were toggling off a workers.dev subdomain (which should have been caught by the no-floating-promises lint rule, so that's concerning)
    • this also fixes publishing environment specific crons, but I'll write tests for that when I'm doing that feature in depth
  • #528 26f5ad2 Thanks @threepointone! - feat: top level main config field

    This implements a top level main field for wrangler.toml to define an entry point for the worker , and adds a deprecation warning for build.upload.main. The deprecation warning is detailed enough to give the exact line to copy-paste into your config file. Example -

    The `build.upload` field is deprecated. Delete the `build.upload` field, and add this to your configuration file:
    
    main = "src/chat.mjs"
    

    This also makes ./dist a default for build.upload.dir, to match wrangler 1's behaviour.

    Closes #488

  • #480 10cb789 Thanks @caass! - Refactored tail functionality in preparation for adding pretty printing.

    • Moved the debug toggle from a build-time constant to a (hidden) CLI flag
    • Implemented pretty-printing logs, togglable via --format pretty CLI option
    • Added stronger typing for tail event messages
  • #525 9d5c14d Thanks @threepointone! - feat: tail+envs

    This implements service environment support for wrangler tail. Fairly simple, we just generate the right URLs. wrangler tail already works for legacy envs, so there's nothing to do there.

  • #553 bc85682 Thanks @threepointone! - feat: disable tunnel in wrangler dev

    Disables sharing local development server on the internet. We will bring this back after it's more polished/ready.

    Fixes #550

  • #522 a283836 Thanks @threepointone! - fix: websockets

    This fixes websockets in wrangler dev. It looks like we broke it in #503. I've reverted the specific changes made to proxy.ts.

    Test plan -

    cd packages/wrangler
    npm run build
    cd ../workers-chat-demo
    npx wrangler dev
    
    
  • #481 8874548 Thanks @threepointone! - fix: replace the word "deploy" with "publish" everywhere.

    We should be consistent with the word that describes how we get a worker to the edge. The command is publish, so let's use that everywhere.

  • #537 b978db4 Thanks @threepointone! - feat: --local mode only applies in wrangler dev

    We'd originally planned for --local mode to be a thing across all wrangler commands. In hindsight, that didn't make much sense, since every command other than wrangler dev assumes some interaction with cloudflare and their API. The only command other than dev where this "worked" was kv, but even that didn't make sense because wrangler dev wouldn't even read from it. We also have --experimental-enable-local-persistence there anyway.

    So this moves the --local flag to only apply for wrangler dev and removes any trace from other commands.

  • #518 72f035e Thanks @threepointone! - feat: implement [text_blobs]

    This implements support for [text_blobs] as defined by cloudflare/wrangler-legacy#1677.

    Text blobs can be defined in service-worker format with configuration in wrangler.toml as -

    [text_blobs]
    MYTEXT = "./path/to/my-text.file"
    

    The content of the file will then be available as the global MYTEXT inside your code. Note that this ONLY makes sense in service-worker format workers (for now).

    Workers Sites now uses [text_blobs] internally. Previously, we were inlining the asset manifest into the worker itself, but we now attach the asset manifest to the uploaded worker. I also added an additional example of Workers Sites with a modules format worker.

  • #532 046b17d Thanks @threepointone! - feat: dev+envs

    This implements service environments + wrangler dev. Fairly simple, it just needed the right url when creating the edge preview token.

    I tested this by publishing a service under one env, adding secrets under it in the dashboard, and then trying to dev under another env, and verifying that the secrets didn't leak.

  • #552 3cee150 Thanks @petebacondarwin! - feat: add confirmation and success messages to kv:bulk delete command

    Added the following:

    • When the deletion completes, we get Success! logged to the console.
    • Before deleting, the user is now asked to confirm is that is desired.
    • A new flag --force/-f to avoid the confirmation check.
  • #533 1b3a5f7 Thanks @threepointone! - feat: default to legacy environments

    While implementing support for service environments, we unearthed a small number of usage issues. While we work those out, we should default to using regular "legacy" environments.

  • #519 93576a8 Thanks @caass! - fix: Improve port selection for wrangler dev for both worker ports and inspector ports.

    Previously when running wrangler dev on multiple workers at the same time, you couldn't attach DevTools to both workers, since they were both listening on port 9229. With this PR, that behavior is improved -- you can now pass an --inspector-port flag to specify a port for DevTools to connect to on a per-worker basis, or if the option is omitted, wrangler will assign a random unused port for you.

    This "if no option is given, assign a random unused port" behavior has also been added to wrangler dev --port, so running wrangler dev on two workers at once should now "just work". Hopefully.

  • #545 9e89dd7 Thanks @threepointone! - feat: zoned worker support for wrangler dev

    This implements support for zoned workers in wrangler dev. Of note, since we're deprecating zone_id, we instead use the domain provided via --host/config.dev.host/--routes/--route/config.routes/config.route and infer the zone id from it.

    Fixes #544

  • #494 6e6c30f Thanks @caass! - - Add tests covering pretty-printing of logs in wrangler tail
    • Modify RequestEvent types
      • Change Date types to number to make parsing easier
      • Change exception and log message properties to unknown
    • Add datetime to pretty-printed request events
  • #496 5a640f0 Thanks @jahands! - chore: Remove acorn/acorn-walk dependency used in Pages Functions filepath-routing.

    This shouldn't cause any functional changes, Pages Functions filepath-routing now uses esbuild to find exports.

  • #419 04f4332 Thanks @Electroid! - refactor: use esbuild's message formatting for cleaner error messages

    This is the first step in making a standard format for error messages. For now, this uses esbuild's error formatting, which is nice and colored, but we could decide to customize our own later. Moreover, we should use the parseJSON, parseTOML, and readFile utilities so there are pretty errors for any configuration.

  • #501 824d8c0 Thanks @petebacondarwin! - refactor: delegate deprecated preview command to dev if possible

    The preview command is deprecated and not supported in this version of Wrangler. Instead, one should use the dev command for most preview use-cases.

    This change attempts to delegate any use of preview to dev failing if the command line contains positional arguments that are not compatible with dev.

    Resolves #9

  • #541 371e6c5 Thanks @threepointone! - chore: refactor some common code into requireAuth()

    There was a common chunk of code across most commands that ensures a user is logged in, and retrieves an account ID. I'd resisted making this into an abstraction for a while. Now that the codebase is stable, and #537 removes some surrounding code there, I made an abstraction for this common code as requireAuth(). This gets a mention in the changelog simply because it touches a bunch of code, although it's mostly mechanical deletion/replacement.

  • #503 e5c7ed8 Thanks @petebacondarwin! - refact: consolidate on ws websocket library

    Removes the faye-websocket library and uses ws across the code base.

  • #502 b30349a Thanks @petebacondarwin! - fix(pages): ensure remaining args passed to pages dev command are captured

    It is common to pass additional commands to pages dev to generate the input source. For example:

    npx wrangler pages dev -- npm run dev

    Previously the args after -- were being dropped. This change ensures that these are captured and used correctly.

    Fixes #482

  • #512 b093df7 Thanks @threepointone! - feat: a better tsconfig.json

    This makes a better tsconfig.json when using wrangler init. Of note, it takes the default tsconfig.json generated by tsc --init, and adds our modifications.

  • #510 9534c7f Thanks @threepointone! - feat: --legacy-env cli arg / legacy_env config

    This is the first of a few changes to codify how we do environments in wrangler2, both older legacy style environments, and newer service environments. Here, we add a cli arg and a config field for specifying whether to enable/disable legacy style environments, and pass it on to dev/publish commands. We also fix how we were generating kv namespaces for Workers Sites, among other smaller fixes.

  • #549 3d2ce01 Thanks @petebacondarwin! - fix: kv:bulk should JSON encode its contents

    The body passed to kv:bulk delete and kv:bulk put must be JSON encoded. This change fixes that and adds some tests to prove it.

    Fixes #547

  • #554 6e5319b Thanks @petebacondarwin! - fix: limit bulk delete API requests to batches of 5,000

    The kv:bulk delete command now batches up delete requests in groups of 5,000, displaying progress for each request.

  • #538 4b6c973 Thanks @threepointone! - feat: with wrangler init, create a new directory for named workers

    Currently, when creating a new project, we usually first have to create a directory before running wrangler init, since it defaults to creating the wrangler.toml, package.json, etc in the current working directory. This fix introduces an enhancement, where using the wrangler init [name] form creates a directory named [name] and initialises the project files inside it. This matches the usage pattern a little better, and still preserves the older behaviour when we're creating a worker inside existing projects.

  • #548 e3cab74 Thanks @petebacondarwin! - refactor: clean up unnecessary async functions

    The readFile() and readConfig() helpers do not need to be async. Doing so just adds complexity to their call sites.

  • #529 9d7e946 Thanks @petebacondarwin! - feat: add more comprehensive config validation checking

    The configuration for a Worker is complicated since we can define different "environments", and each environment can have its own configuration. There is a default ("top-level") environment and then named environments that provide environment specific configuration.

    This is further complicated by the fact that there are three kinds of environment configuration:

    • non-overridable: these values are defined once in the top-level configuration, apply to all environments and cannot be overridden by an environment.
    • inheritable: these values can be defined at the top-level but can also be overridden by environment specific values. Named environments do not need to provide their own values, in which case they inherit the value from the top-level.
    • non-inheritable: these values must be explicitly defined in each environment if they are defined at the top-level. Named environments do not inherit such configuration and must provide their own values.

    All configuration values in wrangler.toml are optional and will receive a default value if not defined.

    This change adds more strict interfaces for top-level Config and Environment types, as well as validation and normalization of the optional fields that are read from wrangler.toml.

  • #486 ff8c9f6 Thanks @threepointone! - fix: remove warning if worker with a durable object doesn't have a name

    We were warning if you were trying to develop a durable object with an unnamed worker. Further, the internal api would actually throw if you tried to develop with a named worker if it wasn't already published. The latter is being fixed internally and should live soon, and this fix removes the warning completely.

0.0.17

Patch Changes

  • #414 f30426f Thanks @petebacondarwin! - fix: support build.upload.dir when using build.upload.main

    Although, build.upload.dir is deprecated, we should still support using it when the entry-point is being defined by the build.upload.main and the format is modules.

    Fixes #413

  • #447 2c5c934 Thanks @threepointone! - fix: Config should be resolved relative to the entrypoint

    During dev and publish, we should resolve wrangler.toml starting from the entrypoint, and then working up from there. Currently, we start from the directory from which we call wrangler, this changes that behaviour to start from the entrypoint instead.

    (To implement this, I made one big change: Inside commands, we now have to explicitly read configuration from a path, instead of expecting it to 'arrive' coerced into a configuration object.)

  • #472 804523a Thanks @JacobMGEvans! - bugfix: Replace .destroy() on faye-websockets with .close() added: Interface to give faye same types as compliant ws with additional .pipe() implementation; .on("message" => fn)
  • #462 a173c80 Thanks @caass! - Add filtering to wrangler tail, so you can now wrangler tail <name> --status ok, for example. Supported options:

    • --status cancelled --status error --> you can filter on ok, error, and cancelled to only tail logs that have that status
    • --header X-CUSTOM-HEADER:somevalue --> you can filter on headers, including ones that have specific values ("somevalue") or just that contain any header (e.g. --header X-CUSTOM-HEADER with no colon)
    • --method POST --method PUT --> filter on the HTTP method used to trigger the worker
    • --search catch-this --> only shows messages that contain the phrase "catch-this". Does not (yet!) support regular expressions
    • --ip self --ip 192.0.2.232 --> only show logs from requests that originate from the given IP addresses. "self" will be replaced with the IP address of the computer that sent the tail request.
  • #471 21cde50 Thanks @caass! - Add tests for wrangler tail:

    • ensure the correct API calls are made
    • ensure that filters are sent
    • ensure that the correct filters are sent
    • ensure that JSON gets spat out into the terminal
  • #398 40d9553 Thanks @threepointone! - feat: guess-worker-format

    This formalises the logic we use to "guess"/infer what a worker's format is - either "modules" or "service worker". Previously we were using the output of the esbuild process metafile to infer this, we now explicitly do so in a separate step (esbuild's so fast that it doesn't have any apparent performance hit, but we also do a simpler form of the build to get this information).

    This also adds --format as a command line arg for publish.

  • #438 64d62be Thanks @Electroid! - feat: Add support for "json" bindings

    Did you know? We have support for "json" bindings! Here are a few examples:

    [vars] text = "plain ol' string" count = 1 complex = { enabled = true, id = 123 }

  • #411 a52f0e0 Thanks @ObsidianMinor! - feat: unsafe-bindings

    Adds support for "unsafe bindings", that is, bindings that aren't supported by wrangler, but are desired when uploading a Worker to Cloudflare. This allows you to use beta features before official support is added to wrangler, while also letting you migrate to proper support for the feature when desired. Note: these bindings may not work everywhere, and may break at any time.

  • #415 d826f5a Thanks @threepointone! - fix: don't crash when browser windows don't open

    We open browser windows for a few things; during wrangler dev, and logging in. There are environments where this doesn't work as expected (like codespaces, stackblitz, etc). This fix simply logs an error instead of breaking the flow. This is the same fix as #263, now applied to the rest of wrangler.

  • 91d8994 Thanks @Mexican-Man! - fix: do not merge routes with different methods when computing pages routes

    Fixes #92

  • #474 bfedc58 Thanks @JacobMGEvans! - bugfix: create reporting.toml file in "wrangler/config" and move error reporting user decisions to new reporting.toml
  • #445 d5935e7 Thanks @threepointone! - chore: remove experimental_services from configuration

    Now that we have [[unsafe.bindings]] (as of #411), we should use that for experimental features. This removes support for [experimental_services], and adds a helpful message for how to rewrite their configuration.

    This error is temporary, until the internal teams that were using this rewrite their configs. We'll remove it before GA.

    What the error looks like -

    Error: The "experimental_services" field is no longer supported. Instead, use [[unsafe.bindings]] to enable experimental features. Add this to your wrangler.toml:
    
    [[unsafe.bindings]]
    name = "SomeService"
    type = "service"
    service = "some-service"
    environment = "staging"
    
    [[unsafe.bindings]]
    name = "SomeOtherService"
    type = "service"
    service = "some-other-service"
    environment = "qa"
    
  • #456 b5f42c5 Thanks @threepointone! - chore: enable strict in tsconfig.json

    In the march towards full strictness, this enables strict in tsconfig.json and fixes the errors it pops up. A changeset is included because there are some subtle code changes, and we should leave a trail for them.

  • #448 b72a111 Thanks @JacobMGEvans! - feat: add --yes with alias --y flag as automatic answer to all prompts and run wrangler init non-interactively. generated during setup:

    • package.json
    • TypeScript, which includes tsconfig.json & @cloudflare/workers-types
    • Template "hello world" Worker at src/index.ts
  • #403 f9fef8f Thanks @JacobMGEvans! - feat: add scripts to package.json & autogenerate name value when initializing a project To get wrangler init projects up and running with good ergonomics for deploying and development, added default scripts "start" & "deploy" with assumed TS or JS files in generated ./src/index. The name property is now derived from user input on init <name> or parent directory if no input is provided.
  • #452 1cf6701 Thanks @petebacondarwin! - feat: add support for publishing workers with r2 bucket bindings

    This change adds the ability to define bindings in your wrangler.toml file for R2 buckets. These buckets will then be available in the environment passed to the worker at runtime.

    Closes #365

  • #458 a8f97e5 Thanks @petebacondarwin! - fix: do not publish to workers.dev if workers_dev is false

    Previously we always published to the workers.dev subdomain, ignoring the workers_dev setting in the wrangler.toml configuration.

    Now we respect this configuration setting, and also disable an current workers.dev subdomain worker when we publish and workers_dev is false.

    Fixes #410

  • #457 b249e6f Thanks @threepointone! - fix: don't report intentional errors

    We shouldn't be reporting intentional errors, only exceptions. This removes reporting for all caught errors for now, until we filter all known errors, and then bring back reporting for unknown errors. We also remove a stray console.warn().

  • #402 5a9bb1d Thanks @JacobMGEvans! - feat: Added Wrangler TOML fields Additional field to get projects ready to publish as soon as possible. It will check if the Worker is named, if not then it defaults to using the parent directory name.
  • #227 97e15f5 Thanks @JacobMGEvans! - feature: Sentry Integration Top level exception logging which will allow to Pre-empt issues, fix bugs faster, Identify uncommon error scenarios, and better quality error information. Context includes of Error in addition to stacktrace Environment: OS/arch node/npm versions wrangler version RewriteFrames relative pathing of stacktrace and will prevent user file system information from being sent.

    Sourcemaps:

    • The sourcemap custom scripts for path matching in Artifact, Sentry Event and Build output is moved to be handled in GH Actions Sentry upload moved after changeset version bump script and npm script to get current version into GH env variable
    • Add org and project to secrets for increased obfuscation of Cloudflare internal ecosystem

    Prompt for Opt-In:

    • When Error is thrown user will be prompted with yes (only sends this time), Always, and No (default). Always and No will be added to default.toml with a datetime property for future update checks.
    • If the property already exists it will skip the prompt.

    Sentry Tests: The tests currently check that the decision flow works as currently set up then checks if Sentry is able to send events or is disabled.

  • #427 bce731a Thanks @petebacondarwin! - refactor: share worker bundling between both publish and dev commands

    This changes moves the code that does the esbuild bundling into a shared file and updates the publish and dev to use it, rather than duplicating the behaviour.

    See #396 Resolves #401

  • #458 c0cfd60 Thanks @petebacondarwin! - fix: pass correct query param when uploading a script

    In f9c1423f0c5b6008f05b9657c9b84eb6f173563a the query param was incorrectly changed from available_on_subdomain to available_on_subdomains.

  • #432 78acd24 Thanks @threepointone! - feat: import .wasm modules in service worker format workers

    This allows importing .wasm modules in service worker format workers. We do this by hijacking imports to .wasm modules, and instead registering them under [wasm_modules] (building on the work from #409).

  • #409 f8bb523 Thanks @threepointone! - feat: support [wasm_modules] for service-worker format workers

    This lands support for [wasm_modules] as defined by cloudflare/wrangler-legacy#1677.

    wasm modules can be defined in service-worker format with configuration in wrangler.toml as -

    [wasm_modules]
    MYWASM = "./path/to/my-wasm.wasm"
    

    The module will then be available as the global MYWASM inside your code. Note that this ONLY makes sense in service-worker format workers (for now).

    (In the future, we MAY enable wasm module imports in service-worker format (i.e. import MYWASM from './path/to/my-wasm.wasm') and global imports inside modules format workers.)

  • #423 dd9058d Thanks @petebacondarwin! - feat: add support for managing R2 buckets

    This change introduces three new commands, which manage buckets under the current account:

    • r2 buckets list: list information about all the buckets.
    • r2 buckets create: create a new bucket - will error if the bucket already exists.
    • r2 buckets delete: delete a bucket.

    This brings Wrangler 2 inline with the same features in Wrangler 1.

  • #455 80aa106 Thanks @threepointone! - fix: error when entry doesn't exist

    This adds an error when we use an entry point that doesn't exist, either for wrangler dev or wrangler publish, and either via cli arg or build.upload.main in wrangler.toml. By using a common abstraction for dev and publish, This also adds support for using build.config.main/build.config.dir for wrangler dev.

0.0.16

Patch Changes

  • #364 3575892 Thanks @threepointone! - enhance: small tweaks to wrangler init

    • A slightly better package.json
    • A slightly better tsconfig.json
    • installing typescript as a dev dependency
  • #380 aacd1c2 Thanks @GregBrimble! - fix: ensure pages routes are defined correctly

    In e151223 we introduced a bug where the RouteKey was now an array rather than a simple URL string. When it got stringified into the routing object these were invalid. E.g. [':page*', undefined] got stringified to ":page*," rather than ":page*".

    Fixes #379

  • #329 27a1f3b Thanks @petebacondarwin! - ci: run PR jobs on both Ubuntu, MacOS and Windows

    • update .gitattributes to be consistent on Windows
    • update Prettier command to ignore unknown files Windows seems to be more brittle here.
    • tighten up eslint config Windows seems to be more brittle here as well.
    • use the matrix.os value in the cache key Previously we were using running.os but this appeared not to be working.
  • #347 ede5b22 Thanks @threepointone! - fix: hide wrangler pages functions in the main help menu

    This hides wrangler pages functions in the main help menu, since it's only intended for internal usage right now. It still "works", so nothing changes in that regard. We'll bring this back when we have a broader story in wrangler for functions.

  • #360 f590943 Thanks @threepointone! - fix: kv:key get

    The api for fetching a kv value, unlike every other cloudflare api, returns just the raw value as a string (as opposed to the FetchResult-style json). However, our fetch utility tries to convert every api response to json before parsing it further. This leads to bugs like #359. The fix is to special case for kv:key get.

    Fixes #359.

  • #373 6e7baf2 Thanks @petebacondarwin! - fix: use the appropriate package manager when initializing a wrangler project

    Previously, when we initialized a project using wrangler init, we always used npm as the package manager.

    Now we check to see whether npm and yarn are actually installed, and also whether there is already a lock file in place before choosing which package manager to use.

    Fixes #353

  • #363 0add2a6 Thanks @threepointone! - fix: support uppercase hotkeys in wrangler dev

    Just a quick fix to accept uppercase hotkeys during dev.

  • #331 e151223 Thanks @petebacondarwin! - fix: generate valid URL route paths for pages on Windows

    Previously route paths were manipulated by file-system path utilities. On Windows this resulted in URLs that had backslashes, which are invalid for such URLs.

    Fixes #51 Closes #235 Closes #330 Closes #327

  • #338 e0d2f35 Thanks @threepointone! - feat: environments for Worker Sites

    This adds environments support for Workers Sites. Very simply, it uses a separate kv namespace that's indexed by the environment name. This PR also changes the name of the kv namespace generated to match wrangler 1's implementation.

  • #329 e1d2198 Thanks @petebacondarwin! - test: support testing in CI on Windows

    • Don't rely on bash variables to configure tests The use of bash variables in the npm test script is not supported in Windows Powershell, causing CI on Windows to fail. These bash variables are used to override the API token and the Account ID.

      This change moves the control of mocking these two concepts into the test code, by adding mockAccountId() and mockApiToken() helpers.

      • The result is slightly more boilerplate in tests that need to avoid hitting the auth APIs.
      • But there are other tests that had to revert these environment variables. So the boilerplate is reduced there.
    • Sanitize command line for snapshot tests This change applies normalizeSlashes() and trimTimings() to command line outputs and error messages to avoid inconsistencies in snapshots. The benefit here is that authors do not need to keep adding them to all their snapshot tests.

    • Move all the helper functions into their own directory to keep the test directory cleaner.

  • #343 cfd8ba5 Thanks @threepointone! - chore: update esbuild

    Update esbuild to 0.14.14. Also had to change import esbuild from "esbuild"; to import * as esbuild from "esbuild"; in dev.tsx.

  • #371 85ceb84 Thanks @nrgnrg! - fix: pages advanced mode usage

    Previously in pages projects using advanced mode (a single _worker.js or --script-path file rather than a ./functions folder), calling pages dev would quit without an error and not launch miniflare.

    This change fixes that and enables pages dev to be used with pages projects in advanced mode.

  • #383 969c887 Thanks @threepointone! - fix: remove redundant process.cwd() calls in wrangler init

    Followup from #372 (comment), just removing some unnecessary calls to process.cwd()/path.join(), since they're already relative to where they're called from.

  • #329 ac168f4 Thanks @petebacondarwin! - refactor: use helpers to manage npm commands

    This change speeds up tests and avoids us checking that npm did what it is supposed to do.

  • #348 b8e3b01 Thanks @threepointone! - chore: replace node-fetch with undici

    There are several reasons to replace node-fetch with undici:

    • undici's fetch() implementation is set to become node's standard fetch() implementation, which means we can just remove the dependency in the future (or optionally load it depending on which version of node is being used)
    • node-fetch pollutes the global type space with a number of standard types
    • we already bundle undici via miniflare/pages, so this means our bundle size could ostensibly become smaller.

    This replaces node-fetch with undici.

    • All instances of import fetch from "node-fetch" are replaced with import {fetch} from "undici"
    • undici also comes with spec compliant forms of FormData and File, so we could also remove formdata-node in form_data.ts
    • All the global types that were injected by node-fetch are now imported from undici (as well as some mistaken ones from node:url)
    • NOTE: this also turns on skipLibCheck in tsconfig.json. Some dependencies oddly depend on browser globals like Request, Response (like @miniflare/core, jest-fetch-mock, etc), which now fail because node-fetch isn't injecting those globals anymore. So we enable skipLibCheck to bypass them. (I'd thought skipLibCheck completely ignores 'third party' types, but that's not true - it still uses the module graph to scan types. So we're still typesafe. We should enable strict sometime to avoid anys, but that's for later.)
    • The bundle size isn't smaller because we're bundling 2 different versions of undici, but we'll fix that by separately upping the version of undici that miniflare bundles.
  • #357 41cfbc3 Thanks @threepointone! - chore: add eslint-plugin-import

    • This adds eslint-plugin-import to enforce ordering of imports, and configuration for the same in package.json.
    • I also run npm run check:lint -- --fix to apply the configured order in our whole codebase.
    • This also needs a setting in .vscode/settings.json to prevent spurious warnings inside vscode. You'll probably have to restart your IDE for this to take effect. (re: import-js/eslint-plugin-import#2377 (comment))

    (I'd also like to enforce using node: prefixes for node builtin modules, but that can happen later. For now I manually added the prefixes wherever they were missing. It's not functionally any different, but imo it helps the visual grouping.)

  • #372 05dbb0d Thanks @threepointone! - feat: wrangler init offers to create a starter worker

    We got feedback that wrangler init felt incomplete, because the immediate next thing folks need is a starter source file. So this adds another step to wrangler init where we offer to create that file for you.

    Fixes #355

  • #384 8452485 Thanks @petebacondarwin! - refactor: use xxhash-wasm for better compatibility with Windows

    The previous xxhash package we were using required a build step, which relied upon tooling that was not always available on Window.

    This version is a portable WASM package.

  • #334 536c7e5 Thanks @threepointone! - feat: wasm support for local mode in wrangler dev

    This adds support for *.wasm modules into local mode for wrangler dev.

    In 'edge' mode, we create a javascript bundle, but wasm modules are uploaded to the preview server directly when making the worker definition form upload. However, in 'local' mode, we need to have the actual modules available to the bundle. So we copy the files over to the bundle path. We also pass appropriate --modules-rule directive to miniflare.

    I also added a sample wasm app to use for testing, created from a default workers-rs project.

    Fixes #299

  • #329 b8a3e78 Thanks @petebacondarwin! - ci: use npm ci and do not cache workspace packages in node_modules

    Previously we were caching all the node_modules files in the CI jobs and then running npm install. While this resulted in slightly improved install times on Ubuntu, it breaks on Windows because the npm workspace setup adds symlinks into node_modules, which the Github cache action cannot cope with.

    This change removes the node_modules caches (saving some time by not needing to restore them) and replaces npm install with npm ci.

    The npm ci command is actually designed to be used in CI jobs as it only installs the exact versions specified in the package-lock.json file, guaranteeing that for any commit we always have exactly the same CI job run, deterministically.

    It turns out that, on Ubuntu, using npm ci makes very little difference to the installation time (~30 secs), especially if there is no node_modules there in the first place.

    Unfortunately, MacOS is slower (~1 min), and Windows even worse (~2 mins)! But it is worth this longer CI run to be sure we have things working on all OSes.

0.0.15

Patch Changes

  • #333 6320a32 Thanks @threepointone! - fix: pass worker name to syncAssets in dev

    This fix passes the correct worker name to syncAssets during wrangler dev. This function uses the name to create the backing kv store for a Workers Sites definition, so it's important we get the name right.

    I also fixed the lint warning introduced in #321, to pass props.enableLocalPersistence as a dependency in the useEffect call that starts the "local" mode dev server.

  • #335 a417cb0 Thanks @threepointone! - fix: prevent infinite loop when fetching a list of results

    When fetching a list of results from cloudflare APIs (e.g. when fetching a list of keys in a kv namespace), the api returns a cursor that a consumer should use to get the next 'page' of results. It appears this cursor can also be a blank string (while we'd only account for it to be undefined). By only accounting for it to be undefined, we were infinitely looping through the same page of results and never terminating. This PR fixes it by letting it be a blank string (and null, for good measure)

  • #332 a2155c1 Thanks @threepointone! - fix: wait for port to be available before creating a dev server

    When we run wrangler dev, we start a server on a port (defaulting to 8787). We do this separately for both local and edge modes. However, when switching between the two with the l hotkey, we don't 'wait' for the previous server to stop before starting the next one. This can crash the process, and we don't want that (of course). So we introduce a helper function waitForPortToBeAvailable() that waits for a port to be available before returning. This is used in both the local and edge modes, and prevents the bug right now, where switching between edge - local - edge crashes the process.

    (This isn't a complete fix, and we can still cause errors by very rapidly switching between the two modes. A proper long term fix for the future would probably be to hoist the proxy server hook above the <Remote/> and <Local/> components, and use a single instance throughout. But that requires a deeper refactor, and isn't critical at the moment.)

  • #336 ce61000 Thanks @threepointone! - feat: inline text-like files into the worker bundle

    We were adding text-like modules (i.e. .txt, .html and .pem files) as separate modules in the Worker definition, but this only really 'works' with the ES module Worker format. This commit changes that to inline the text-like files into the Worker bundle directly.

    We still have to do something similar with .wasm modules, but that requires a different fix, and we'll do so in a subsequent commit.

  • #336 ce61000 Thanks @threepointone! - feat: Sites support for local mode wrangler dev

    This adds support for Workers Sites in local mode when running wrangler dev. Further, it fixes a bug where we were sending the __STATIC_CONTENT_MANIFEST definition as a separate module even with service worker format, and a bug where we weren't uploading the namespace binding when other kv namespaces weren't present.

0.0.14

Patch Changes

  • #307 53c6318 Thanks @threepointone! - feat: wrangler secret * --local

    This PR implements wrangler secret for --local mode. The implementation is simply a no-op, since we don't want to actually write secret values to disk (I think?). I also got the messaging for remote mode right by copying from wrangler 1. Further, I added tests for all the wrangler secret commands.

  • #324 b816333 Thanks @GregBrimble! - Fixes wrangler pages dev failing to start for just a folder of static assets (no functions)
  • #317 d6ef61a Thanks @threepointone! - fix: restart the dev proxy server whenever it closes

    When we run wrangler dev, the session that we setup with the preview endpoint doesn't last forever, it dies after ignoring it for 5-15 minutes or so. The fix for this is to simply reconnect the server. So we use a state hook as a sigil, and add it to the dependency array of the effect that sets up the server, and simply change it every time the server closes.

    Fixes #197

    (In wrangler1, we used to restart the whole process, including uploading the worker again, making a new preview token, and so on. It looks like that they may not have been necessary.)

  • #312 77aa324 Thanks @threepointone! - fix: remove --prefer-offline when running npm install

    We were using --prefer-offline when running npm install during wrangler init. The behaviour is odd, it doesn't seem to fetch from the remote when the cache isn't hit, which is not what I'm expecting. So we remove --prefer-offline.

  • #311 a5537f1 Thanks @threepointone! - fix: custom builds should allow multiple commands

    We were running custom builds as a regular command with execa. This would fail whenever we tried to run compound commands like cargo install -q worker-build && worker-build --release (via #236). The fix is to use shell: true, so that the command is run in a shell and can thus use bash-y syntax like &&, and so on. I also switched to using execaCommand which splits a command string into parts correctly by itself.

  • #321 5b64a59 Thanks @geelen! - fix: disable local persistence by default & add --experimental-enable-local-persistence flag

    BREAKING CHANGE:

    When running dev locally any data stored in KV, Durable Objects or the cache are no longer persisted between sessions by default.

    To turn this back on add the --experimental-enable-local-persistence at the command line.

0.0.13

Patch Changes

  • #293 71b0fab Thanks @petebacondarwin! - fix: warn if the site.entry-point configuration is found during publishing

    Also updates the message and adds a test for the error when there is no entry-point specified.

    Fixes #282

  • #304 7477b52 Thanks @threepointone! - feat: enhance wrangler init

    This PR adds some enhancements/fixes to the wrangler init command.

    • doesn't overwrite wrangler.toml if it already exists
    • installs wrangler when creating package.json
    • offers to install wrangler into package.json even if package.json already exists
    • offers to install @cloudflare/workers-types even if tsconfig.json already exists
    • pipes stdio back to the terminal so there's feedback when it's installing npm packages

    This does have the side effect of making out tests slower. I added --prefer-offline to the npm install calls to make this a shade quicker, but I can't figure out a good way of mocking these. I'll think about it some more later. We should work on making the installs themselves quicker (re: #66)

    This PR also fixes a bug with our tests - runWrangler would catch thrown errors, and if we didn't manually verify the error, tests would pass. Instead, it now throws correctly, and I modified all the tests to assert on thrown errors. It seems like a lot, but it was just mechanical rewriting.

  • #294 7746fba Thanks @threepointone! - feature: add more types that get logged via console methods

    This PR adds more special logic for some data types that get logged via console methods. Types like Promise, Date, WeakMaps, and some more, now get logged correctly (or at least, better than they used to).

    This PR also fixes a sinister bug - the type of the ConsoleAPICalled events don't match 1:1 with actual console methods (eg: console.warn message type is warning). This PR adds a mapping between those types and method names. Some methods don't seem to have a message type, I'm not sure why, but we'll get to them later.

  • #310 52c99ee Thanks @threepointone! - feat: error if a site definition doesn't have a bucket field

    This adds an assertion error for making sure a [site] definition always has a bucket field.As a cleanup, I made some small fixes to the Config type definition, and modified the tests in publish.test.ts to use the config format when creating a wrangler.toml file.

0.0.12

Patch Changes

  • #292 e5d3690 Thanks @threepointone! - fix: use entrypoint specified in esbuuild's metafile as source for building the worker

    When we pass a non-js file as entry to esbuild, it generates a .js file. (which, is the whole job of esbuild, haha). So, given <source>/index.ts, it'll generate <destination>/index.js. However, when we try to 'find' the matching file to pass on as an input to creating the actual worker, we try to use the original file name inside the destination directory. At this point, the extension has changed, so it doesn't find the file, and hence we get the error that looks like ENOENT: no such file or directory, open '/var/folders/3f/fwp6mt7n13bfnkd5vl3jmh1w0000gp/T/tmp-61545-4Y5kwyNI8DGU/src/worker.ts'

    The actual path to the destination file is actually the key of the block in metafile.outputs that matches the given output.entryPoint, so this PR simply rewrites the logic to use that instead.

  • #287 b63efe6 Thanks @threepointone! - fix: propagate api errors to the terminal correctly

    Any errors embedded in the response from the Cloudflare API were being lost, because fetchInternal() would throw on a non-200 response. This PR fixes that behaviour:

    • It doesn't throw on non-200 responses
    • It first gets the response text with .text() and converts it to an object with JSON.parse, so in case the api returns a non json response, we don't lose response we were sent.

    Unfortunately, because of the nature of this abstraction, we do lose the response status code and statusText, but maybe that's acceptable since we have richer error information in the payload. I considered logging the code and text to the terminal, but that may make it noisy.

0.0.11

Patch Changes

  • #267 e22f9d7 Thanks @petebacondarwin! - refactor: tidy up the typings of the build result in dev

    In #262 some of the strict null fixes were removed to resolve a regression. This refactor re-applies these fixes in a way that avoids that problem.

  • #270 0289882 Thanks @petebacondarwin! - fix: ensure kv:key list matches the output from Wrangler 1

    The previous output was passing an array of objects to console.log, which ended up showing something like

    [Object object]
    [Object object]
    ...
    

    Now the result is JSON stringified before being sent to the console. The tests have been fixed to check this too.

  • #258 f9c1423 Thanks @petebacondarwin! - fix: correctly handle entry-point path when publishing

    The publish command was failing when the entry-point was specified in the wrangler.toml file and the entry-point imported another file.

    This was because we were using the metafile.inputs to guess the entry-point file path. But the order in which the source-files were added to this object was not well defined, and so we could end up failing to find a match.

    This fix avoids this by using the fact that the metadata.outputs object will only contain one element that has the entrypoint property - and then using that as the entry-point path. For runtime safety, we now assert that there cannot be zero or multiple such elements.

  • #275 e9ab55a Thanks @petebacondarwin! - feat: add a link to create a github issue when there is an error.

    When a (non-yargs) error surfaces to the top level, we know also show a link to Github to encourage the developer to report an issue.

  • #286 b661dd0 Thanks @dependabot! - chore: Update node-fetch to 3.1.1, run npm audit fix in root

    This commit addresses a secutity issue in node-fetch and updates it to 3.1.1. I also ran npm audit fix in the root directory to address a similar issue with @changesets/get-github-info.

  • #249 9769bc3 Thanks @petebacondarwin! - Do not crash when processing environment configuration.

    Previously there were corner cases where the configuration might just crash. These are now handled more cleanly with more appropriate warnings.

  • #272 5fcef05 Thanks @petebacondarwin! - refactor: enable TypeScript strict-null checks

    The codebase is now strict-null compliant and the CI checks will fail if a PR tries to introduce code that is not.

  • #277 6cc9dde Thanks @petebacondarwin! - fix: align publishing sites asset keys with Wrangler 1

    • Use the same hashing strategy for asset keys (xxhash64)
    • Include the full path (from cwd) in the asset key
    • Match include and exclude patterns against full path (from cwd)
    • Validate that the asset key is not over 512 bytes long
  • #270 522d1a6 Thanks @petebacondarwin! - fix: check actual asset file size, not base64 encoded size

    Previously we were checking whether the base64 encoded size of an asset was too large (>25MiB). But base64 takes up more space than a normal file, so this was too aggressive.

  • #263 402c77d Thanks @jkriss! - fix: appropriately fail silently when the open browser command doesn't work
  • #280 f19dde1 Thanks @petebacondarwin! - fix: skip unwanted files and directories when publishing site assets

    In keeping with Wrangler 1, we now skip node_modules and hidden files and directories.

    An exception is made for .well-known. See https://datatracker.ietf.org/doc/html/rfc8615.

    The tests also prove that the asset uploader will walk directories in general.

  • #258 ba6fc9c Thanks @petebacondarwin! - chore: add test-watch script to the wrangler workspace

    Watch the files in the wrangler workspace, and run the tests when anything changes:

    > npm run test-watch -w wrangler

    This will also run all the tests in a single process (rather than in parallel shards) and will increase the test-timeout to 50 seconds, which is helpful when debugging.

0.0.10

Patch Changes

0.0.9

Patch Changes

  • #238 65f9904 Thanks @threepointone! - refactor: simplify and document config.ts

    This PR cleans up the type definition for the configuration object, as well as commenting the hell out of it. There are no duplicate definitions, and I annotated what I could.

    • @optional means providing a value isn't mandatory
    • @deprecated means the field itself isn't necessary anymore in wrangler.toml
    • @breaking means the deprecation/optionality is a breaking change from wrangler 1
    • @todo means there's more work to be done (with details attached)
    • @inherited means the field is copied to all environments
  • #257 00e51cd Thanks @threepointone! - fix: description for kv:bulk delete <filename>

    The description for the kv:bulk delete command was wrong, it was probably copied earlier from the kv:bulk put command. This PR fixes the mistake.

  • #262 7494cf7 Thanks @threepointone! - fix: fix dev and publish

    We introduced some bugs in recent PRs

    • In #196, we broke being able to pass an entrypoint directly to the cli. In this PR, I just reverted that fix. I'll reopen #78 and we'll tackle it again later. (cc @jgentes)
    • In #215, we broke being able to publish a script by just passing --latest or --compatibility-data in the cli. This PR fixes that by reading the correct argument when choosing whether to publish.
    • In #247, we broke how we made requests by passing headers to requests. This PR reverts the changes made in cfetch/internal.ts. (cc @petebacondarwin)
    • In #244, we broke dev and it would immediately crash. This PR fixes the reference in dev.tsx that was breaking. (cc @petebacondarwin)

0.0.8

Patch Changes

  • #231 18f8f65 Thanks @threepointone! - refactor: proxy/preview server

    This PR refactors how we setup the proxy server between the developer and the edge preview service during wrangler dev. Of note, we start the server immediately. We also buffer requests/streams and hold on to them, when starting/refreshing the token. This means a developer should never see ERR_CONNECTION_REFUSED error page, or have an older worker respond after making a change to the code. And when the token does get refreshed, we flush said streams/requests with the newer values, making the iteration process a lot smoother and predictable.

  • #208 fe4b099 Thanks @petebacondarwin! - Remove explicit any types from the codebase

    This change removes all use of any from the code and updates the no-explicit-any eslint rule to be an error.

  • #223 a979d55 Thanks @GregBrimble! - Add ability to compile a directory other than functions for wrangler pages functions build.
  • #196 fc112d7 Thanks @jgentes! - allow specifying only "index" without extension or nothing at all for "wrangler dev" and "wrangler publish"
  • #211 3bbfd4f Thanks @GregBrimble! - Silently fail to auto-open the browser in wrangler pages dev command when that errors out.
  • #189 2f7e1b2 Thanks @petebacondarwin! - Refactor raw value extraction from Cloudflare APIs

    Most API responses are JSON of the form:

    { result, success, errors, messages, result_info }
    

    where the result contains the actual response value.

    But some API responses only contain the result value.

    This change refactors the client-side fetch API to allow callers to specify what kind of response they expect.

  • #215 41d4c3e Thanks @threepointone! - Add --compatibility-date, --compatibility-flags, --latest cli arguments to dev and publish.

    • A cli arg for adding a compatibility data, e.g --compatibility_date 2022-01-05
    • A shorthand --latest that sets compatibility_date to today's date. Usage of this flag logs a warning.
    • latest is NOT a config field in wrangler.toml.
    • In dev, when a compatibility date is not available in either wrangler.toml or as a cli arg, then we default to --latest.
    • In publish we error if a compatibility date is not available in either wrangler.toml or as a cli arg. Usage of --latest logs a warning.
    • We also accept compatibility flags via the cli, e.g: --compatibility-flags formdata_parser_supports_files
  • #210 d381fed Thanks @GregBrimble! - Expose wrangler pages functions build command, which takes the functions folder and compiles it into a single Worker.

    This was already done in wrangler pages dev, so this change just exposes this build command for use in our build image, or for people who want to do it themselves.

  • #213 5e1222a Thanks @GregBrimble! - Adds support for building a Worker from a folder of functions which isn't tied to the Pages platform.

    This lets developers use the same file-based routing system an simplified syntax when developing their own Workers!

  • #199 d9ecb70 Thanks @threepointone! - Refactor inspection/debugging code -

    • I've installed devtools-protocol, a convenient package that has the static types for the devtools protocol (duh) autogenerated from chrome's devtools codebase.
    • We now log messages and exceptions into the terminal directly, so you don't have to open devtools to see those messages.
    • Messages are now buffered until a devtools instance connects, so you won't lose any messages while devtools isn't connected.
    • We don't lose the connection on making changes to the worker, removing the need for the kludgy hack on the devtools side (where we refresh the whole page when there's a change)
  • #189 2f7e1b2 Thanks @petebacondarwin! - Fix pagination handling of list requests to the Cloudflare API

    When doing a list request to the API, the server may respond with only a single page of results. In this case, it will also provide a cursor value in the result_info part of the response, which can be used to request the next page. This change implements this on the client-side so that we get all the results by requesting further pages when there is a cursor.

  • #220 6fc2276 Thanks @GregBrimble! - Add --live-reload option to wrangler pages dev which automatically reloads HTML pages when a change is detected
  • #223 a979d55 Thanks @GregBrimble! - Add --output-config-path option to wrangler pages functions build which writes a config file describing the functions folder.

0.0.7

Patch Changes

  • 1fdcfe3: Subfolder Relative Pathing Fix issue #147 The filename from args didn't handle relative paths passed in from users with scripts in subfolders. To handle the subfolder pathing a path.relative using cwd() to user input filepath to the filepath variable passed into Dev

  • 0330ecf: Adds the Content-Type header when serving assets with wrangler pages dev. It guesses the mime-type based on the asset's file extension.

  • eaf40e8: Improve the error message for bad kv:namespace delete commands

  • 562d3ad: chore: enable eslint's no-shadow rule

  • 9cef492: Adds the logic of @cloudflare/pages-functions-compiler directly into wrangler. This generates a Worker from a folder of functions.

    Also adds support for sourcemaps and automatically watching dependents to trigger a re-build.

  • 3426c13: fix: prevent useWorker's inifinite restarts during dev

  • e9a1820: Upgrade miniflare to 2.0.0-rc.5

  • 7156e39: Pass bindings correctly to miniflare/child_process.spawn in dev, to prevent miniflare from erroring out on startup

  • ce2d7d1: Add experimental support for worker-to-worker service bindings. This introduces a new field in configuration experimental_services, and serialises it when creating and uploading a worker definition. This is highly experimental, and doesn't work with wrangler dev yet.

  • 072566f: Fixed KV getNamespaceId preview flag bug

  • 5856807: Improve validation message for kv:namespace create

    Previously, if the user passed multiple positional arguments (which is invalid) the error message would suggest that these should be grouped in quotes. But this is also wrong, since a namespace binding name must not contain spaces.

  • 34ad323: Refactor the way we convert configurations for bindings all the way through to the API where we upload a worker definition. This commit preserves the configuration structure (mostly) until the point we serialise it for the API. This prevents the way we use duck typing to detect a binding type when uploading, makes the types a bit simpler, and makes it easier to add other types of bindings in the future (notably, the upcoming service bindings.)

0.0.6

Patch Changes

  • 421f2e4: Update base version to 0.0.5, copy the README to packages/wrangler

0.0.5

Patch Changes

  • cea27fe: don't log file contents when writing via kv:key put <key> --path <path>

  • b53cbc8: CI/CD

    • Release flow triggered on PR's closed
  • 43e7a82: When using wrangler pages dev, enable source maps and log unhandled rejections

  • c716abc: Error and exit if the --type option is used for the init command.

    The --type option is no longer needed, nor supported.

    The type of a project is implicitly javascript, even if it includes a wasm (e.g. built from rust).

    Projects that would have had the webpack type need to be configured separately to have a custom build.

  • 3752acf: Add support for websockets in dev, i.e. when developing workers. This replaces the proxy layer that we use to connect to the 'edge' during preview mode, using the faye-wesocket library.

  • c7bee70: Patches typing mismatches between us, undici and miniflare when proxying requests in pages dev, and also adds fallback 404 behavior which was missed

  • 8b6c2d1: Add more fields to the tsconfig.json generated by wrangler init

  • 78cd080: Custom builds for dev and publish

  • cd05d20: import text file types into workers

  • 1216fc9: Export regular functions from dialog.ts, pass tests (followup from #124)

  • 6fc4c50: Display error message when unknown command is provided to the wrangler CLI.

  • 23543fe: Allow the developer to exit init if there is already a toml file

  • 1df6b0c: enable @typescript-eslint/no-floating-promises, pass lint+type check

  • 3c5725f: CI/CD Cleanup

    • Removed the build step from tests, which should speed up the "Tests" Workflow.
    • Added a branch specific trigger for "Release", now the Workflow for "Release" should only work on PRs closed to main
    • Removed the "Changeset PR" Workflow. Now the "Release" Workflow will handle everything needed for Changesets.
  • fb0eae7: support importing .wasm files / workers-rs support

  • e928f94: Improve support for package exports conditionals, including "worker" condition

  • 43e7a82: Upgrade miniflare to 2.0.0-rc.4

  • f473942: Replaces the static asset server with a more faithful simulation of what happens with a production Pages project.

    Also improves error handling and automatically opens the browser when running wrangler pages dev.

0.0.0

Minor Changes

  • 689cd55: CI/CD Improvements

    Changeset

    Adding configuration allows for use of CLI for changesets. A necessary supplement to the changesets bot, and GitHub Action.

    • Installed Changeset CLI tool
    • NPX changeset init
      • Added changesets directory
      • Config
      • README
    • Modified the config for main branch instead of master

    ESLint & Prettier Integration

    Running Prettier as a rule through ESLint to improve CI/CD usage

    • Added additional TypeScript support for ESLint
    • Prettier errors as ESLint rule
    • .vscode directory w/ settings.json config added that enforces the usage of ESLint by anyone working in the workspace

Patch Changes

  • b0fcc7d: CI/CD Tests & Type Checking GH Workflow additions:

    • Added Testing script
    • Added Linting script
    • tsc is using skipLibCheck as a current workaround
      • TODO added for future removal
    • Runs on every Pull Request instance
    • Removed npm ci in favor of npm install
      • Removed --prefer-offline in favor of local cache artifact
  • 2f760f5: remove --polyfill-node

  • fd53780: kv:key put: make only one of value or --path <path> necessary

  • dc41476: Added optional shortcuts

  • 7858ca2: Removed NPM registry and timeout from CI

  • 85b5020: Make wrangler dev work with durable objects