Dependency cleanup/syntax modernisation
Fairly low priority I imagine, but there are various dependency clean ups and code modernisations we can do in this repo.
I already opened a couple of PRs but want a tracking issue to add some context/discussion.
Here are my suggestions:
Dependencies
| Dependency | Used by | Replace with | Notes |
|---|---|---|---|
| chalk | wrangler, create-cloudflare, cli | styleText (native) or picocolors |
miniflare uses kleur, so could make sense to settle on that or move miniflare to also use styleText/picocolors |
| execa | wrangler, create-cloudflare | tinyexec |
#12369 |
| strip-ansi | wrangler, vite-plugin-cloudflare | stripVTControlCharacters (native) |
#11853 |
| find-up | tools, workers-utils, wrangler | empathic |
#12601 |
| glob | tools, pages-shared, create-cloudflare | tinyglobby |
vite-plugin-cloudflare already uses tinyglobby |
| rimraf | workflows-shared, miniflare, wrangler, pages-shared, workers-shared | premove |
#11913 |
@typescript-eslint/eslint-plugin |
various | Remove | #11906 |
These replacements are what the e18e community recommend (see here). The modules being replaced are generally much larger, slower, and/or outdated.
I can explain each one if needed, just let me know 👍
Syntax (modernisation/perf)
FYI I used the e18e ESLint plugin to find a bunch of these (in case you want a way to reproduce the findings etc).
| Old syntax | New syntax | Notes |
|---|---|---|
arr[arr.length - 1] |
arr.at(-1) |
|
[...arr].map(mapper) |
Array.from(arr, mapper) |
Avoids an intermediate array being allocated |
str.match(regex) |
regex.test(str) |
In conditional logic, to avoid an unused match array |
For these, we could run eslint --fix with the e18e plugin enabled to auto-fix them. There's various occurrences but not a huge amount so it'd be easily reviewable.
Let me know if there's any interest in any of these. I and others would be happy to contribute the changes if you give the go-ahead.
Hi @43081j thanks a lot for the issue 🙂🙏
I think that the syntax suggestions are all quite sensible and non at all controversial (although I would suspect that arr.at(-1) would get probably transpiled away during build 🤔), for those I would say that you are more then welcome to go ahead and summit a PR with the changes. Possibly the simplest thing to do would just be to add the e18e plugin to the monorepo's base config and apply all of those automatically. I can't imagine much pushback on having the e18e plugin set up in the monorepo 🙂
Regarding the dependencies, the proposed changes all seem quite valid to me and I don't expect there to be much pushback if the package is well maintained and the performance benefit is either clearly documented or benchmarked/apparent in the results. I would suggest going with the less potentially controversial one, see how it goes and progress following potential controvesionality 🙂 (that's not a word is it? 😅), but it seems to me like you already started with such approach anyways! 😄
I'll also surface this to the whole team so that everyone is aware and can add any comment here if they have any 🙂
awesome thanks for the quick response 🙏
i can try explain some of the dependency replacements:
- chalk
- ~44KB vs picocolors 6KB
- picocolors is widely adopted already
- if you need RGB colours,
ansisis a good alternative instead of picocolors - one day we should just use node's built-in
styleTextbut iirc it only became stable in 21.x
- execa
- ~640KB, 22 dependencies vs tinyexec 26KB, 0 dependencies
- tinyexec is adopted by most modern tools already
- strip-ansi
- it is built into node since 16.x, this one seems the easiest to do first
- find-up
- ~62KB, 5 dependencies vs empathic 21KB, 0 dependencies
- empathic is faster, but "find upwards" functionality isn't often hot-path code so users are unlikely to notice either way
- empathic replaces many "find upwards" packages in wider dependency trees, so should de-dupe better in the bigger picture (e.g. it replaces
find-up,find-package,find-package-json, etc.)
- glob
- 2.6MB vs tinyglobby 179KB
- tinyglobby is faster, too
- most modern tools have adopted tinyglobby already
- rimraf
- ~2.9MB vs premove 9.7KB
- dev only dependency, so this is another easy one to do
- premove doesn't have glob support, but afaik this repo doesn't pass globs to rimraf anyway
The sizes are all install size (including all their dependencies).
Hi @43081j @dario-piotrowicz — great work on this cleanup! I see chalk and glob are the two remaining items. Happy to take the glob → tinyglobby replacement if that works for you. I'd start with pages-shared and create-cloudflare.
Hi! I’d like to handle one remaining part of this cleanup by replacing chalk with ansis in @cloudflare/cli-shared-helpers only.
This package needs RGB, background, hidden, and standard text styles, which ansis supports while keeping the replacement significantly smaller than chalk. I’ll preserve the existing exported color API, update the lockfile and changeset, and run the package tests and repository checks.
Is this package-scoped approach acceptable?
[!NOTE] This is an automated, advisory triage report generated by workers-devprod. It is not an official maintainer response — a maintainer will follow up.
🤖 Automated triage report
Issue Triage: cloudflare/workers-sdk#11854
Summary
A tracking issue proposing dependency replacements (chalk, execa, strip-ansi, find-up, glob, rimraf) and JavaScript syntax modernisations across the monorepo, following e18e community recommendations.
Classification
- Type: Feature Request (tracking issue)
- Component: repo-wide tooling / dependencies (touches
packages/wrangler,packages/create-cloudflare,packages/cli,packages/miniflare,packages/vite-plugin-cloudflare,packages/pages-shared,packages/workers-shared,packages/workers-utils,packages/workflows-shared,tools) - Severity: N/A (maintenance/modernisation, explicitly low priority per author)
- Has Reproduction: N/A (not a bug)
- Quality: Complete
Findings
- Created: 2026-01-09
- Author: 43081j (James Garbutt)
- Version: not specified (N/A for a tracking issue)
- Labels: none
- Comments: 5
Analysis
- This is a well-scoped tracking issue, not a bug. The author lays out a clear table of dependency replacements (with install-size justifications) and syntax modernisations, plus links to already-open PRs (#12369, #11853, #12601, #11913, #11906).
- A maintainer (
dario-piotrowicz, MEMBER) explicitly endorsed the proposal in comments — approving the syntax changes via the e18e ESLint plugin and welcoming the dependency swaps — and surfaced it to the wider team. This is a clear "go-ahead." - The issue is actively progressing: multiple contributors have claimed sub-tasks (
roli-lpcion glob→tinyglobby;ahfoysalon chalk→ansis in cli-shared-helpers) and several linked PRs are already open/merging. - Not stale — last activity was 2026-07-15 (same day as triage). Work is ongoing with only a couple of items (chalk, glob) remaining.
- No closeable condition from Step 2 applies: not spam, not resolved, not a duplicate, in-scope for workers-sdk, not stale, not user error, not won't-fix. It should remain open until the remaining sub-tasks are complete.
Recommendation
Status: KEEP OPEN
Reasoning: This is an active, maintainer-endorsed tracking issue for a multi-PR modernisation effort. Several sub-tasks are already merged or in progress, and contributors are actively picking up the remaining items (chalk, glob). It should stay open as a coordination point until all tracked work lands.
Action: Leave open as a tracking issue. A maintainer could optionally convert the dependency/syntax tables into a checklist to track remaining work, and label it for discoverability. Confirm to ahfoysal whether the package-scoped chalk→ansis approach is acceptable.
Suggested Labels: none (no confidently-existing repo label clearly applies; omitting rather than guessing)
Suggested Comment
Thanks for putting together this tracking issue and for the detailed justifications! As noted above, the team is happy for these modernisations to go ahead. A few of the linked PRs have already landed and contributors are picking up the remaining items (chalk, glob). We'll keep this open to coordinate the remaining work — feel free to keep linking PRs here as they open so we can track progress.
Structured summary (JSON)
{
"issueNumber": 11854,
"title": "Dependency cleanup/syntax modernisation",
"githubUrl": "https://github.com/cloudflare/workers-sdk/issues/11854",
"recommendation": "KEEP OPEN",
"difficulty": "n/a",
"reasoning": "Active, maintainer-endorsed tracking issue for a multi-PR dependency and syntax modernisation effort, with several sub-tasks already merged or in progress.",
"suggestedAction": "Leave open as a tracking issue; optionally convert the tables into a checklist and confirm the scoped chalk->ansis approach with the latest contributor.",
"hasSuggestedComment": true,
"suggestedLabels": []
}
hey everybody ✌🏻
@dario-piotrowicz, i wanted to pick up the chalk row from this table. before i open anything i wanted to check the approach with you since it's a bit bigger than the table suggests.
chalk is still a dep of six packages, not three: wrangler, cli-shared-helpers, autoconfig, remote-bindings, deploy-helpers and workers-utils. around 54 files are involved. three of those ship chalk as a runtime dep to consumers (deploy-helpers, cli-shared-helpers, workers-utils), the rest bundle it.
the catch is hex. packages/cli/colors.ts has seven chalk.hex() brand colours plus four bgHex variants, and there are a few more inline in wrangler and autoconfig. on the node 22 the repo pins, util.styleText throws on hex (i tested on 22.22.1, it only works on 24), and picocolors doesn't do hex either. so going native means dropping the brand palette to the 16 named colours, which felt like your call, not mine.
what i'd propose instead is ansis (@43081j mentioned it above for rgb). it's chalk-compatible api wise, chaining and hex included, and i checked the escape bytes it emits are identical to chalk's, including how hex degrades at level 1 and 2. so output stays byte for byte the same.
two things i found while prototyping that shape the prs:
- ansis colours piped output whenever
COLORTERMorCIis set, chalk only does it on a tty or withFORCE_COLOR. that would put escape codes inwrangler deploy > log.txtfrom any modern terminal. so rather than swapping imports file by file i'd add one shared instance in workers-utils with a tty guard, and have everything import from there. this also gives you a single place for colour policy across the repo ansis.level = 0is a no-op (level is a plain property), so the three test setups that setchalk.level = 0just get deleted (vitest has no tty anyway) and the one deploy-helpers test that asserts colour codes gets a mocked instance
my plan is to submit two prs following the same shape as james' rimraf/execa ones: first one adds the instance to workers-utils and rebuilds the cli-shared-helpers palette on it, second one sweeps the other four packages with a codemod (one commit per package) and drops chalk from the catalog.
if you'd rather go native and are fine losing the hex palette, i can do that instead, same shape, just styleText under the hood with a small tty guard since validateStream only exists from 22.13. lmk which way you want it
ansis makes sense to me since there's a few hex colours 👍
i do wonder if we should only use it when needed though. i.e. only pull it in to the package(s) that need hex colours. for the rest, use styleText.
it means later on we can drop it easily once the node version bumps enough.
Thanks @43081j for putting this together, and to everyone who picked up items. Most of the dependency swaps have now landed. For chalk, we've decided to keep it and upgrade to v6 rather than replace it: several packages depend on its hex colours, which Node's styleText can't produce on Node 22, and v6 matches what Cloudflare's other CLI uses. With that settled, we're closing this tracking issue.
It would still be a smart move to drop chalk. 50KB for something this simple is a little much.
Many projects have already moved to any of: tinyrainbow, ansis, styleText (22+ or something). All support hex
I'm happy to change it in the other cli too if that's the only reason to keep holding onto it. Let me know