Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce direct dependencies/devDependencies #598

Open
6 of 13 tasks
XhmikosR opened this issue Mar 4, 2022 · 9 comments
Open
6 of 13 tasks

Reduce direct dependencies/devDependencies #598

XhmikosR opened this issue Mar 4, 2022 · 9 comments
Labels
dependencies Pull requests that update a dependency file help-wanted

Comments

@XhmikosR
Copy link
Member

XhmikosR commented Mar 4, 2022

With jest, we might be able to remove the following devDependencies:

As for dependencies, we might be able to remove and/or replace this with smaller/better maintained packages:

  • lodash (see Remove/replace lodash dependency #604)
  • prettysize
  • glob - replace it with a smaller one or see if we can achieve the same with code on our side using native methods? Maybe fdir
  • lodash.escape
  • lodash.merge
  • lodash.trim (see refactor: drop lodash.trim dependency #749)
  • lodash.trimstart
  • winston - do we really need its functionalities? Can't we just replace it with simpler logging/smaller package?
  • csso is a big dependency but svgo depends on it anyway so it's being deduped as long as we use the same version here
  • any other deps?
@XhmikosR XhmikosR added dependencies Pull requests that update a dependency file help-wanted labels Mar 4, 2022
@Kreeg
Copy link
Member

Kreeg commented Mar 7, 2022

@XhmikosR if 2.0 release of resvgjs will be landed we can drop image-size dependency

@XhmikosR
Copy link
Member Author

XhmikosR commented Mar 7, 2022

Nice!

I think our biggest dep at least in regard to the number of installed files is lodash. We'll get there eventually :)

@XhmikosR XhmikosR pinned this issue Jun 22, 2022
@chalkygames123
Copy link

chalkygames123 commented Jun 23, 2022

I'd like to recommend fdir as an alternative to glob.

Author's post: https://dev.to/thecodrr/how-i-wrote-the-fastest-directory-crawler-ever-3p9c

@Kreeg
Copy link
Member

Kreeg commented Jun 23, 2022

Seems like a good solution. It is lightweight, dependency-free, I'm down with that.

@XhmikosR
Copy link
Member Author

XhmikosR commented Jun 24, 2022

One thing to keep in mind is that if one dep is very popular, there's a higher chance it's already in people's deps tree. I'm not saying we shouldn't replace a dependency if it's not popular, but it's something we should keep in mind too.

Anyway, after the lodash removal, installing svg-sprite v2.0.0-beta7 leads to ~1700 files while in v2.0.0-beta5 it was ~2700 files.

See also:

@strager
Copy link
Contributor

strager commented Oct 26, 2022

Drop lodash.trim: #742

@tommiv
Copy link

tommiv commented May 5, 2023

A note here that with the lodash.trim removal a small documentation bug is introduced:

// Add SVG source files — the manual way ...
spriter.add('assets/svg-1.svg', null, fs.readFileSync('assets/svg-1.svg', 'utf-8'));

this line will throw an error because there's no null check on

name = trimStart(name.trim(), `${path.sep}.`) || path.basename(file);

Possible solutions are

  1. to add a null-ish check
name = trimStart(name ? name.trim() : '', `${path.sep}.`) || path.basename(file);
  1. to force a string before .trim() call
name = trimStart((name || '').trim(), `${path.sep}.`) || path.basename(file);
  1. to update a readme
// Add SVG source files — the manual way ...
spriter.add('assets/svg-1.svg', '', fs.readFileSync('assets/svg-1.svg', 'utf-8'));

@strager
Copy link
Contributor

strager commented May 5, 2023

@tommiv Thanks for finding a bug in my patch!

@XhmikosR Please advise on the right solution.

@jimCresswell
Copy link
Contributor

I've opened #819 to remove lodash.trimstart, happy to make changes if that approach doesn't suit you or you find issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file help-wanted
Projects
None yet
Development

No branches or pull requests

6 participants