Repository navigation
Open
Labels
umbrella issueThis issue contains a list of dependents of a package and tracks the progress in each
Description
Currently it has 107 direct dependencies, and many more non-direct. It's worth cleaning them up.
Modules that can be replaced with other modules:
chalk->picocolors(mainly a size win)- chokidar v3 -> v4 upgrade, -11 deps (if I remember correctly)
find-up-> empathic, -7 depsdot-prop-> dlv + dset, might be that only one is neededexeca-> tinyexec
Modules that can be removed in favor of 1-3 lines of code:
is-streamp-filter:
const filteredItems = await Promise.all(
items.map(async (item) => {
const shouldKeep = await someAsyncCondition(item); // Replace with your async condition
return shouldKeep ? item : null;
})
).then((results) => results.filter((item) => item !== null));p-map, probably could be replaced withPromise.allp-wait-for:
const waitFor = async (condition, interval = 100) => {
while (!(await condition())) {
await new Promise((resolve) => setTimeout(resolve, interval));
}
};through2-filter:
const { Transform } = require('node:stream');
const filterStream = new Transform({
decodeStrings: false,
transform(chunk, encoding, callback) {
if (chunk.includes('foo')) { // Example filter condition
this.push(chunk);
}
callback();
},
});
process.stdin
.pipe(filterStream)
.pipe(process.stdout);from2-array:
const { Readable } = require('node:stream');
const arrayToStream = (array) => {
return new Readable({
objectMode: true,
read() {
array.forEach((item) => this.push(item));
this.push(null);
},
});
};tempy->os.tmpdir()+fs.createFile/fs.mkdirhasha->crypto.createHash('sha512').digest()
PRs:
- remove
hasha: chore(deps): remove hasha netlify/cli#7017
Reacted by Sarah Etter, v1rtl and Charles Kornoelje
Metadata
Metadata
Assignees
Labels
umbrella issueThis issue contains a list of dependents of a package and tracks the progress in each
Activity
pralkarz commentedon Jan 28, 2025
Another suggestion:
ora->nanospinner/picospinner.Some dev dependencies could be dropped too:
is-cisimply exposes a function fromci-info, so it's redundant given that the latter is a regular dependencyfs-extra->node:fsstrip-ansi->node:util(stripVTControlCharacters)43081j commentedon Jan 28, 2025
good issue 🙌
cc @sarahetter
another interesting one to look at, but much bigger job, would be moving from express to something like polka (or another fast/light alternative)
there's a few modern, lightweight node web servers floating around these days. using one could improve the dev server performance and overall CLI size i imagine
v1rtl commentedon Jan 28, 2025
shameless plug of tinyhttp, in case you need a smoother transition from express, rather than going hardcore with polka
v1rtl commentedon Jan 29, 2025
Seems like this PR is also related, it bumps a lot of deps and shrinks the lockfile heavily
netlify/cli#7008
benmccann commentedon Jan 29, 2025
Moving to polka is quite easy. It's API compatible with express. You just have to be sure to use the version tagged with
next(currently1.0.0-next.28). Thelatestversion, which is pre-1.0 has a different API. We've been using thenextversion in SvelteKit and have a good experience with it.benmccann commentedon Jan 29, 2025
Also wanted to mention since this issue doesn't yet that the package we're talking about here is
netlify-cli: https://npmgraph.js.org/?q=netlify-cliI wonder if it's necessary for it to depend on both fastify and express?
v1rtl commentedon Jan 29, 2025
depends on how they use it. If they use a lot of different request / response extensions, it's not that easy. If it's just res.send and res.json, then yes I agree it's better to move to Polka
sarahetter commentedon Jan 29, 2025
Hey all! Thanks for all your investigation here. I'm excited about the potential work & cleanup! ✨
For the immediate future hold off on submitting PRs as we're actively scoping out a larger project in the netlify-cli and don't want to have any throw-away work.
I'll keep this issue updated when we have more information.
serhalp commentedon Feb 20, 2025
👋🏼 Thanks so much for looking into this, folks! I've been working on the Netlify CLI lately and this has been helpful. Let me provide a quick update (and get this collated for my own sake):
chalkwith smaller and fasteransisnetlify/cli#7058execa -> tinyexecwe probably won't do this one. We make very extensive use of execa and so does our dependency@netlify/build(so even if we removed it from netlify-cli we wouldn't save anything). Don't think the juice is worth the squeeze here.remove is-streamdecided not to botheroraandlog-symbolswith tiny dependencynanospinnernetlify/cli#7026fs-extranetlify/cli#7025strip-ansi-control-characters? it's more than juststrip-ansiThe ones with no comments I'll be knocking out soon I think. But if anyone here feels like grabbing any of them, by all means please go ahead and just give me a heads up! 🙌🏼
btw if you happen to have any tips about any of these (they're untyped, so we'd love to get rid of them anyway) please let me know 😄:
strip-ansi-control-characterstomlify-j0.4: I'm thinking of replacing with https://github.com/squirrelchat/smol-toml (goes from TOML spec 0.4 to 1.0 but that should be fine for how it's being used)v1rtl commentedon Feb 20, 2025
I don't think it's worth moving from express to fastify tbh, it's a standalone framework and isn't meant to be consumed by libraries/tools directly. I'd use either polka or tinyhttp. I could send a PR with migrating to tinyhttp if you'd like
Fuzzyma commentedon Feb 20, 2025
If you need glob support for chokidar, I can release my chokidar-glob package. You would be the first consumer tho. But all tests pass
43081j commentedon Feb 20, 2025
thanks a lot for getting the list together @serhalp 🙏
there's a lot of low hanging fruit on there, easy wins. we should churn those out first and can figure out the larger stuff like express later (though i think you'll have got through most yourself soon)
depending on the usage of express inside the CLI, i would agree polka or tinyhttp will probably do nicely
i think we should hold off on this until it has been proven out elsewhere. but you raise a point, we should be doing that very soon as we need to unblock the various projects in need of it
benmccann commentedon Feb 20, 2025
I noticed a couple of dependencies that could be upgraded to cleanup the graph a bit. E.g. upgrading
@vercel/nftwould help a fair amount as I've been working on cleaning that up for the past several monthsYou can see a list of everything outdated here: https://npmgraph.js.org/?q=netlify-cli#color=outdated
serhalp commentedon Feb 21, 2025
@talentlessguy Sounds great, I won't decline that offer! 😄 Even better if it happens to remove the untyped
express-loggingdep, since I need to tackle that soon too.18 remaining items
benmccann commentedon Jul 24, 2025
precinctis 76 dependencies and is only called once. It could probably be replaced with something likezimmerframearchiveris 64 dependencies is used just once to zip a file and I'd imagine there's a lighter alternative for it as wellqsis 18 dependencies and should be able to be replaced with something likepicoquery(orneoqsif that doesn't work)43081j commentedon Jul 25, 2025
FYI im tracking a bunch of this here while i submit some PRs:
https://gist.github.com/43081j/5f899a79c60089351a072ad3139393c6
43081j commentedon Jul 30, 2025
i've updated the gist with a whole bunch of things
i've tried to add links to the ones that are already done
if anyone wants to pick up the others, feel free! most are easy
benmccann commentedon Aug 6, 2025
@serhalp I was wondering if it might be possible to split the CLI into multiple packages that the CLI consumes? In SvelteKit, we need the serve functionality for our integration tests to ensure that we've built a properly working Netlify app, but we don't need the other commands that the CLI offers. It'd be really nice for us if there were a way to just invoke the serve piece directly. Currently the CLI has 847 dependencies and I'd really like to find a way to avoid needing to install the ones we don't need
serhalp commentedon Aug 7, 2025
@benmccann hmm, well, in a way we've sort of recently done that in order to build our new Vite plugin. we haven't split it by command but rather we've split all the Netlify platform emulation logic out of CLI into their own packages and then wrapped all those in a new
@netlify/devpackage: https://github.com/netlify/primitives/tree/main/packages/dev. so far we're using it in our new vite plugin and in our new nuxt module (and we're slowly pulling it back in netlify-cli of course). we're very curious to hear about new use cases! could this be one?(we may want to move this discussion elsewhere to avoid derailing the e18e stuff here)
v1rtl commentedon Aug 7, 2025
BTW I'm also working on remove fetch and AC polyfills, but seems like there's some errors in integration tests that I am not sure how to properly resolve, specifically:
bad porterror (that usually comes from binding on ports disallowed by fetch spec)fetch failedwith no error descriptionnetlify/cli#7357
43081j commentedon Aug 7, 2025
@outslept just moving the conversation from the gist here
can you explain the path-scurry/symlink/glob stuff a little more? i didn't quite follow
we can tell tinyglobby to follow symlinks, can we not? then just archive the results as if they were real files
outslept commentedon Aug 7, 2025
@43081j Great that you tagged me because I was mentally coming back to this. Here's a breakdown for everyone not coming from gist.
We're talking about
netlify/buildrepo, the currentarchiverusage inzip-it-and-ship-itdoes full zip creation witharchiver('zip'), the problematic part for replacement is the symlink handling where we checkstat.isSymbolicLink()and either callarchive.symlink()for symlinks orarchive.file()for regular files. From my research there are no libraries that provide anything for working with symlinks in zip creation context (I may be wrong in this). I considered this a blocker and decided to dig deeper into how other projects solve this.That's when I discovered VSCode's
vsceand how they work with symlinks. Instead of preserving symlinks in the zip file, they useglob('**/*', { follow: true })to collect files with symlinks already resolved to real files, then useyazlto archive those real files as regular entries.The key insight is moving symlink resolution from the archiving phase to the collection phase. You're right about being able to use follow symlinks from
tinyglobby. I got fixated on the issue title and mistakenly thought it was a blocker, but that issue doesn't actually affect this use case.For context,
zip-it-and-ship-itis the core lib behind Netlify Functions - it bundles Node.js, Go, and Rust functions for deployment on AWS Lambda.The remaining question is: in this specific case should we preserve symlinks as symlinks in the zip archive, or resolve them to real files during collection phase? I don't know all the depth in this topic and don't wanna break things as it's a different approach to handle symlinks if we compare it to the current one. Completely different..
outslept commentedon Aug 7, 2025
Also worth noting - if this happens, it would be one of the biggest bundle size reductions from the discussion:
archiver- 6.7MB total size + 73 dependenciesyazl- 73.77KB total size + 1 dependencyThat's a ~98.9% size reduction 😱
43081j commentedon Aug 7, 2025
i understand now 👍
if we switch to tinyglobby and yazl, we would have to store the files rather than symlinks
if it's an easy enough change, its probably good to open a draft PR in the netlify repo. If its a lot of effort, an issue would be enough for now. just so we can discuss with the netlify folks if its acceptable to no longer archive links as-is.
benmccann commentedon Aug 7, 2025
Really excited to see the work happening towards removing
archiverfromzip-it-and-ship-it!@netlify/devsounds like a great alternative tonetlify serve! I'll continue that discussion in netlify/primitives#406Here are some more ideas in the meantime:
ipxcould probably replacelisthenwith something lighter likesrvx. If staying onlisthenit could be cleaned up a bit (Replaceclipboardywith lighter alternative unjs/listhen#202)unstorageandipxcould both dropofetch. All LTS versions of Node supportfetchnow@parcel/watchercould switch frommicromatchto the underlyingpicomatch. We've seen intinyglobbythatpicomatchis just fine for everyone in the real world and have never run into someone needing the functionality inmicromatch. Or perhaps it should be replaced bychokidar, which would probably dedupe better@whatwg-node/serverin@netlify/dev-utils. We already have a few other HTTP servers innetlify/build, so don't need yet anotherajvandbetter-ajv-errorsin@netlify/edge-bundlerAlso, it seems we need to use
fix:rather thanchore:if we want these changes to be released. My change removingqshas not been released and I'm guessing this is whypi0 commentedon Aug 7, 2025
Some notes re unjs related deps:
node-fetch-nativesub-dep in the next major (it is 790kB of 890kB, so dropping it makes it much lighter). But likely somehow need dependency on undici for features like Unix socket and proxyAgentfrom undici it would save whole ecosystem)v1rtl commentedon Aug 7, 2025
seconding the
ofetchpart. Removingnode-fetchand others is not as easy when there's usage of http agents and proxies. AFAIK you can't pass a specific agent tonode-fetch-nativetho, at least I couldn't manage to.pi0 commentedon Aug 7, 2025
@talentlessguy Feel free to open an issue in node-fetch-native it is strange if you couldn’t pass (legacy node-fetch) agent to it.
I had briefly talked with undici maintainers. They are (sadly) unlikely to make it ESM/treeshakable to only pick Agent part at least anytime soon. Likely we should make it an optional dep for users need it. (but at least good news recent Node.js 24 supports proxy env)
benmccann commentedon Oct 12, 2025
jsonwebtokencould be replaced withjose