Drop, Replace, Inline, DIY, or Minimize Dependencies
Open
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 10.5k
- Forks
- 564
- PR merge metrics
- No merged PRs in 30d
Description
Feature Request
I really want to decrease the size of WXT. As of 0.21.2, here's it's install size (excluding peers):
22MB / 156 packages
There's a couple options for cleaning these up:
- Is the dependency actually needed anymore? No? Drop it
- Can the dependency be replaced with a smaller alternative? Yes? Do it
- Is the dependency small and not likely to have a vulnerability? Yes? Inline it
- Is the dependency something that can be replaced by a single function? Yes? DIY it
- After reviewing, could the package be cleaned up? Yes? Contribute to it
Dependencies
This is a list of all of WXT's 37 direct dependencies, and what, if anything, we can do to reduce it's size:
High Priority
-
import-meta-resolve(79KB / 1 package, ESM) - Drop, not needed in Node 22- #2526
-
publish-browser-extension(933KB / 7 packages, ESM)- Released v6 → 333KB / 4 packages
- Explored inlining final deps, but decided not to: https://github.com/aklinker1/publish-browser-extension/pull/87
-
@aklinker1/rollup-plugin-visualizer(1.7MB / 23 packages, CJS) - Replace with https://sonda.dev or DIY it (how hard can it be? lol). What does nuxt's analysis tool and devtools use? OR trim down my fork to removeyargsandopen- Issue for sonda already exists: https://github.com/filipsobol/sonda/issues/195
- Rolldown provide's it's own bundle analysis tool, though it is experimental and this would lock us into Vite even more. We would just have to render a UI: https://rolldown.rs/builtin-plugins/bundle-analyzer
- I got an extension working with vite's environment API, https://github.com/wxt-dev/wxt/issues/1046#issuecomment-5109933695, but
rollup-plugin-visualizerdidn't work when building in series, only in parallel, meaning it's getting lucky with a race condition. So my fork is still necessary
Medium Priority
-
open(83KB / 12 packages, ESM) - Replace withtiny-open?- #2527
-
prompts(203KB / 3 packages, CJS) - Replace with@topcli/prompts- #2528
-
async-mutex(153KB / 2 packages, ESM + CJS) - replace withsuperlock- #2529
-
@wxt-dev/storage(1.1MB / 8 packages, ESM) - Inlinedequal, replaceasync-mutexwithsuperlock- #2529
- #2530
-
jszip(1.8MB / 13 packages, CJS) - There's got to be a zero-dependency zip library we can replace this with...uzipis tiny and might work- But maybe
node:zlibcan do it in a few lines? More than a few, but yes: https://share.gemini.google/gYafpOMSmyfo - Or spawn
zipsubprocesses 🤔 fflatewas suggested: https://github.com/wxt-dev/wxt/issues/2523#issuecomment-5128051194- https://github.com/wxt-dev/wxt/pull/2538
- #2560
Low Priority
-
scule(30KB / 1 package, ESM + CJS) - Inline to tree-shake CJS- #2560
-
ci-info(30KB / 1 package, CJS) - Inline to tree-shake everything we don't use|- #2543
-
get-port-please(29KB / 1 package, ESM + CJS) - Inline to tree-shake CJS out- #2576
-
filesize(58KB / 1 package, ESM + CJS) - Inline or DIY it. 58 kB is a bit large for a few if statements...- #2589
-
is-wsl(10KB / 3 packages, ESM) - Is this apart ofci-info? If not, inline.- #2560
-
normalize-path(9.2KB / 1 package, CJS) - Inline or DIY- #2557
-
ohash(20KB / 1 package, ESM) - Inline or DIY- #2560
-
picomatch (93KB / 1 package, CJS) - Can this be dropped?- Let's cleanup the other deps that depend on it first: https://github.com/wxt-dev/wxt/pull/2559#issuecomment-5227070142
-
nanospinner(17KB / 2 packages, CJS) - Inline- #2567
-
nano-spawn(45KB / 1 package, ESM) - vstinyexec? don't need both,tinyexecis smaller...- #2544
-
@webext-core/isolated-element(13KB / 2 packages, ESM) - could DIY this- Inlined only dependency: https://github.com/aklinker1/webext-core/commit/eff4212433fbd2fd01f5656ae513102d5300b189
-
dotenv-expand(123KB / 2 packages, CJS) - Inlining it should remove the dependency ondotenv, will be tree-shaken out? -
magicast(5.3MB / 6 packages, ESM) - Only tool that includes babel, would like to replace, maybe with https://oxc.rs/docs/guide/usage/transformer.html?- Potential OXC replacement: https://github.com/wxt-dev/wxt/commit/c394e4b2060d4ee1870541035d25a51e43b42209
- I think we're going to have to keep this one.
-
@webext-core/fake-browser(1.1MB / 6 packages, ESM) - Simplify thebaseobject to a proxy -
c12(404KB / 8 packages, ESM) - There's a lot of dependencies here that probably aren't required for our use-case. Might want to DIY it now that node can import TS files -
unimport(3MB / 30 packages, ESM) - No idea how this can be simplified, but it should be. Probably would need to contribute to it.
Fine As-is
-
@1natsu/wait-element(46KB / 3 packages, ESM) - Small enough as-is, though I would like to see it have 0 dependencies -
@webext-core/match-patterns(9.9KB / 1 package, ESM) - small, zero deps, it's fine -
@wxt-dev/browser(870KB / 4 packages, ESM) - Fine, kinda big, but not much can be done about it -
cac(41KB / 1 package, ESM) - Fine, could inline it, but it's fine. -
chokidar(105KB / 2 packages, ESM) - fine for now.readdirpdoesn't seem necessary anymore, could contribute to it's removal -
consola(322KB / 1 package, ESM + CJS) - Kinda big, but fine for now. Don't like that it still ships CJS -
defu(21KB / 1 package, ESM + CJS) - Small, could inline, but probably fine -
giget(184KB / 1 package, ESM) - Kinda large, but it does it's job well. -
hookable(24KB / 1 package, ESM) - Could inline, but it's fine as-is for now. -
json5(235KB / 1 package, FAUX) - Small-ish, one package, probably fine as is. -
linkedom(3.6MB / 20 packages, ESM) - Parsing the entrypoint HTML files could be accomplished withhtmlparser2, but I don't think the fake browser environment can be created without a library like this... -
nypm(160KB / 4 packages, ESM) - We don't need it's CLI, so having to downloadcittyis a bit of a waste, but it's not very large for the trouble. -
tinyglobby(186KB / 3 packages, ESM + CJS) - Necessary, could contribute to drop CJS
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Review the unresolved dependency entries, especially rollup-plugin-visualizer, dotenv-expand, c12, and unimport, and inspect the linked upstream discussions before choosing one. Done means a concrete dependency reduction is implemented and the issue's checklist and size accounting are updated.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- build-system, tooling
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 32/100