diff --git a/src/createDevTools.js b/src/createDevTools.js index 9e1381af..7d3c71fa 100644 --- a/src/createDevTools.js +++ b/src/createDevTools.js @@ -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) { ); } }; -} +}; diff --git a/src/index.js b/src/index.js index f302dc55..da746941 100644 --- a/src/index.js +++ b/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 +}; diff --git a/src/instrument.js b/src/instrument.js index 74916126..75f4ae20 100644 --- a/src/instrument.js +++ b/src/instrument.js @@ -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; diff --git a/src/persistState.js b/src/persistState.js index 0045db01..025e53d9 100644 --- a/src/persistState.js +++ b/src/persistState.js @@ -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 } }; }; -} +}; diff --git a/test/exports.spec.js b/test/exports.spec.js new file mode 100644 index 00000000..044ad7ba --- /dev/null +++ b/test/exports.spec.js @@ -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'); + }); +}); diff --git a/test/instrument.spec.js b/test/instrument.spec.js index 9db18896..2035adb6 100644 --- a/test/instrument.spec.js +++ b/test/instrument.spec.js @@ -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) { diff --git a/test/persistState.spec.js b/test/persistState.spec.js index c00c1c19..43bb0b6b 100644 --- a/test/persistState.spec.js +++ b/test/persistState.spec.js @@ -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;