Releases: cloudflare/workers-sdk
wrangler@0.0.13
Patch Changes
-
#293
71b0fab
Thanks @petebacondarwin! - fix: warn if thesite.entry-point
configuration is found during publishingAlso updates the message and adds a test for the error when there is no entry-point specified.
Fixes #282
-
#304
7477b52
Thanks @threepointone! - feat: enhancewrangler init
This PR adds some enhancements/fixes to the
wrangler init
command.- doesn't overwrite
wrangler.toml
if it already exists - installs
wrangler
when creatingpackage.json
- offers to install
wrangler
intopackage.json
even ifpackage.json
already exists - offers to install
@cloudflare/workers-types
even iftsconfig.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 thenpm 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. - doesn't overwrite
-
#294
7746fba
Thanks @threepointone! - feature: add more types that get logged viaconsole
methodsThis PR adds more special logic for some data types that get logged via
console
methods. Types likePromise
,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 theConsoleAPICalled
events don't match 1:1 with actual console methods (eg:console.warn
message type iswarning
). 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 abucket
fieldThis adds an assertion error for making sure a
[site]
definition always has abucket
field.As a cleanup, I made some small fixes to theConfig
type definition, and modified the tests inpublish.test.ts
to use the config format when creating awrangler.toml
file.
wrangler@0.0.12
Patch Changes
-
#292
e5d3690
Thanks @threepointone! - fix: use entrypoint specified in esbuuild's metafile as source for building the workerWhen 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 likeENOENT: 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 correctlyAny 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 withJSON.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 andstatusText
, 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.
wrangler@0.0.11
Patch Changes
-
#242
014a731
Thanks @petebacondarwin! - Refactor pages code to pass strict-null checks -
#267
e22f9d7
Thanks @petebacondarwin! - refactor: tidy up the typings of the build result in devIn #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. -
#284
20377e8
Thanks @petebacondarwin! - Add whoami command -
#270
2453577
Thanks @petebacondarwin! - feat: add support for include and exclude when publishing site assets -
#270
0289882
Thanks @petebacondarwin! - fix: ensurekv:key list
matches the output from Wrangler 1The 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 publishingThe
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 theentrypoint
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: Updatenode-fetch
to 3.1.1, runnpm audit fix
in rootThis commit addresses a secutity issue in
node-fetch
and updates it to 3.1.1. I also rannpm 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 checksThe 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 sizePreviously 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 assetsIn 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 workspaceWatch 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.
wrangler@0.0.9
Patch Changes
- #243
dc7ce83
Thanks @petebacondarwin! - refactor: update test code to pass strict-null checks
- #244
2e7a75f
Thanks @petebacondarwin! - refactor: update dev and publish commands to pass strict-null checks
-
#238
65f9904
Thanks @threepointone! - refactor: simplify and documentconfig.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
- #247
edc4b53
Thanks @petebacondarwin! - refactor: update miscellaneous source files to pass strict-null checks
- #248
5806932
Thanks @petebacondarwin! - refactor: update proxy code to pass strict-null checks
- #241
5d423e9
Thanks @petebacondarwin! - chore: add common words to the cSpell config to prevent unwanted warnings
-
#257
00e51cd
Thanks @threepointone! - fix: description forkv:bulk delete <filename>
The description for the
kv:bulk delete
command was wrong, it was probably copied earlier from thekv:bulk put
command. This PR fixes the mistake.
-
#262
7494cf7
Thanks @threepointone! - fix: fixdev
andpublish
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 indev.tsx
that was breaking. (cc @petebacondarwin)
- #250
3c74a4a
Thanks @petebacondarwin! - refactor: update inspector code to ensure that strict-null types pass
wrangler@0.0.10
wrangler@0.0.8
Patch Changes
-
#231
18f8f65
Thanks @threepointone! - refactor: proxy/preview serverThis 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 seeERR_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. -
#239
0431093
Thanks @Warfields! - Added prompt for users to select an account. -
#225
b901bf7
Thanks @GregBrimble! - Fix the--watch
command forwrangler pages functions build
. -
#208
fe4b099
Thanks @petebacondarwin! - Remove explicitany
types from the codebaseThis change removes all use of
any
from the code and updates theno-explicit-any
eslint rule to be an error. -
#223
a979d55
Thanks @GregBrimble! - Add ability to compile a directory other thanfunctions
forwrangler pages functions build
. -
#216
e1c615f
Thanks @GregBrimble! - Ignore non-JS files when compiling Pages Functions -
#217
777f4d5
Thanks @GregBrimble! - Reverse execution order of Pages Functions middlewares -
#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 inwrangler pages dev
command when that errors out. -
#189
2f7e1b2
Thanks @petebacondarwin! - Refactor raw value extraction from Cloudflare APIsMost 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.
-
#202
e26781f
Thanks @threepointone! - Disable @typescript-lint/no-explicit-any eslint rule in pages code -
#214
79d0f2d
Thanks @threepointone! - rename--public
as--experimental-public
-
#215
41d4c3e
Thanks @threepointone! - Add--compatibility-date
,--compatibility-flags
,--latest
cli arguments todev
andpublish
.- A cli arg for adding a compatibility data, e.g
--compatibility_date 2022-01-05
- A shorthand
--latest
that setscompatibility_date
to today's date. Usage of this flag logs a warning. latest
is NOT a config field inwrangler.toml
.- In
dev
, when a compatibility date is not available in eitherwrangler.toml
or as a cli arg, then we default to--latest
. - In
publish
we error if a compatibility date is not available in eitherwrangler.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
- A cli arg for adding a compatibility data, e.g
-
#210
d381fed
Thanks @GregBrimble! - Exposewrangler pages functions build
command, which takes thefunctions
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 APIWhen 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 acursor
value in theresult_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 towrangler pages dev
which automatically reloads HTML pages when a change is detected -
#223
a979d55
Thanks @GregBrimble! - Add--output-config-path
option towrangler pages functions build
which writes a config file describing thefunctions
folder.
wrangler@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 duringdev
-
e9a1820: Upgrade
miniflare
to2.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 withwrangler 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.)
wrangler@0.0.6
Patch Changes
- 421f2e4: Update base version to 0.0.5, copy the README to packages/wrangler
wrangler@0.0.5
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 theinit
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 thefaye-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 bywrangler init
-
78cd080: Custom builds for
dev
andpublish
-
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
to2.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
.