zalmoxisus / remote-redux-devtools

Redux DevTools remotely.

Home Page:http://zalmoxisus.github.io/monitoring/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

installing with --save-dev but importing it in files, won't deploy to production

DonGiulio opened this issue · comments

hello,

I've installed remote-redux-devtools in my app, following the readme, namely:

 npm install --save-dev remote-redux-devtools

which makes the lib available in dev, no worries about that.

I configured my store so to use the devtools:

import { createStore, applyMiddleware } from 'redux';
import { composeWithDevTools } from 'remote-redux-devtools';

const composeEnhancers = composeWithDevTools({ realtime: true, port: 8000 });
const store = createStore(reducer, /* preloadedState, */ composeEnhancers(
  applyMiddleware(...middleware),
  // other store enhancers if any
));

no problem with this either, as long I keep working only in development env.

As soon as I migrate to production, and deploy with RUN npm install --only=production, my store file is still trying to import the library, which is not available in prod. breaking the deployment.

I read somewhere that having devtools in production is not too bad, so my quick fix could be:

 npm install --save remote-redux-devtools

installing the lib in the production dependencies.

is there any better ways to do it?

@DonGiulio, you are not doing any environmental checks before importing or using the library, so your dependency on this module does not change with your environment unless you deliberately write these checks yourself. The code sample you showed us above would require that you install the module with npm install --save ... or yarn add ... because you are still referencing the module from production-facing code.

But you can install it with npm install --save ... or yarn add ... and the library knows how to disable itself automatically in production. If you want to turn it ON in production you can reference the Enabling section of the readme.