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

Remove lodash from the xrpl package #2118

Closed
tequdev opened this issue Oct 25, 2022 · 8 comments · Fixed by #2378
Closed

Remove lodash from the xrpl package #2118

tequdev opened this issue Oct 25, 2022 · 8 comments · Fixed by #2378

Comments

@tequdev
Copy link
Contributor

tequdev commented Oct 25, 2022

When connecting to XRPL with Metamask Snap, due to a Hardend Javascript (SES) limitation, xrpl.js cannot be used (resulting in an error).

This is due to the lodash package.

After replacing the lodash package with just, the error no longer occurs, but I am not sure if this package can be included in xrpl.js.

https://github.com/angus-c/just

@ckniffen
Copy link
Collaborator

@develoQ I am up for removing lodash all together if the methods used can be done in modern js.

@WietseWind
Copy link
Member

@ckniffen Exactly, most things are very easy with some map/reduce/filter/... these days.

@mvadari
Copy link
Collaborator

mvadari commented Oct 26, 2022

I believe I tried to remove as much lodash as possible at some point, but in some places there were really nice functions like groupby and omitby that were hard to replace.

@WietseWind
Copy link
Member

WietseWind commented Oct 26, 2022

groupby would be very easy with a reduce fn?

Ugly piece of code, idea is clear, reducer could be a more generic fn of course.

const people = [
  { name: 'Nienke', gender: 'F' },
  { name: 'Wietse', gender: 'M' },
  { name: 'Arwen', gender: 'F' },
  { name: 'Quinn', gender: 'M' },
]

const sortedPeople = people.reduce((a, b) => {
  if (!a[b.gender]) {
    Object.assign(a, { [b.gender]: [] })
  }
  a[b.gender].push(b)
  return a
}, {})

image

@aruns05
Copy link

aruns05 commented Jul 6, 2023

@develoQ @intelliot is it done. I am keen in learning xrp and want to pick this

@ckniffen
Copy link
Collaborator

ckniffen commented Jul 6, 2023

@aruns05 when working on this the solution should reduce the webpack bundle size.

ckniffen added a commit that referenced this issue Jul 12, 2023
This will reduce the bundle size by ~23%(117kb).

Only 4 methods were used `flatten`, `flatMap`, `omitBy`, and `groupBy`.

`omitBy and `groupBy` were recreated while the es2019 implementations of
`flatten` and `flatMap` are used.

`lodash` is still used in the tests which is fine because it makes the
tests cleaner.

Closes #2118
@ckniffen
Copy link
Collaborator

@aruns05 I went ahead and did this as part of our effort to reduce the bundle size of xrpl.js. Let me know if I missed anything in #2378.

There will be more PRs to reduce size in the next few weeks.

@ckniffen ckniffen added 3.0 and removed help wanted labels Jul 17, 2023
ckniffen added a commit that referenced this issue Jul 25, 2023
This will reduce the bundle size by ~23%(117kb).

Only 4 methods were used `flatten`, `flatMap`, `omitBy`, and `groupBy`.

`omitBy and `groupBy` were recreated while the es2019 implementations of
`flatten` and `flatMap` are used.

`lodash` is still used in the tests which is fine because it makes the
tests cleaner.

Closes #2118
@ckniffen
Copy link
Collaborator

Done as part of 3.0

ckniffen added a commit that referenced this issue Aug 12, 2023
This will reduce the bundle size by ~23%(117kb).

Only 4 methods were used `flatten`, `flatMap`, `omitBy`, and `groupBy`.

`omitBy and `groupBy` were recreated while the es2019 implementations of
`flatten` and `flatMap` are used.

`lodash` is still used in the tests which is fine because it makes the
tests cleaner.

Closes #2118
ckniffen added a commit that referenced this issue Aug 15, 2023
This will reduce the bundle size by ~23%(117kb).

Only 4 methods were used `flatten`, `flatMap`, `omitBy`, and `groupBy`.

`omitBy and `groupBy` were recreated while the es2019 implementations of
`flatten` and `flatMap` are used.

