-
Notifications
You must be signed in to change notification settings - Fork 734
Infra/lodash babel plugin #1815
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
Conversation
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.
A general comment, I see a lot of places where you wrote arr
(mainly) or str
and not used the original name, was that intentional or some autogeneration?
Actually, I preferred to use |
I think that if you have a proper name (
Tough one, it might be more readable but it might be less readable with wrong name(s), it will also make the code a bit longer, I think this is generally better (unless you have really good names and \ or repeating functions in the same class). |
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.
Just FYI, there was no reason to change usages outside of the src
files (:
We only deliver the src files and we babel only them.
Anyway, Have you checked If the exported files got their lodash imports changed?
src/assets/Assets.ts
Outdated
_(b).keys().forEach((key) => { | ||
// @ts-ignore | ||
Object.defineProperty(a, key, Object.getOwnPropertyDescriptor(b, key)); | ||
}); | ||
_.flow(_.keys, arr => | ||
_.forEach(arr, key => { | ||
// @ts-ignore | ||
Object.defineProperty(a, key, Object.getOwnPropertyDescriptor(b, key)); | ||
}))(b); |
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.
Why did you change here if there's no _.chain?
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.
It's an unexplicit chain - https://lodash.com/docs/4.17.15#prototype-chain
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.
Wouldn't it be enough to just change it to _.keys(b).forEach
? Would that work?
I personally find the _.flow
API not very readable, so whenever possible, I'd use a different approach.
In this case we can also use vanilla JS and do Object.keys(b).forEach
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.
Done.
I changed to vanilla JS where I found it more readable and also renamed the parameters of the methods as Miki suggested.
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.
Cool! 👌
Yes, it does change the imports :) |
Description
Reduce bundle size using lodash babel plugin - https://github.com/lodash/babel-plugin-lodash
As part of it, I was needed to migrate all the usages of
_.chain
to_.flow
, since_.chain
brings all lodash with it.I recommend reviewing this PR by commit since one of the commits is only for formatting
WOAUILIB-2485
Changelog
Reduce bundle size using lodash babel plugin