Skip to content

Releases: cloudflare/workers-sdk

wrangler@0.0.27

25 Apr 11:09
61b752c
Compare
Choose a tag to compare

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

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

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

wrangler@0.0.26

16 Apr 01:10
1e4fb70
Compare
Choose a tag to compare

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

  • #797 67fc4fc Thanks @threepointone! - feat: optionally send zone_name with routes

    A followup to #778, this lets you send an optional zone_name with routes. This is particularly useful when using ssl for saas (https://developers.cloudflare.com/ssl/ssl-for-saas/).

    Fixes #793

  • #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)

jest-environment-wrangler@0.0.26

16 Apr 01:10
1e4fb70
Compare
Choose a tag to compare
jest-environment-wrangler@0.0.26

wrangler@0.0.25

09 Apr 12:28
Compare
Choose a tag to compare

Patch Changes

  • #752 6d43e94 Thanks @petebacondarwin! - fix: add a warning if dev is defaulting to the latest compatibility-date

    Fixes #741

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

  • #699 ea8e701 Thanks @JacobMGEvans! - polish: added logout and login to helpstring message.

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

  • #750 b933641 Thanks @mrbbot! - Upgrade miniflare to 2.4.0

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

  • #757 13e57cd Thanks @sidharthachatterjee! - feature: Add wrangler pages project list

    Adds a new command to list your projects in Cloudflare Pages.

  • #745 6bc3e85 Thanks @petebacondarwin! - feat: add hotkey to clear the console in wrangler dev

    Closes #388

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

  • #753 cf432ac Thanks @petebacondarwin! - fix: distinguish the command hotkeys in wrangler dev

    Closes #354

  • #746 3e25dcb Thanks @petebacondarwin! - fix: remove superfluous debugger log messages from local dev

    Closes #387

  • #758 9bd95ce Thanks @sidharthachatterjee! - feature: Add wrangler pages deployment list

    Renders a list of deployments in a Cloudflare Pages project

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

Read more

jest-environment-wrangler@0.0.24

09 Apr 12:28
Compare
Choose a tag to compare

Patch Changes

  • #750 b933641 Thanks @mrbbot! - Upgrade miniflare to 2.4.0

  • #715 9857fbf Thanks @threepointone! - feat: jest-environment-wrangler

    A starting point for a jest environment powered by wrangler. This is just a proxy for jest-environment-miniflare right now, but we'll add features as we go along.

wrangler@0.0.24

28 Mar 15:24
754f6c6
Compare
Choose a tag to compare

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

  • #711 3dac1da Thanks @threepointone! - fix: default wrangler tail to pretty print

    Fixes #707

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

Read more

wrangler@0.0.23

23 Mar 06:40
b7e2135
Compare
Choose a tag to compare

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

  • #650 d3d1ff8 Thanks @petebacondarwin! - feat: make main an inheritable environment field

    See #588

  • #650 f0eed7f Thanks @petebacondarwin! - fix: make validation error messages more consistent

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

  • #667 e29a241 Thanks @threepointone! - fix: delete unused [site] assets

    We discovered critical issues with the way we expire unused assets with [site] (see #666, cloudflare/wrangler-legacy#2224), that we're going back to the legacy manner of handling unused assets, i.e- deleting unused assets.

    Fixes #666

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

wrangler@0.0.22

21 Mar 15:20
Compare
Choose a tag to compare

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

wrangler@0.0.21

21 Mar 07:38
Compare
Choose a tag to compare

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

wrangler@0.0.19

09 Mar 06:40
998a6a1
Compare
Choose a tag to compare

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.