`lodash` is still used in the tests which is fine because it makes the
tests cleaner.

Closes #2118
ckniffen added a commit that referenced this issue Aug 28, 2023
This will reduce the bundle size by ~23%(117kb).

Only 4 methods were used `flatten`, `flatMap`, `omitBy`, and `groupBy`.

`omitBy and `groupBy` were recreated while the es2019 implementations of
`flatten` and `flatMap` are used.

`lodash` is still used in the tests which is fine because it makes the
tests cleaner.

Closes #2118
ckniffen added a commit that referenced this issue Aug 28, 2023
This will reduce the bundle size by ~23%(117kb).

Only 4 methods were used `flatten`, `flatMap`, `omitBy`, and `groupBy`.

`omitBy and `groupBy` were recreated while the es2019 implementations of
`flatten` and `flatMap` are used.

`lodash` is still used in the tests which is fine because it makes the
tests cleaner.

Closes #2118
ckniffen added a commit that referenced this issue Sep 1, 2023
This will reduce the bundle size by ~23%(117kb).

Only 4 methods were used `flatten`, `flatMap`, `omitBy`, and `groupBy`.

`omitBy and `groupBy` were recreated while the es2019 implementations of
`flatten` and `flatMap` are used.

`lodash` is still used in the tests which is fine because it makes the
tests cleaner.

Closes #2118
ckniffen added a commit that referenced this issue Oct 5, 2023
This will reduce the bundle size by ~23%(117kb).

Only 4 methods were used `flatten`, `flatMap`, `omitBy`, and `groupBy`.

`omitBy and `groupBy` were recreated while the es2019 implementations of
`flatten` and `flatMap` are used.

`lodash` is still used in the tests which is fine because it makes the
tests cleaner.

Closes #2118
ckniffen added a commit that referenced this issue Oct 18, 2023
This will reduce the bundle size by ~23%(117kb).

Only 4 methods were used `flatten`, `flatMap`, `omitBy`, and `groupBy`.

`omitBy and `groupBy` were recreated while the es2019 implementations of
`flatten` and `flatMap` are used.

`lodash` is still used in the tests which is fine because it makes the
tests cleaner.

Closes #2118
ckniffen added a commit that referenced this issue Oct 25, 2023
This will reduce the bundle size by ~23%(117kb).

Only 4 methods were used `flatten`, `flatMap`, `omitBy`, and `groupBy`.

`omitBy and `groupBy` were recreated while the es2019 implementations of
`flatten` and `flatMap` are used.

`lodash` is still used in the tests which is fine because it makes the
tests cleaner.

Closes #2118
ckniffen added a commit that referenced this issue Nov 1, 2023
This will reduce the bundle size by ~23%(117kb).

Only 4 methods were used `flatten`, `flatMap`, `omitBy`, and `groupBy`.

`omitBy and `groupBy` were recreated while the es2019 implementations of
`flatten` and `flatMap` are used.

`lodash` is still used in the tests which is fine because it makes the
tests cleaner.

Closes #2118
ckniffen added a commit that referenced this issue Nov 30, 2023
This will reduce the bundle size by ~23%(117kb).

Only 4 methods were used `flatten`, `flatMap`, `omitBy`, and `groupBy`.

`omitBy and `groupBy` were recreated while the es2019 implementations of
`flatten` and `flatMap` are used.

`lodash` is still used in the tests which is fine because it makes the
tests cleaner.

Closes #2118
ckniffen added a commit that referenced this issue Feb 1, 2024
This will reduce the bundle size by ~23%(117kb).

Only 4 methods were used `flatten`, `flatMap`, `omitBy`, and `groupBy`.

`omitBy and `groupBy` were recreated while the es2019 implementations of
`flatten` and `flatMap` are used.

`lodash` is still used in the tests which is fine because it makes the
tests cleaner.

Closes #2118
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants