Patch Changes
-
#364
3575892
Thanks @threepointone! - enhance: small tweaks towrangler init
- A slightly better
package.json
- A slightly better
tsconfig.json
- installing
typescript
as a dev dependency
- A slightly better
-
#380
aacd1c2
Thanks @GregBrimble! - fix: ensure pages routes are defined correctlyIn 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 usingrunning.os
but this appeared not to be working.
-
#347
ede5b22
Thanks @threepointone! - fix: hidewrangler pages functions
in the main help menuThis 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 forkv:key get
.Fixes #359.
-
#373
6e7baf2
Thanks @petebacondarwin! - fix: use the appropriate package manager when initializing a wrangler projectPreviously, 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 inwrangler dev
Just a quick fix to accept uppercase hotkeys during
dev
. -
#331
e151223
Thanks @petebacondarwin! - fix: generate valid URL route paths for pages on WindowsPreviously route paths were manipulated by file-system path utilities.
On Windows this resulted in URLs that had backslashes, which are invalid for such URLs. -
#338
e0d2f35
Thanks @threepointone! - feat: environments for Worker SitesThis 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 thenpm 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()
andmockApiToken()
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 appliesnormalizeSlashes()
andtrimTimings()
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.
-
-
#380
aacd1c2
Thanks @GregBrimble! - refactor: clean up pages routing -
#343
cfd8ba5
Thanks @threepointone! - chore: update esbuildUpdate esbuild to 0.14.14. Also had to change
import esbuild from "esbuild";
toimport * as esbuild from "esbuild";
indev.tsx
. -
#371
85ceb84
Thanks @nrgnrg! - fix: pages advanced mode usagePreviously in pages projects using advanced mode (a single
_worker.js
or--script-path
file rather than a./functions
folder), callingpages 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 inwrangler 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 commandsThis change speeds up tests and avoids us checking that npm did what it is supposed to do.
-
#348
b8e3b01
Thanks @threepointone! - chore: replacenode-fetch
withundici
There are several reasons to replace
node-fetch
withundici
:undici
'sfetch()
implementation is set to become node's standardfetch()
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
viaminiflare
/pages, so this means our bundle size could ostensibly become smaller.
This replaces
node-fetch
withundici
.- All instances of
import fetch from "node-fetch"
are replaced withimport {fetch} from "undici"
undici
also comes with spec compliant forms ofFormData
andFile
, so we could also removeformdata-node
inform_data.ts
- All the global types that were injected by
node-fetch
are now imported fromundici
(as well as some mistaken ones fromnode:url
) - NOTE: this also turns on
skipLibCheck
intsconfig.json
. Some dependencies oddly depend on browser globals likeRequest
,Response
(like@miniflare/core
,jest-fetch-mock
, etc), which now fail becausenode-fetch
isn't injecting those globals anymore. So we enableskipLibCheck
to bypass them. (I'd thoughtskipLibCheck
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 enablestrict
sometime to avoidany
s, 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 ofundici
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 inpackage.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.) - This adds
-
#372
05dbb0d
Thanks @threepointone! - feat:wrangler init
offers to create a starter workerWe got feedback that
wrangler init
felt incomplete, because the immediate next thing folks need is a starter source file. So this adds another step towrangler init
where we offer to create that file for you.Fixes #355
-
#384
8452485
Thanks @petebacondarwin! - refactor: use xxhash-wasm for better compatibility with WindowsThe 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 inwrangler dev
This adds support for
*.wasm
modules into local mode forwrangler 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 tominiflare
.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: usenpm ci
and do not cache workspace packages in node_modulesPreviously we were caching all the
node_modules
files in the CI jobs and then runningnpm 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 replacesnpm install
withnpm ci
.The
npm ci
command is actually designed to be used in CI jobs as it only installs the exact versions specified in thepackage-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 nonode_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.