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

Changing combineReducers breaks reducer generator #32

Open
Primajin opened this issue Jul 22, 2016 · 10 comments
Open

Changing combineReducers breaks reducer generator #32

Primajin opened this issue Jul 22, 2016 · 10 comments

Comments

@Primajin
Copy link

Primajin commented Jul 22, 2016

So I was using the yo react-webpack-redux:reducer myReducer command with no problems.
Since you suggested using react-router-redux, I implemented it into my reducer/index.js with a simple import of import { routerReducer } from 'react-router-redux'; and changed the last line from

module.exports = combineReducers(reducers);

to

module.exports = combineReducers({...reducers, routing: routerReducer});

When I now try to run the yo command it fails silently. Changing the last line back to what it was before while leaving the (now unused) import inside the file - and the command works again.

Now what I find very curious about is, that this line does not change when adding new reducers, and thus should not cause the generator to fail nor should it fail silently like this.

Let me know if you need any more information.
Cheers

@Primajin
Copy link
Author

Primajin commented Jul 22, 2016

Same Problem seems to be for actions aswell. It starts to link files, but then fails somewhere and leaving behind files that are linked but do not exist and so on :(

@stylesuxx
Copy link
Owner

Give me a couple of days to look into this, might have to do with ast parsing.

@stylesuxx stylesuxx added the bug label Jul 26, 2016
@juegas
Copy link

juegas commented Aug 1, 2016

Any update on this issue?

I'm adding the routerReducer as the first obj pair in src/reducers/index.js for the time being. The yo command still fails but src/reducers/index.js still populates correctly from me.

  0 import { combineReducers } from 'redux';
  1 import { routerReducer } from 'react-router-redux';
  2 /* Populated by react-webpack-redux:reducer */
  3 const reducers = {
  4   routing: routerReducer
  5 };
  6 module.exports = combineReducers(reducers);

@stylesuxx
Copy link
Owner

Alright, this seems to be multiple issues at once.

The spread operator ... seems to be a problem when parsing the abstract syntax tree. So @Primajin instead of

module.exports = combineReducers({...reducers, routing: routerReducer});

simply add the router reducer to the reducers like @juegas does.
On my side the parser throws an error regarding this - strange that it does not on your side. Could you maybe tell me more about your system: OS, node and npm version?

After adding the router reducer like so, I have absolutely no problems adding reducers / actions.

@juegas which yo command fails on your side exactly?

Could any of you share their project, so I can take a look? I tried re creating the issue from a fresh setup from the master branch and everything is working as it should. So I can not reproduce the issue on my side:

yo react-webpack-redux
npm install --save react-router-redux
// import in  ./src/reducers/index.js
// add router reducer to reducers as 1st item
yo react-webpack-redux:reducer test_1
yo react-webpack-redux:action test_1

@Primajin
Copy link
Author

Primajin commented Aug 1, 2016

Allright, I have this on my machine at work and will give you all the infos as soon as I'm back in the office tomorrow morning (CEST)

@juegas
Copy link

juegas commented Aug 2, 2016

yo:Action is adjusting ./actions/const.js && ./containers/App.js and creating ./actions/name.js

yo:Reducer is failing silently. It is successfully adding name: require('../reducers/name.js') to ./reducers/index.js but then fails creating the reducer & test files.

@Primajin
Copy link
Author

Primajin commented Aug 2, 2016

@stylesuxx OK after adding the router reducer like you guys suggested it works as expected.

It does not fail for me anymore, but if it does, it does it silently and leaves back half way created files which is not so cool. So at least that would be great to get rid of.

I'm on a MBP with latest OSX.
NPM is 3.8.6, Node is 5.11.1

@juegas
Copy link

juegas commented Aug 2, 2016

I'm also on an MBP with the latest OSX
NPM is 3.9.5, Node is 4.0.0

@stylesuxx
Copy link
Owner

OK, so both on you are on mac. Interesting. I am on Linux and get an error -_- will be awesome to debug :-D I guess I should be able to get rid of it when I change AST parsing to acorn, but right now I have not enough time to dive into that.

So @Primajin is good now as I understand.

@juegas you are still experiencing problems?

@juegas
Copy link

juegas commented Aug 2, 2016

@stylesuxx well yea the issue remains but it doesn't block me from my experimentations with react-rout + redux-router.

gl looking into it and thanks

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

No branches or pull requests

3 participants