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

fix: add babel-plugin-add-module-exports for default export #41

Merged
merged 1 commit into from Dec 14, 2015

Conversation

ahdinosaur
Copy link
Contributor

upgrading to Babel 6 silently broke everyone using redux-thunk with CommonJS require and module.exports due to Kill CommonJS default export behaviour - babel/babel#2212. this fixes that (unintended?) breaking change.

see also:

[upgrading to Babel 6](reduxjs@6577fb6) silently broke everyone using `redux-thunk` with CommonJS `require` and `module.exports` due to [Kill CommonJS default export behaviour - babel/babel#2212](https://phabricator.babeljs.io/T2212). this fixes that (unintended?) breaking change.

see also:

- LogRocket/redux-logger@0b34fb9
- https://github.com/59naga/babel-plugin-add-module-exports
@ahdinosaur
Copy link
Contributor Author

for reference to anyone who is affected, here's the error:

const { applyMiddleware } = require('redux')
const thunk = require('redux-thunk')

applyMiddleware(thunk)
 TypeError: middleware is not a function
     at /app/node_modules/redux/lib/utils/applyMiddleware.js:50:16
     at Array.map (native)
     at /app/node_modules/redux/lib/utils/applyMiddleware.js:49:27
...

until this PR is merged, the quick hack is to do:

const thunk = require('redux-thunk').default

gaearon added a commit that referenced this pull request Dec 14, 2015
fix: add babel-plugin-add-module-exports for default export
@gaearon gaearon merged commit ee42523 into reduxjs:master Dec 14, 2015
@gaearon
Copy link
Collaborator

gaearon commented Dec 14, 2015

D'oh. Thanks!

ahdinosaur added a commit to ahdinosaur/redux-devtools-dock-monitor that referenced this pull request Dec 14, 2015
[upgrading to Babel 6](gaearon@766cdad) silently broke everyone using `redux-devtools-dock-monitor` with CommonJS `require` and `module.exports` due to [Kill CommonJS default export behaviour - babel/babel#2212](https://phabricator.babeljs.io/T2212). this fixes that unintended breaking change.

repeat of reduxjs/redux-thunk#41
ahdinosaur added a commit to ahdinosaur/redux-devtools-log-monitor that referenced this pull request Dec 14, 2015
[upgrading to Babel 6](gaearon#10) silently broke everyone using `redux-devtools-log-monitor` with CommonJS `require` and `module.exports` due to [Kill CommonJS default export behaviour - babel/babel#2212](https://phabricator.babeljs.io/T2212). this fixes that unintended breaking change.

repeat of reduxjs/redux-thunk#41
@ahdinosaur
Copy link
Contributor Author

@gaearon woo awesome, thanks for merging and re-publishing. 😃

here's two more: gaearon/redux-devtools-dock-monitor#18 and gaearon/redux-devtools-log-monitor#19.

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.

None yet

2 participants