refactor: remove redux-invariant & redux-logging from production (#680)

* these middlewares are intend to be use only during development.
* also move a few packages from devDependencies to dependencies
This commit is contained in:
My 2019-03-19 13:05:38 -07:00 коммит произвёл My Ho
Родитель c06405ce08
Коммит cd01a4ac1d
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 20F354921724D773
4 изменённых файлов: 46 добавлений и 42 удалений

Просмотреть файл

@ -18,3 +18,4 @@ coverage:
ignore:
- "src/electron/start.js"
- "src/providers/export/tensorFlowRecords/tensorFlowRecordsProtoBuf_pb.js"
- "src/redux/store/store.ts"

46
package-lock.json сгенерированный
Просмотреть файл

@ -4581,7 +4581,8 @@
"deep-diff": {
"version": "0.3.8",
"resolved": "https://registry.npmjs.org/deep-diff/-/deep-diff-0.3.8.tgz",
"integrity": "sha1-wB3mPvsO7JeYgB1Ax+Da4ltYLIQ="
"integrity": "sha1-wB3mPvsO7JeYgB1Ax+Da4ltYLIQ=",
"dev": true
},
"deep-equal": {
"version": "1.0.1",
@ -5987,8 +5988,7 @@
"exenv": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/exenv/-/exenv-1.2.2.tgz",
"integrity": "sha1-KueOhdmJQVhnCwPUe+wfA72Ru50=",
"dev": true
"integrity": "sha1-KueOhdmJQVhnCwPUe+wfA72Ru50="
},
"exit": {
"version": "0.1.2",
@ -14430,12 +14430,11 @@
"integrity": "sha512-u7FDWtthB4rWibG/+mFbVd5FvdI20yde86qKGx4lVUTWmPlSWQ4QxbBIrrs+HnXGbxOUlUzTAP/VDmvCwaP2yA=="
},
"react-jsonschema-form": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/react-jsonschema-form/-/react-jsonschema-form-1.0.6.tgz",
"integrity": "sha512-F6441MjApWHiFU/98T+fM19kBP9Ib0b3GMOB5DNyXnfMYC35CLwaANeZsTHug0HAmXGxgG+caPZSxgJSAyPz1Q==",
"dev": true,
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/react-jsonschema-form/-/react-jsonschema-form-1.3.0.tgz",
"integrity": "sha512-WrlQh0urJGkR4Sb9hMJLwsTkVYVYbpgtofZ+JxiI9FSFXAIfCiCwhZ7R0zEKFADlah3KrN3qC6VFE6HtFk6aZg==",
"requires": {
"ajv": "^5.2.3",
"ajv": "^6.7.0",
"babel-runtime": "^6.26.0",
"core-js": "^2.5.7",
"lodash.topath": "^4.5.2",
@ -14443,28 +14442,15 @@
},
"dependencies": {
"ajv": {
"version": "5.5.2",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz",
"integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=",
"dev": true,
"version": "6.10.0",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.0.tgz",
"integrity": "sha512-nffhOpkymDECQyR0mnsUtoCE8RlX38G0rYP+wgLWFyZuUyuuojSSvi/+euOiQBIn63whYwYVIIH1TvE3tu4OEg==",
"requires": {
"co": "^4.6.0",
"fast-deep-equal": "^1.0.0",
"fast-deep-equal": "^2.0.1",
"fast-json-stable-stringify": "^2.0.0",
"json-schema-traverse": "^0.3.0"
"json-schema-traverse": "^0.4.1",
"uri-js": "^4.2.2"
}
},
"fast-deep-equal": {
"version": "1.1.0",
"resolved": "http://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz",
"integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ=",
"dev": true
},
"json-schema-traverse": {
"version": "0.3.1",
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz",
"integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=",
"dev": true
}
}
},
@ -14485,8 +14471,7 @@
"react-modal": {
"version": "3.8.1",
"resolved": "https://registry.npmjs.org/react-modal/-/react-modal-3.8.1.tgz",
"integrity": "sha1-cwD5Sm+SouF5lN4L5sy2FzRGTJ4=",
"dev": true,
"integrity": "sha512-aLKeZM9pgXpIKVwopRHMuvqKWiBajkqisDA8UzocdCF6S4fyKVfLWmZR5G1Q0ODBxxxxf2XIwiCP8G/11GJAuw==",
"requires": {
"exenv": "^1.2.0",
"prop-types": "^15.5.10",
@ -14498,7 +14483,6 @@
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/warning/-/warning-3.0.0.tgz",
"integrity": "sha1-MuU3fLVy3kqwR1O9+IIcAe1gW3w=",
"dev": true,
"requires": {
"loose-envify": "^1.0.0"
}
@ -15222,6 +15206,7 @@
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/redux-immutable-state-invariant/-/redux-immutable-state-invariant-2.1.0.tgz",
"integrity": "sha512-3czbDKs35FwiBRsx/3KabUk5zSOoTXC+cgVofGkpBNv3jQcqIe5JrHcF5AmVt7B/4hyJ8MijBIpCJ8cife6yJg==",
"dev": true,
"requires": {
"invariant": "^2.1.0",
"json-stringify-safe": "^5.0.1"
@ -15231,6 +15216,7 @@
"version": "3.0.6",
"resolved": "https://registry.npmjs.org/redux-logger/-/redux-logger-3.0.6.tgz",
"integrity": "sha1-91VZZvMJjzyIYExEnPC69XeCdL8=",
"dev": true,
"requires": {
"deep-diff": "^0.3.5"
}

Просмотреть файл

@ -28,7 +28,9 @@
"rc-menu": "^7.4.21",
"react": "^16.7.0",
"react-dom": "^16.7.0",
"react-jsonschema-form": "^1.3.0",
"react-localization": "^1.0.13",
"react-modal": "^3.8.1",
"react-redux": "^5.1.1",
"react-router-dom": "^4.3.1",
"react-scripts": "2.1.1",
@ -38,8 +40,6 @@
"react-vis": "^1.11.6",
"reactstrap": "^6.5.0",
"redux": "^4.0.1",
"redux-immutable-state-invariant": "^2.1.0",
"redux-logger": "^3.0.6",
"redux-thunk": "^2.3.0",
"rimraf": "^2.6.2",
"shortid": "^2.2.14",
@ -106,8 +106,8 @@
"jquery": "^3.3.1",
"node-sass": "^4.10.0",
"popper.js": "^1.14.6",
"react-jsonschema-form": "^1.0.6",
"react-modal": "^3.6.1",
"redux-immutable-state-invariant": "^2.1.0",
"redux-logger": "^3.0.6",
"redux-mock-store": "^1.5.3",
"ts-loader": "^5.3.0",
"tslint": "^5.11.0",

Просмотреть файл

@ -1,13 +1,12 @@
import { applyMiddleware, createStore, Store } from "redux";
import reduxImmutableStateInvarient from "redux-immutable-state-invariant";
import { createLogger } from "redux-logger";
import thunk from "redux-thunk";
import rootReducer from "../reducers";
import { IApplicationState } from "../../models/applicationState";
import { createLocalStorage, mergeInitialState } from "../middleware/localStorage";
import { mergeInitialState } from "../middleware/localStorage";
import { Env } from "../../common/environment";
/**
* Creates initial redux store from initial aplication state
* Creates initial redux store from initial application state
* @param initialState - Initial state of application
* @param useLocalStorage - Whether or not to use localStorage middleware
*/
@ -15,13 +14,31 @@ export default function createReduxStore(
initialState?: IApplicationState,
useLocalStorage: boolean = false): Store {
const paths: string[] = ["appSettings", "connections", "recentProjects"];
const middlewares = useLocalStorage
? applyMiddleware(thunk, reduxImmutableStateInvarient(), createLogger(), createLocalStorage({ paths }))
: applyMiddleware(thunk, reduxImmutableStateInvarient(), createLogger());
let middlewares = [thunk];
if (useLocalStorage) {
const localStorage = require("../middleware/localStorage");
const storage = localStorage.createLocalStorage({paths});
middlewares = [
...middlewares,
storage,
];
}
if (Env.get() === "development") {
const logger = require("redux-logger");
const reduxImmutableStateInvariant = require("redux-immutable-state-invariant");
middlewares = [
...middlewares,
reduxImmutableStateInvariant.default(),
logger.createLogger(),
];
}
return createStore(
rootReducer,
useLocalStorage ? mergeInitialState(initialState, paths) : initialState,
middlewares,
applyMiddleware(...middlewares),
);
}