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

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

Open
DonGiulio opened this issue Sep 22, 2018 · 1 comment

Comments

@DonGiulio
Copy link

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?

@radiovisual
Copy link

radiovisual commented Jan 8, 2019

@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.

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