Skip to content

Go back to CommonJS modules for now... #214

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/createDevTools.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -60,4 +61,4 @@ export default function createDevTools(children) {
);
}
};
}
};
14 changes: 11 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -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
};
14 changes: 9 additions & 5 deletions src/instrument.js
Original file line number Diff line number Diff line change
@@ -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',
Expand All @@ -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() };
},
Expand Down Expand Up @@ -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);
Expand All @@ -342,4 +343,7 @@ export default function instrument(monitorReducer = () => null) {
const liftedStore = createStore(liftReducer(reducer));
return unliftStore(liftedStore, liftReducer);
};
}
};

module.exports.ActionTypes = ActionTypes;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this kosher for achieving a default and named exports?

module.exports.ActionCreators = ActionCreators;
8 changes: 4 additions & 4 deletions src/persistState.js
Original file line number Diff line number Diff line change
@@ -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);
}
Expand Down Expand Up @@ -57,4 +57,4 @@ export default function persistState(sessionId, deserializeState = identity, des
}
};
};
}
};
21 changes: 21 additions & 0 deletions test/exports.spec.js
Original file line number Diff line number Diff line change
@@ -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');
});
});
8 changes: 5 additions & 3 deletions test/instrument.spec.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions test/persistState.spec.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down