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

v4 breaking change: lib dir with cjs files removed #3348

Closed
srghma opened this issue Jan 30, 2019 · 1 comment
Closed

v4 breaking change: lib dir with cjs files removed #3348

srghma opened this issue Jan 30, 2019 · 1 comment

Comments

@srghma
Copy link

srghma commented Jan 30, 2019

In v3 I used to import bindActionCreators from lib dir, that contained code compiled to cjs

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const bindActionCreators = _interopRequireDefault(require('redux/lib/bindActionCreators'))

In v4 this is no longer possible.


I cant use src dir too, because it's es

# will throw error because of the `export ....`
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const bindActionCreators = _interopRequireDefault(require('redux/src/bindActionCreators'))

Workaround is

const bindActionCreators = require('redux').bindActionCreators

but it's bad for project size

Q: why not to return cjs compiled files?

@timdorr
Copy link
Member

timdorr commented Jan 30, 2019

With a tree-shaking bundler, any unused imports will be automatically dropped. That won't apply to CJS files, but will work with ES modules.

This and other reasons are in the PR that changed this: #2358

@timdorr timdorr closed this as completed Jan 30, 2019
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

No branches or pull requests

2 participants