mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2024-12-01 14:03:52 +03:00
Go back to CommonJS modules for now until https://phabricator.babeljs.io/T2817 is resolved.
This commit is contained in:
parent
a1e3d9ec3e
commit
384a9118af
|
@ -1,8 +1,9 @@
|
|||
import React, { Children, Component, PropTypes } from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import instrument from './instrument';
|
||||
const React = require('react');
|
||||
const { Children, Component, PropTypes } = require('react');
|
||||
const { connect } = require('react-redux');
|
||||
const instrument = require('./instrument');
|
||||
|
||||
export default function createDevTools(children) {
|
||||
module.exports = function createDevTools(children) {
|
||||
const monitorElement = Children.only(children);
|
||||
const monitorProps = monitorElement.props;
|
||||
const Monitor = monitorElement.type;
|
||||
|
@ -60,4 +61,4 @@ export default function createDevTools(children) {
|
|||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
|
14
src/index.js
14
src/index.js
|
@ -1,3 +1,11 @@
|
|||
export { default as instrument, ActionCreators, ActionTypes } from './instrument';
|
||||
export { default as persistState } from './persistState';
|
||||
export { default as createDevTools } from './createDevTools';
|
||||
const instrument = require('./instrument');
|
||||
const persistState = require('./persistState');
|
||||
const createDevTools = require('./createDevTools');
|
||||
|
||||
module.exports = {
|
||||
instrument,
|
||||
ActionCreators: instrument.ActionCreators,
|
||||
ActionTypes: instrument.ActionTypes,
|
||||
persistState,
|
||||
createDevTools
|
||||
};
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import difference from 'lodash/array/difference';
|
||||
const difference = require('lodash/array/difference');
|
||||
|
||||
export const ActionTypes = {
|
||||
|
||||
const ActionTypes = {
|
||||
PERFORM_ACTION: 'PERFORM_ACTION',
|
||||
RESET: 'RESET',
|
||||
ROLLBACK: 'ROLLBACK',
|
||||
|
@ -14,7 +15,7 @@ export const ActionTypes = {
|
|||
/**
|
||||
* Action creators to change the History state.
|
||||
*/
|
||||
export const ActionCreators = {
|
||||
const ActionCreators = {
|
||||
performAction(action) {
|
||||
return { type: ActionTypes.PERFORM_ACTION, action, timestamp: Date.now() };
|
||||
},
|
||||
|
@ -333,7 +334,7 @@ function unliftStore(liftedStore, liftReducer) {
|
|||
/**
|
||||
* Redux instrumentation store enhancer.
|
||||
*/
|
||||
export default function instrument(monitorReducer = () => null) {
|
||||
module.exports = function instrument(monitorReducer = () => null) {
|
||||
return createStore => (reducer, initialState) => {
|
||||
function liftReducer(r) {
|
||||
return liftReducerWith(r, initialState, monitorReducer);
|
||||
|
@ -342,4 +343,7 @@ export default function instrument(monitorReducer = () => null) {
|
|||
const liftedStore = createStore(liftReducer(reducer));
|
||||
return unliftStore(liftedStore, liftReducer);
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
module.exports.ActionTypes = ActionTypes;
|
||||
module.exports.ActionCreators = ActionCreators;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import mapValues from 'lodash/object/mapValues';
|
||||
import identity from 'lodash/utility/identity';
|
||||
const mapValues = require('lodash/object/mapValues');
|
||||
const identity = require('lodash/utility/identity');
|
||||
|
||||
export default function persistState(sessionId, deserializeState = identity, deserializeAction = identity) {
|
||||
module.exports = function persistState(sessionId, deserializeState = identity, deserializeAction = identity) {
|
||||
if (!sessionId) {
|
||||
return next => (...args) => next(...args);
|
||||
}
|
||||
|
@ -57,4 +57,4 @@ export default function persistState(sessionId, deserializeState = identity, des
|
|||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
};
|
||||
|
|
21
test/exports.spec.js
Normal file
21
test/exports.spec.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
const expect = require('expect');
|
||||
|
||||
const { instrument, ActionCreators, ActionTypes, persistState, createDevTools} = require('../src');
|
||||
|
||||
describe('exports are the correct types', () => {
|
||||
it('instrument', () => {
|
||||
expect(instrument).toBeA('function');
|
||||
});
|
||||
it('ActionCreators', () => {
|
||||
expect(ActionCreators).toBeA('object');
|
||||
});
|
||||
it('ActionTypes', () => {
|
||||
expect(ActionTypes).toBeA('object');
|
||||
});
|
||||
it('persistState', () => {
|
||||
expect(persistState).toBeA('function');
|
||||
});
|
||||
it('createDevTools', () => {
|
||||
expect(createDevTools).toBeA('function');
|
||||
});
|
||||
});
|
|
@ -1,6 +1,8 @@
|
|||
import expect, { spyOn } from 'expect';
|
||||
import { createStore } from 'redux';
|
||||
import instrument, { ActionCreators } from '../src/instrument';
|
||||
const expect = require('expect');
|
||||
const { spyOn } = expect;
|
||||
const {createStore } = require('redux');
|
||||
const instrument = require('../src/instrument');
|
||||
const { ActionCreators } = instrument;
|
||||
|
||||
function counter(state = 0, action) {
|
||||
switch (action.type) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import expect from 'expect';
|
||||
import { instrument, persistState } from '../src';
|
||||
import { compose, createStore } from 'redux';
|
||||
const expect = require('expect');
|
||||
const { instrument, persistState } = require('../src');
|
||||
const { compose, createStore } = require('redux');
|
||||
|
||||
describe('persistState', () => {
|
||||
let savedLocalStorage = global.localStorage;
|
||||
|
|
Loading…
Reference in New Issue
Block a user