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

Convert the Source to ES Modules #11389

Merged
merged 23 commits into from Nov 2, 2017
Commits
Jump to file or symbol
Failed to load files and symbols.
+57 −68
Diff settings

Always

Just for now

Viewing a subset of changes. View all

Convert events to ES modules

  • Loading branch information...
gaearon committed Oct 31, 2017
commit 1e95d12a6098553047e851bbd0a4109039bc5395
@@ -7,13 +7,13 @@
'use strict';
var ReactErrorUtils = require('shared/ReactErrorUtils');
var invariant = require('fbjs/lib/invariant');
import ReactErrorUtils from 'shared/ReactErrorUtils';
import invariant from 'fbjs/lib/invariant';
var EventPluginRegistry = require('./EventPluginRegistry');
var EventPluginUtils = require('./EventPluginUtils');
var accumulateInto = require('./accumulateInto');
var forEachAccumulated = require('./forEachAccumulated');
import EventPluginRegistry from './EventPluginRegistry';
import EventPluginUtils from './EventPluginUtils';
import accumulateInto from './accumulateInto';
import forEachAccumulated from './forEachAccumulated';
/**
* Internal queue of events that have accumulated their dispatches and are
@@ -220,4 +220,4 @@ var EventPluginHub = {
},
};
module.exports = EventPluginHub;
export default EventPluginHub;
@@ -16,7 +16,7 @@ import type {
PluginModule,
} from './PluginModuleType';
var invariant = require('fbjs/lib/invariant');
import invariant from 'fbjs/lib/invariant';
type NamesToPlugins = {[key: PluginName]: PluginModule<AnyNativeEvent>};
type EventPluginOrder = null | Array<PluginName>;
@@ -251,4 +251,4 @@ var EventPluginRegistry = {
},
};
module.exports = EventPluginRegistry;
export default EventPluginRegistry;
@@ -7,12 +7,9 @@
'use strict';
var ReactErrorUtils = require('shared/ReactErrorUtils');
var invariant = require('fbjs/lib/invariant');
if (__DEV__) {
var warning = require('fbjs/lib/warning');
}
import ReactErrorUtils from 'shared/ReactErrorUtils';
import invariant from 'fbjs/lib/invariant';
import warning from 'fbjs/lib/warning';
/**
* Injected dependencies:
@@ -228,4 +225,4 @@ var EventPluginUtils = {
injection: injection,
};
module.exports = EventPluginUtils;
export default EventPluginUtils;
@@ -7,20 +7,17 @@
'use strict';
var ReactTreeTraversal = require('shared/ReactTreeTraversal');
import ReactTreeTraversal from 'shared/ReactTreeTraversal';
import warning from 'fbjs/lib/warning';
var EventPluginHub = require('./EventPluginHub');
var accumulateInto = require('./accumulateInto');
var forEachAccumulated = require('./forEachAccumulated');
import EventPluginHub from './EventPluginHub';
import accumulateInto from './accumulateInto';
import forEachAccumulated from './forEachAccumulated';
type PropagationPhases = 'bubbled' | 'captured';
var getListener = EventPluginHub.getListener;
if (__DEV__) {
var warning = require('fbjs/lib/warning');
}
/**
* Some event types have a notion of different registration names for different
* "phases" of propagation. This finds listeners by a given phase.
@@ -155,4 +152,4 @@ var EventPropagators = {
accumulateEnterLeaveDispatches: accumulateEnterLeaveDispatches,
};
module.exports = EventPropagators;
export default EventPropagators;
@@ -7,9 +7,9 @@
'use strict';
var invariant = require('fbjs/lib/invariant');
import invariant from 'fbjs/lib/invariant';
var EventPluginUtils = require('./EventPluginUtils');
import EventPluginUtils from './EventPluginUtils';
// Use to restore controlled state after a change event has fired.
@@ -83,4 +83,4 @@ var ReactControlledComponent = {
},
};
module.exports = ReactControlledComponent;
export default ReactControlledComponent;
@@ -7,7 +7,7 @@
'use strict';
var EventPluginHub = require('./EventPluginHub');
import EventPluginHub from './EventPluginHub';
function runEventQueueInBatch(events) {
EventPluginHub.enqueueEvents(events);
@@ -35,4 +35,4 @@ var ReactEventEmitterMixin = {
},
};
module.exports = ReactEventEmitterMixin;
export default ReactEventEmitterMixin;
@@ -7,7 +7,7 @@
'use strict';
var ReactControlledComponent = require('./ReactControlledComponent');
import ReactControlledComponent from './ReactControlledComponent';
// Used as a way to call batchedUpdates when we don't have a reference to
// the renderer. Such as when we're dispatching events or if third party
@@ -58,4 +58,4 @@ var ReactGenericBatching = {
injection: ReactGenericBatchingInjection,
};
module.exports = ReactGenericBatching;
export default ReactGenericBatching;
@@ -7,13 +7,13 @@
'use strict';
var ReactTreeTraversal = require('shared/ReactTreeTraversal');
import ReactTreeTraversal from 'shared/ReactTreeTraversal';
var EventPluginUtils = require('./EventPluginUtils');
var EventPropagators = require('./EventPropagators');
var ResponderSyntheticEvent = require('./ResponderSyntheticEvent');
var ResponderTouchHistoryStore = require('./ResponderTouchHistoryStore');
var accumulate = require('./accumulate');
import EventPluginUtils from './EventPluginUtils';
import EventPropagators from './EventPropagators';
import ResponderSyntheticEvent from './ResponderSyntheticEvent';
import ResponderTouchHistoryStore from './ResponderTouchHistoryStore';
import accumulate from './accumulate';
var isStartish = EventPluginUtils.isStartish;
var isMoveish = EventPluginUtils.isMoveish;
@@ -592,4 +592,4 @@ var ResponderEventPlugin = {
},
};
module.exports = ResponderEventPlugin;
export default ResponderEventPlugin;
@@ -7,7 +7,7 @@
'use strict';
var SyntheticEvent = require('./SyntheticEvent');
import SyntheticEvent from './SyntheticEvent';
/**
* `touchHistory` isn't actually on the native event, but putting it in the
@@ -43,4 +43,4 @@ function ResponderSyntheticEvent(
SyntheticEvent.augmentClass(ResponderSyntheticEvent, ResponderEventInterface);
module.exports = ResponderSyntheticEvent;
export default ResponderSyntheticEvent;
@@ -9,14 +9,12 @@
'use strict';
const invariant = require('fbjs/lib/invariant');
import invariant from 'fbjs/lib/invariant';
import warning from 'fbjs/lib/warning';
const EventPluginUtils = require('./EventPluginUtils');
const {isEndish, isMoveish, isStartish} = EventPluginUtils;
import EventPluginUtils from './EventPluginUtils';
if (__DEV__) {
var warning = require('fbjs/lib/warning');
}
const {isEndish, isMoveish, isStartish} = EventPluginUtils;
/**
* Tracks the position and time of each active touch by `touch.identifier`. We
@@ -218,4 +216,4 @@ const ResponderTouchHistoryStore = {
touchHistory,
};
module.exports = ResponderTouchHistoryStore;
export default ResponderTouchHistoryStore;
@@ -9,17 +9,14 @@
'use strict';
var emptyFunction = require('fbjs/lib/emptyFunction');
var invariant = require('fbjs/lib/invariant');
import emptyFunction from 'fbjs/lib/emptyFunction';
import invariant from 'fbjs/lib/invariant';
import warning from 'fbjs/lib/warning';
var didWarnForAddedNewProperty = false;
var isProxySupported = typeof Proxy === 'function';
var EVENT_POOL_SIZE = 10;
if (__DEV__) {
var warning = require('fbjs/lib/warning');
}
var shouldBeReleasedProperties = [
'dispatchConfig',
'_targetInst',
@@ -271,8 +268,6 @@ if (__DEV__) {
addEventPoolingTo(SyntheticEvent);
module.exports = SyntheticEvent;
/**
* Helper to nullify syntheticEvent instance properties when destructing
*
@@ -356,3 +351,5 @@ function addEventPoolingTo(EventConstructor) {
EventConstructor.getPooled = getPooledEvent;
EventConstructor.release = releasePooledEvent;
}
export default SyntheticEvent;
@@ -148,4 +148,4 @@ var TouchHistoryMath = {
noCentroid: -1,
};
module.exports = TouchHistoryMath;
export default TouchHistoryMath;
@@ -16,7 +16,7 @@ describe('EventPluginRegistry', () => {
beforeEach(() => {
jest.resetModuleRegistry();
// TODO: can we express this test with only public API?
EventPluginRegistry = require('events/EventPluginRegistry');
EventPluginRegistry = require('events/EventPluginRegistry').default;
createPlugin = function(properties) {
return Object.assign({extractEvents: function() {}}, properties);
@@ -13,7 +13,7 @@ var accumulateInto;
describe('accumulateInto', () => {
beforeEach(() => {
accumulateInto = require('events/accumulateInto');
accumulateInto = require('events/accumulateInto').default;
});
it('throws if the second item is null', () => {
@@ -9,7 +9,7 @@
'use strict';
var invariant = require('fbjs/lib/invariant');
import invariant from 'fbjs/lib/invariant';
/**
* Accumulates items that must not be null or undefined.
@@ -44,4 +44,4 @@ function accumulate<T>(
return [current, next];
}
module.exports = accumulate;
export default accumulate;
@@ -9,7 +9,7 @@
'use strict';
var invariant = require('fbjs/lib/invariant');
import invariant from 'fbjs/lib/invariant';
/**
* Accumulates items that must not be null or undefined into the first one. This
@@ -56,4 +56,4 @@ function accumulateInto<T>(
return [current, next];
}
module.exports = accumulateInto;
export default accumulateInto;
@@ -30,4 +30,4 @@ function forEachAccumulated<T>(
}
}
module.exports = forEachAccumulated;
export default forEachAccumulated;
@@ -58,8 +58,8 @@ describe('ReactBrowserEventEmitter', () => {
LISTENER.mockClear();
// TODO: can we express this test with only public API?
EventPluginHub = require('events/EventPluginHub');
EventPluginRegistry = require('events/EventPluginRegistry');
EventPluginHub = require('events/EventPluginHub').default;
EventPluginRegistry = require('events/EventPluginRegistry').default;
React = require('react');
ReactDOM = require('react-dom');
ReactDOMComponentTree = require('../client/ReactDOMComponentTree').default;
@@ -19,7 +19,7 @@ describe('SyntheticEvent', () => {
beforeEach(() => {
// TODO: can we express this test with only public API?
SyntheticEvent = require('events/SyntheticEvent');
SyntheticEvent = require('events/SyntheticEvent').default;
React = require('react');
ReactDOM = require('react-dom');
ReactTestUtils = require('react-dom/test-utils');
@@ -71,7 +71,7 @@ beforeEach(() => {
ReactNative = require('react-native-renderer');
ReactNativeBridgeEventPlugin = require('../ReactNativeBridgeEventPlugin')
.default;
ResponderEventPlugin = require('events/ResponderEventPlugin');
ResponderEventPlugin = require('events/ResponderEventPlugin').default;
UIManager = require('UIManager');
createReactNativeComponentClass = require('../createReactNativeComponentClass')
.default;
ProTip! Use n and p to navigate between commits in a pull request.