-
Notifications
You must be signed in to change notification settings - Fork 147
chore: Remove dependency on lodash #421
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
base: main
Are you sure you want to change the base?
Conversation
|
I'm generally in favor of moving off of Lodash - or at least the parts of it that are now built into JS. But:
Why does Lodash block ESM? As of Node.js v20.19.0+, |
New info to me! haha I had to brush back up on the spec. I think eslint/prettier fires off an error about it since its recommended that you do not use require in esm. That being said, we probably shouldnt be mixing ways to load modules if possible. Let me see if i can get the exact issue i saw and post it in the PR |
|
@JoshuaKGoldberg It might have been this eslint error: When i tried to perform the |
Weird, that doesn't look like an ESLint error. Where did you see it / how did you get that to happen? Can you paste the full error? (I don't reproduce locally)
Well, removing a large dependency is always nice 😄 I'm not against the PR if you want to keep it going! But I just don't think we need it for the yargs update or otherwise. |
|
@jdalrymple, My apologies, I just broke your PR with merge conflicts when we merged my ESLINT config pr. 🙃 |
|
hahah no worries, ill sort out the conflicts over the next couple days |
52c8b33 to
94d87eb
Compare
|
@JoshuaKGoldberg I was able to bump yargs without doing all the esm things in one ticket, see #431 |
Aha there's an issue! I think you discovered this in the PR, but just to say it here: there shouldn't be a need to do that. The only entries that should need to be changed in the |
Not quite sure I follow. Are you saying that nothing* needs to be changed in the package.json to have the library be recognized as esm? |
|
Depends what you mean by "have the library be recognized as esm"?
|
|
Anything missing in this that i should add/cover? |
| "async": "^3.1.0", | ||
| "chalk": "^5.6.2", | ||
| "didyoumean": "^1.2.1", | ||
| "eta": "^4.5.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Praise] TIL that eta is the recommended replacement for _.template. Cool! https://www.npmjs.com/package/lodash.template
JoshuaKGoldberg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, what a great contribution - thanks for doing all this manual work! 🙌
Because this touches a lot of tricky stuff, I'd definitely want another review from a maintainer. I think it'd be good to double-check sure CI is working & tests are running well before merging. But no blockers that I can see.
|
thanks for the review @JoshuaKGoldberg !! @jdalrymple two questions - are you interested in becoming a part of our maintainer team here? you've been helping so so much! second, I will review this in the next few days. i'll test things locally - and give it a closer review. My apologies for the delays!! |
|
hey there @jdalrymple i'm curious - did you run an
i'm getting a TypeError {
^
TypeError: util.template is not a function
at /Users/leahawasser/Documents/GitHub/allcontributors/cli/dist/util/git.js:57:30
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
Node.js v22.22.0but then when I try to fix that I get another error - circular reference. So i'm wondering if you see the same thing? Thank you!! |
| git: require('./git'), | ||
| markdown: require('./markdown'), | ||
| url: require('./url'), | ||
| template: require('./template'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ran into a problem here with template loading in time. So moving git to the end helped with that issue.
i'm a bit confused as there seems to be a circular import involved here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weirdddddd, ill give it a look and follow up 🫡
Ill check this one as well, and write a test so its not missed again 🫡 |
No apology needed! Were all running on little time here 😂 I'm down! though time commitment might be hit and miss, I'm game to help regardless. |
# Conflicts: # src/util/git.js # Conflicts: # src/generate/index.js # src/init/init-content.js
94d87eb to
3ad2a4a
Compare
|
Converted to a draft until i have time to check the above notes |

What: Remove dependency on lodash
Why:
In the attempt to move to esm, lodash is a blocker. There are alternatives such as lodash-esm, but alot of the use cases (except for template) are supported by native js.Additional benefit is the reduction in pkg size since lodash is massive!How: Migrate all lodash usages to native logic, and migrate template to use eta
Checklist:
Related #412