mobx-devtools
mobx-devtools copied to clipboard
conditional import based on NODE_ENV
I am creating my store this way:
export const createStore = (initial: StoreSnapshotIn = {}) => {
const store = Store.create(initial);
if (process.env.NODE_ENV === "development") {
const makeInspectable = require("mobx-devtools-mst").default;
makeInspectable(store);
}
return store;
};
Note that i'm doing a deferred import for makeInspectable. I can't really tell if the build would ignore this anyway if NODE_ENV !== 'development, so my question is: is this necessary?
This is not really necessary becasue mobx-devtools-mst module is just few lines of code, so it won't hurt https://github.com/mobxjs/mobx-devtools/blob/master/packages/mobx-devtools-mst/src/index.js