nusmodifications / nusmods

🏫 Official course planning platform for National University of Singapore.
https://nusmods.com
MIT License
578 stars 315 forks source link

Cherry-pick lodash methods for smaller builds #307

Closed yangshun closed 7 years ago

yangshun commented 8 years ago

From @zyml on September 13, 2016 14:39

Consider importing the individual lodash methods to reduce webpack build file size.

Before:

import _ from 'lodash';

const foo = _.find(someArr, (item) => item.id === 'bar');

After:

import find from 'lodash/find';

const foo = find(someArr, (item) => item.id === 'bar');

However this is easier said than done because some of the functions use the seq chain. Might have to replace it with currying instead:

https://medium.com/making-internets/why-using-chain-is-a-mistake-9bc1f80d51ba

Copied from original issue: nusmodifications/nusmods-v3#14

yangshun commented 8 years ago

Heh that's on my to-do list (: Will help in tree shaking too I believe

On Sep 13, 2016 10:39 PM, "Melvin Lee" notifications@github.com wrote:

Consider importing the individual lodash methods to reduce webpack build file size.

Before:

import from 'lodash'; const foo = .find(someArr, (item) => item.id === 'bar');

After:

import find from 'lodash/find'; const foo = find(someArr, (item) => item.id === 'bar');

However this is easier said than done because some of the functions use the seq chain. Might have to replace it with currying instead:

https://medium.com/making-internets/why-using-chain-is-a-mistake-9bc1f80d51ba

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

yangshun commented 7 years ago

Fixed via 096beb7aa5b10ecfcbad8d5aad958831af0b9707. Cheated and used https://github.com/lodash/babel-plugin-lodash instead.