Go back to CommonJS modules for now until https://phabricator.babeljs.io/T2817 is resolved.

This commit is contained in:
Kevan Ahlquist 2015-12-30 01:49:33 -06:00
parent a1e3d9ec3e
commit 384a9118af
7 changed files with 59 additions and 23 deletions

View File

@ -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) {
);
}
};
}
};

View File

@ -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
};

View File

@ -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;

View File

@ -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
View 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');
});
});

View File

@ -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) {

View File

@ -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;