Releases: cloudflare/workers-sdk
[email protected]
Patch Changes
-
#926
7b38a7c
Thanks @threepointone! - polish: show paths of created files withwrangler init
This patch modifies the terminal when running
wrangler init
, to show the proper paths of files created during it (likepackage.json
,tsconfig.json
, etc etc). It also fixes a bug where we weren't detecting the existence ofsrc/index.js
for a named worker before asking to create it.
[email protected]
Patch Changes
-
#924
3bdba63
Thanks @threepointone! - fix: withwrangler init
, test for existence ofpackage.json
/tsconfig.json
/.git
in the right locationsWhen running
wrangler.init
, we look for the existence ofpackage.json
, /tsconfig.json
/.git
when deciding whether we should create them ourselves or not. Becausename
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.
[email protected]
Patch Changes
-
#922
e2f9bb2
Thanks @threepointone! - feat: offer to create a git repo when callingwrangler init
Worker projects created by
wrangler init
should also be managed by source control (popularly, git). This patch adds a choice inwrangler init
to make the created project into a git repository.Additionally, this fixes a bug in our tests where mocked
confirm()
andprompt()
calls were leaking between tests.Closes #847
[email protected]
Patch Changes
-
#916
4ef5fbb
Thanks @petebacondarwin! - fix: display and error and help forwrangler 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 forwrangler 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 nullSometime 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
ondev
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. -
#916
4ef5fbb
Thanks @petebacondarwin! - fix: add some space after the CLI help message when there is an error -
#920
57cf221
Thanks @threepointone! - chore: don't minify bundlesWhen 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.
-
#916
4ef5fbb
Thanks @petebacondarwin! - fix: update thegenerate
command to provide better deprecation messaging -
#914
9903526
Thanks @sidharthachatterjee! - fix: Ensure getting git branch doesn't fail on Windows -
#917
94d3d6d
Thanks @GregBrimble! - fix: Hit correct endpoint for 'wrangler pages publish' -
#910
fe0344d
Thanks @taylorlee! - fix: support preview buckets for r2 bindingsAllows 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.
[email protected]
Patch Changes
-
#902
daed3c3
Thanks @petebacondarwin! - fix: show error if a string option is used without a valueFixes #883
-
#901
b246066
Thanks @threepointone! - chore: minify bundle, don't ship sourcemapsWe 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.
[email protected]
Patch Changes
-
#897
d0801b7
Thanks @threepointone! - polish: tweak the message when.dev.vars
is usedThis 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 theirwrangler.toml
. -
#880
aad1418
Thanks @GregBrimble! - fix: Stop unnecessarily amalgamating duplicate headers in Pages FunctionsPreviously,
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 foraccount_id
,CLOUDFLARE_ACCOUNT_ID
andCLOUDFLARE_API_TOKEN
. Ifaccount_id
exists inwrangler.toml
thenCLOUDFLARE_ACCOUNT_ID
is not needed in non-TTY scope. TheCLOUDFLARE_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 errorsPreviously, 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/ IgnoredFollowup to #888, this replaces some more scary capitals with a more chill word.
-
#893
5bf17ca
Thanks @petebacondarwin! - fix: add bold to theDeprecated
warning title -
#882
1ad7570
Thanks @petebacondarwin! - feat: add support for reading build time env variables from a.env
fileThis 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 dialogsInstead 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/DeprecationThis 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: readvars
overrides from a local file forwrangler dev
The
vars
bindings can be specified in thewrangler.toml
configuration file.
But "secret"vars
are usually only provided at the server -
either by creating them in the Dashboard UI, or using thewrangler secret
command.It is useful during development, to provide these types of variable locally.
When runningwrangler dev
we will look for a file called.dev.vars
, situated
next to thewrangler.toml
file (or in the current working directory if there is no
wrangler.toml
). Any values in this file, formatted like adotenv
file, will add to
or overridevars
bindings provided in thewrangler.toml
.Related to #190
[email protected]
[email protected]
Patch Changes
-
#843
da12cc5
Thanks @threepointone! - fix:site.entry-point
is no longer a hard deprecationTo make migration of v1 projects easier, Sites projects should still work, including the
entry-point
field (which currently errors out). This enablessite.entry-point
as a valid entry point, with a deprecation warning. -
#848
0a79d75
Thanks @petebacondarwin! - polish: improve consistency of warnings and errorsRelated to #377
-
#877
97f945f
Thanks @caass! - Treat the "name" parameter inwrangler 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 namemy-worker
, -
#851
277b254
Thanks @threepointone! - polish: do not log the error object when refreshing a token failsWe 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
inwrangler.toml
, or by passing--node-compat
as a command line arg fordev
/publish
commands. This is currently powered by@esbuild-plugins/node-globals-polyfill
(which in itself is powered byrollup-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.
-
#790
331c659
Thanks @sidharthachatterjee! - feature: Adds 'wrangler pages publish' (alias 'wrangler pages deployment create') command. -
#866
8b227fc
Thanks @caass! - Add a runtime check forwrangler dev
local mode to avoid erroring in environments with noAsyncLocalStorage
classCertain 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 thename
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 -
#868
6ecb1c1
Thanks @threepointone! - feat: implement service environments + durable objectsNow 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
[email protected]
[email protected]
Patch Changes
-
#838
9c025c4
Thanks @threepointone! - fix: remove timeout on custom builds, and make sure logs are visibleThis 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
forwrangler pages functions build
command.
-
#836
28e3b17
Thanks @threepointone! - fix: toggleworkers.dev
subdomains only when requiredThis 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 aJSON.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 anUnknownError
with a message showing where
it originated.resolves #539
-
#840
32f6108
Thanks @threepointone! - fix: make wrangler work on node v18There's some interference between our data fetching library
undici
and node 18's newfetch
and co. (powered byundici
internally) which replaces the filename ofFile
s attached toFormData
s with a genericblob
(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 makesundici
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 ofpublish
. 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.
- #798
feecc18
Thanks @GregBrimble! - fix: Allowsnext()
to take just a pathname with Pages Functions.
-
#839
f2d6de6
Thanks @threepointone! - fix: persist dev experimental storage state in feature specific dirsWith
--experimental-enable-local-persistence
indev
, 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 aminiflare
section in theirwrangler.toml
.Closes #799
- #796
3e0db3b
Thanks @GregBrimble! - fix: Makes Response Headers object mutable after a call tonext()
in Pages Functions
-
#814
51fea7c
Thanks @threepointone! - fix: disallow setting account_id in named service environmentsMuch 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 whenwrangler dev
is cancelled earlyWe currently log an
AbortError
with a stack if we exitwrangler 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 targetThe 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 towrangler 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 forwrangler pages project
andwrangler 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 towrangler.toml
just yet, but could in the future if it looks appropriate there.
-
#811
8c2c7b7
Thanks @JacobMGEvans! - feat: Addedminify
as a configuration option and a cli arg, which will minify code fordev
andpublish
resolves #785