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

πŸ‘· Removing lodash dependencies #396

Merged
merged 6 commits into from
May 27, 2020
Merged

Conversation

thibthib
Copy link
Member

@thibthib thibthib commented May 20, 2020

Motivation

The SDK code being quite large – as you can see on bundlephobia – I wanted to remove lodash as it's quite big and can easily be replaced with something smaller.

Changes

Two dependencies got replaced:

  • lodash.merge got replaced with a function that does the same thing, just without the ability to merge objects with circular references
  • lodash.assign got replaced with simple loop re-assigning keys

Testing

Everything should work exactly the same, but happy to write more tests if needed.


I have gone over the contributing documentation.

@thibthib thibthib requested a review from a team as a code owner May 20, 2020 15:50
@bits-bot
Copy link

bits-bot commented May 20, 2020

CLA assistant check
All committers have signed the CLA.

@thibthib thibthib force-pushed the thibaut/replace-lodash branch 2 times, most recently from 1bf09fd to 10defdd Compare May 22, 2020 13:35
packages/logs/src/logger.ts Outdated Show resolved Hide resolved
packages/rum/src/rum.entry.ts Outdated Show resolved Hide resolved
packages/core/src/utils.ts Show resolved Hide resolved
packages/core/src/utils.ts Outdated Show resolved Hide resolved
packages/core/src/utils.ts Outdated Show resolved Hide resolved
@thibthib thibthib requested a review from bcaudan May 22, 2020 15:34
)
}
if (isContext(value1) && isContext(value2)) {
return Object.keys(value2).reduce(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A for/in loop or a (polyfilled) usage of Object.fromEntries would be easier to understand and faster here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not really clear what's polyfilled and what is not πŸ˜… And I'm not sure ObjectEntries would be faster as it'll be doing an extra map on the array

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not polyfilled. It would have a lower complexity, since you recreate the whole object for each key. Anyway, a for/in could do the trick :)

Copy link
Contributor

@glorieux glorieux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
Just one question.

yarn.lock Show resolved Hide resolved
@bcaudan bcaudan merged commit 957d93c into master May 27, 2020
@bcaudan bcaudan deleted the thibaut/replace-lodash branch May 27, 2020 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants