Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Use import for lodash/flowRight to allow for tree shaking #2306

Closed
Pajn opened this issue Aug 25, 2018 · 3 comments · Fixed by #2332
Closed

Use import for lodash/flowRight to allow for tree shaking #2306

Pajn opened this issue Aug 25, 2018 · 3 comments · Fixed by #2332

Comments

@Pajn
Copy link
Contributor

Pajn commented Aug 25, 2018

browser.ts exports lodash/flowRight as compose, however it import this module using require()which makes it impossible for Webpack to treeshake it away. This causes quite a bit of lodash to be pulled in even though compose from react-apollo is not used at all. Replacing this require call with import should allow it to be treeshaked and its cost only paid if actually used.

const compose = require('lodash/flowRight');

@rosskevin
Copy link
Contributor

You could PR this just like #2045. At least it would solve the problem in the next patch/minor release before it is removed entirely.

@rosskevin rosskevin changed the title Can lodash be imported using ES module syntax? Use import for lodash/flowRight to allow for tree shaking Aug 31, 2018
@Pajn
Copy link
Contributor Author

Pajn commented Aug 31, 2018

The thing is that I have no idea if changing it to

import * as compose from 'lodash/flowRight';
export { compose };

would break stuff for some users.

I have not used require imports since Typescript 1.6 is released so there might very well be minor differences that I have forgotten.
Since you use ES imports everywhere else they question is rather, why isn't this one? Is there a reason?

@Pajn
Copy link
Contributor Author

Pajn commented Aug 31, 2018

Okey, types from DefinitlyTyped where bad. That I guess that was simply the reason. See the PR

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants