Connected-react-router: Move immutable.js to peer dependencies

Created on 18 Apr 2019  路  13Comments  路  Source: supasate/connected-react-router

Currently connected-react-router requires immutable v3 as dependency. If somebody uses immutable v4, both v3 and v4 are included in the bundle

Most helpful comment

How come this library even has a dependency on immutable? I'd like to use this library, but do I need to ship essentially all of immutable.js just for that? Should I just look elsewhere if want something with a low bundle-size impact?

Or will immutable only end up in my bundle if I include something specific?

All 13 comments

And also it does so by including immutable.js instead of immutable.es.js which cause not supporting tree shaking at all.

Or just use https://github.com/immerjs/immer instead of depending on immutable.js

How come this library even has a dependency on immutable? I'd like to use this library, but do I need to ship essentially all of immutable.js just for that? Should I just look elsewhere if want something with a low bundle-size impact?

Or will immutable only end up in my bundle if I include something specific?

How come this library even has a dependency on immutable? I'd like to use this library, but do I need to ship essentially all of immutable.js just for that? Should I just look elsewhere if want something with a low bundle-size impact?

Or will immutable only end up in my bundle if I include something specific?

Immutable will be included only if you will import connected-react-router/immutable

Hi, this is a big problem for us too. Because this library installs immutable, then another library that has it as an optional dependency goes "nice I guess we're using immutable now then?" and pulls the entire library into the webpack bundle.

If you could make this an optional dependency that would be amazing.

^ the "other" library is redux-form by the way

How come this library even has a dependency on immutable? I'd like to use this library, but do I need to ship essentially all of immutable.js just for that? Should I just look elsewhere if want something with a low bundle-size impact?
Or will immutable only end up in my bundle if I include something specific?

Immutable will be included only if you will import connected-react-router/immutable

I only import { ConnectedRouter, connectRouter, push, routerMiddleware } from 'connected-react-router' but I have immutable/dist in my bundle.

connected-react-router is the only lib which has immutable in deps in my project

it downloads the library, but the library is not added into your bundle unless you load immutable version of this module

it downloads the library, but the library is not added into your bundle unless you load immutable version of this module

Sorry, you are right. It was redux-form

My dirty workaround for this btw is to add this script to my package.json:

"postinstall": "rm -rf node_modules/immutable",

:laughing:

My dirty workaround for this btw is to add this script to my package.json:

"postinstall": "rm -rf node_modules/immutable",

馃槅

This fix is kind of useless. If you don't use "connected-react-router/immutable," it will not be loaded in your bundle. If you use it - your build will be broken

To clarify, the workaround was for when using connected-react-router as well as redux-form (which dumps immutable in your bundle if it exists in your node modules)

Fixed in #390.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alexseitsinger picture alexseitsinger  路  3Comments

nickvoronin-ellation picture nickvoronin-ellation  路  5Comments

bmueller-sykes picture bmueller-sykes  路  4Comments

tonoslav picture tonoslav  路  4Comments

preciselywilliam picture preciselywilliam  路  4Comments