Move injectors code to external library - #2749
Conversation
|
That was just for local development and is needed when using |
eceacab to
e0cdec1
Compare
|
OK, this is now ready for review whenever anyone has a chance 馃檪 |
|
@julienben When you have some time, I also need help transferring redux-injectors to the reactboilerplate org as I explained in this comment: #2698 (comment) |
|
Oh, I think it dropped because I removed a lot of code that was well tested, I'll see if I can add some more tests elsewhere. |
|
I haven't taken a deep look at this PR's changes yet but maybe also check if some of the tests you removed were testing code outside the injectors? |
|
I checked and I don't think I removed any tests that were testing other code. I did remove some I fixed the coverage by adding some tests for LanguageProvider and Loadable. Also copied the folder |
|
Thanks!! Just one thing: Can you undo the copying of |
|
Ah I see, done |
There was a problem hiding this comment.
Hey! Looks awesome overall. Just left a few small comments.
Also:
- Make sure you merge the latest changes from dev and fix the conflicts. (Sorry, I merged a few PRs over the weekend 馃槄)
- Did you check if code-splitting/loadable still works the same? I'm just worried that we lost that feature partially since the containers import from
redux-injectorsand the store setup does too. To test it, compare the webpack output of a build from the dev branch and your branch. They won't be exactly the same but you should see one file for each container. (Use webpack analyze if necessary.) - Any comments on files in the app folder also apply to the internals of course.
One more thing you might want to do is run a regression test as described in deployment.md. Just make sure you uncomment the git commit line in clean.js.
| } | ||
|
|
||
| const sagaMiddleware = createSagaMiddleware(reduxSagaMonitorOptions); | ||
| const runSaga = sagaMiddleware.run; |
There was a problem hiding this comment.
Slightly prettier maybe:
const { run: runSaga } = sagaMiddleware;| expect(typeof store.runSaga).toBe('function'); | ||
| }); | ||
| it('should return a redux store', () => { | ||
| const store = configureStore({}, browserHistory); |
There was a problem hiding this comment.
Here browserHistory is undefined because it's an old obsolete API from react-router. You'll see it's been removed in #2791. You'll get a merge conflict here. You can just remove that argument and the test should pass just fine without it.
| }); | ||
| it('should return a redux store', () => { | ||
| const store = configureStore({}, browserHistory); | ||
| expect(typeof store).toBe('object'); |
There was a problem hiding this comment.
It's a bit light to say it should return a redux store but then just check that it's of type object. You should use some of the same checks that used to be in checkStore. And IMO there's nothing wrong with also checking for the presence of the keys which are added by redux-injectors (runSaga, injectedSagas, injectedReducers, and replaceReducer too or is that gone now?).
There was a problem hiding this comment.
So I added in a more robust test for checking if it returned a redux store. I'm hesitant to check for injectedSagas, injectedReducers, etc, because I'd consider that an internal implementation detail of redux-injectors. I'd like to be able to change that in the future if we need to without breaking react-boilerplate tests.
| 1. Remove `expect(() => checkStore({ ...store, injectedSagas: null })).toThrow();` | ||
| 2. Remove `expect(() => checkStore({ ...store, runSaga: null })).toThrow();` | ||
| 4. Remove statement `const runSaga = sagaMiddleware.run;` | ||
| 5. Remove `runSaga` from `createInjectorsEnhancer` params |
There was a problem hiding this comment.
Does this actually work? You can use redux-injectors without redux-saga?
There was a problem hiding this comment.
kind of. It throws some invariant warnings. I could probably disable them in redux-injectors
There was a problem hiding this comment.
Could it be done by checking which keys are passed to createInjectorsEnhancer? It can be like a configuration object for the injectors and will be especially useful later if/when you add more integrations to them.
There was a problem hiding this comment.
(No emergency here. We can merge this branch without this being present in injectors.)
There was a problem hiding this comment.
Possibly, I'd have to look into it more
There was a problem hiding this comment.
No rush. Just consider it for a future release of injectors.
| # `redux-injectors` | ||
|
|
||
| `redux-injectors` is a library we made ourselves by moving code we used to have | ||
| in the utils folder into a seperate library. It allows you to dynamically load |
There was a problem hiding this comment.
I would replace the first sentence with something like this:
redux-injectorsis an officialreact-boilerplatecompanion library. We built it so that it can be used and maintained independently fromreact-boilerplate.It allows you to dynamically load...
It feels slightly more professional IMO.
|
Looks like code-splitting is still working, I can see Regression test:Example App:
Internal Commands:
|
julienben
left a comment
There was a problem hiding this comment.
@BenLorantfy it's been a pleasure working with you on this. Thanks for your patience and your attention to detail! I hope you'll continue contributing!
|
No problem, thanks for your guidance and help with this 馃憤 |
|
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |



This PR moves the injector-related code to a new external library called
redux-injectors. For the full discussion on how we got here, see this issue. A few guiding notes:createReducer. It was only givenrunSagapreviously.templatesfolderdocs/js/redux-injectors.md. I linked to theredux-injectorsdocs for readers to view the full docs, but let me know if I should go into more detail in this file.redux-injectors(e.g.docs/js/redux-saga.md,docs/js/redux.md)docs/js/remove.mdredux-injectorsA few other links: