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

refactor: replace lodash with remeda #1952

Closed
wants to merge 23 commits into from
Closed

refactor: replace lodash with remeda #1952

wants to merge 23 commits into from

Conversation

bd82
Copy link
Member

@bd82 bd82 commented Jul 2, 2023

No description provided.

@mattbishop
Copy link

Did you have a look at TS-belt for this change? They claim to be much faster and support tree-shaking. https://mobily.github.io/ts-belt/

@bd82
Copy link
Member Author

bd82 commented Jul 3, 2023

Thanks @mattbishop I was not aware of ts-belt
Both libraries support tree-shaking so the differences would be around performance and active / on-going maintenance.

I will probably attempt to finish the migration to remeda as I am pleased with what I am seeing so far
and it seems to be more actively developed.

If there are any performance regressions I will consider other options.

Potential advantage of ts-belt may be to speed up parser init time, but that may be considered as a separate future (low priority) track.

@bd82
Copy link
Member Author

bd82 commented Jul 4, 2023

While the size has decreased by ~20KB the performance of lexer/parser init time has degraded severely.
image

@bd82
Copy link
Member Author

bd82 commented Jul 4, 2023

Webpack output:

asset chevrotain.min.js 153 KiB [compared for emit] [minimized] (name: main) 1 related asset
hidden modules 369 KiB 55 modules
cacheable modules 22 KiB
  ../../node_modules/.pnpm/[email protected]/node_modules/remeda/dist/commonjs/isEmpty.js 502 bytes [built] [code generated]
  ../../node_modules/.pnpm/[email protected]/node_modules/remeda/dist/commonjs/isArray.js 189 bytes [built] [code generated]
  ../../node_modules/.pnpm/[email protected]/node_modules/remeda/dist/commonjs/isString.js 198 bytes [built] [code generated]
  ../../node_modules/.pnpm/[email protected]/node_modules/remeda/dist/commonjs/map.js 1.11 KiB [built] [code generated]
  ../../node_modules/.pnpm/[email protected]/node_modules/remeda/dist/commonjs/forEach.js 1.25 KiB [built] [code generated]
  ../../node_modules/.pnpm/[email protected]/node_modules/remeda/dist/commonjs/values.js 189 bytes [built] [code generated]
  ../../node_modules/.pnpm/[email protected]/node_modules/remeda/dist/commonjs/flatten.js 926 bytes [built] [code generated]
  ../../node_modules/.pnpm/[email protected]/node_modules/remeda/dist/commonjs/forEachObj.js 876 bytes [built] [code generated]
  ../../node_modules/.pnpm/[email protected]/node_modules/remeda/dist/commonjs/first.js 696 bytes [built] [code generated]
  ../../node_modules/.pnpm/[email protected]/node_modules/remeda/dist/commonjs/merge.js 291 bytes [built] [code generated]
  ../../node_modules/.pnpm/[email protected]/node_modules/remeda/dist/commonjs/reject.js 1.32 KiB [built] [code generated]
  ../../node_modules/.pnpm/[email protected]/node_modules/remeda/dist/commonjs/keys.js 270 bytes [built] [code generated]
  ../../node_modules/.pnpm/[email protected]/node_modules/remeda/dist/commonjs/reduce.js 689 bytes [built] [code generated]
  ../../node_modules/.pnpm/[email protected]/node_modules/remeda/dist/commonjs/noop.js 167 bytes [built] [code generated]
  ../../node_modules/.pnpm/[email protected]/node_modules/remeda/dist/commonjs/last.js 286 bytes [built] [code generated]
  ../../node_modules/.pnpm/[email protected]/node_modules/remeda/dist/commonjs/identity.js 180 bytes [built] [code generated]
  ../../node_modules/.pnpm/[email protected]/node_modules/remeda/dist/commonjs/flatMap.js 977 bytes [built] [code generated]
  ../../node_modules/.pnpm/[email protected]/node_modules/remeda/dist/commonjs/isObject.js 232 bytes [built] [code generated]
  ../../node_modules/.pnpm/[email protected]/node_modules/remeda/dist/commonjs/purry.js 1010 bytes [built] [code generated]
  ../../node_modules/.pnpm/[email protected]/node_modules/remeda/dist/commonjs/_reduceLazy.js 589 bytes [built] [code generated]
  ../../node_modules/.pnpm/[email protected]/node_modules/remeda/dist/commonjs/_toLazyIndexed.js 229 bytes [built] [code generated]
  ../../node_modules/.pnpm/[email protected]/node_modules/remeda/dist/commonjs/drop.js 863 bytes [built] [code generated]
  ../../node_modules/.pnpm/[email protected]/node_modules/is-regexp/index.js 102 bytes [built] [code generated]
  ../../node_modules/.pnpm/[email protected]/node_modules/remeda/dist/commonjs/pickBy.js 492 bytes [built] [code generated]
  ../../node_modules/.pnpm/[email protected]/node_modules/remeda/dist/commonjs/uniq.js 875 bytes [built] [code generated]
  ../../node_modules/.pnpm/[email protected]/node_modules/remeda/dist/commonjs/compact.js 244 bytes [built] [code generated]
  ../../node_modules/.pnpm/[email protected]/node_modules/remeda/dist/commonjs/difference.js 973 bytes [built] [code generated]
  ../../node_modules/.pnpm/[email protected]/node_modules/remeda/dist/commonjs/isFunction.js 208 bytes [built] [code generated]
  ../../node_modules/.pnpm/[email protected]/node_modules/remeda/dist/commonjs/find.js 1.2 KiB [built] [code generated]
  ../../node_modules/.pnpm/[email protected]/node_modules/remeda/dist/commonjs/filter.js 1.32 KiB [built] [code generated]
  ../../node_modules/.pnpm/[email protected]/node_modules/remeda/dist/commonjs/groupBy.js 964 bytes [built] [code generated]
  ../../node_modules/.pnpm/[email protected]/node_modules/remeda/dist/commonjs/dropLast.js 772 bytes [built] [code generated]
  ../../node_modules/.pnpm/[email protected]/node_modules/remeda/dist/commonjs/clone.js 1.42 KiB [built] [code generated]
  ../../node_modules/.pnpm/[email protected]/node_modules/remeda/dist/commonjs/isTruthy.js 180 bytes [built] [code generated]
  ../../node_modules/.pnpm/[email protected]/node_modules/remeda/dist/commonjs/_toSingle.js 208 bytes [built] [code generated]
  ../../node_modules/.pnpm/[email protected]/node_modules/remeda/dist/commonjs/type.js 303 bytes [built] [code generated]
webpack 5.75.0 compiled successfully in 1318 ms

@bd82
Copy link
Member Author

bd82 commented Jul 6, 2023

libraryTarget = ES2015 + ESM + lodash-es will reduce chevrotain.min.js to approx 135Kb.
So this is no longer needed

@bd82 bd82 closed this Jul 6, 2023
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.

2 participants