Skip to content

Convert the Source to ES Modules #11389

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

Merged
merged 23 commits into from
Nov 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
e17bbe7
Update transforms to handle ES modules
gaearon Oct 27, 2017
cff14c6
Update Jest to handle ES modules
gaearon Oct 27, 2017
27956f1
Convert react package to ES modules
gaearon Oct 27, 2017
82002bf
Convert react-art package to ES Modules
gaearon Oct 27, 2017
cda2ec6
Convert react-call-return package to ES Modules
gaearon Oct 27, 2017
e0bd572
Convert react-test-renderer package to ES Modules
gaearon Oct 27, 2017
a0a1ee0
Convert react-cs-renderer package to ES Modules
gaearon Oct 27, 2017
0452dfd
Convert react-rt-renderer package to ES Modules
gaearon Oct 27, 2017
c90daf8
Convert react-noop-renderer package to ES Modules
gaearon Oct 27, 2017
d622fc3
Convert react-dom/server to ES modules
gaearon Oct 27, 2017
78a0900
Convert react-dom/{client,events,test-utils} to ES modules
gaearon Oct 31, 2017
087cb44
Convert react-dom/shared to ES modules
gaearon Oct 31, 2017
8b8ec20
Convert react-native-renderer to ES modules
gaearon Oct 31, 2017
b688ec2
Convert react-reconciler to ES modules
gaearon Oct 31, 2017
1e95d12
Convert events to ES modules
gaearon Oct 31, 2017
b5513c3
Convert shared to ES modules
gaearon Oct 31, 2017
c8e690b
Remove CommonJS support from transforms
gaearon Oct 31, 2017
15f7753
Move ReactDOMFB entry point code into react-dom/src
gaearon Nov 1, 2017
3b3d230
Fix Rollup shim configuration to work with ESM
gaearon Nov 1, 2017
52081f6
Fix incorrect comment
gaearon Nov 1, 2017
1bd389f
Exclude external imports without side effects
gaearon Nov 2, 2017
21bfd4c
Fix ReactDOM FB build
gaearon Nov 2, 2017
56519b4
Remove TODOs I don’t intend to fix yet
gaearon Nov 2, 2017
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
14 changes: 7 additions & 7 deletions packages/events/EventPluginHub.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -220,4 +220,4 @@ var EventPluginHub = {
},
};

module.exports = EventPluginHub;
export default EventPluginHub;
4 changes: 2 additions & 2 deletions packages/events/EventPluginRegistry.js
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
Expand Down Expand Up @@ -251,4 +251,4 @@ var EventPluginRegistry = {
},
};

module.exports = EventPluginRegistry;
export default EventPluginRegistry;
11 changes: 4 additions & 7 deletions packages/events/EventPluginUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -228,4 +225,4 @@ var EventPluginUtils = {
injection: injection,
};

module.exports = EventPluginUtils;
export default EventPluginUtils;
43 changes: 14 additions & 29 deletions packages/events/EventPropagators.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,21 @@

'use strict';

var ReactTreeTraversal = require('shared/ReactTreeTraversal');
import {
getParentInstance,
traverseTwoPhase,
traverseEnterLeave,
} 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.
Expand Down Expand Up @@ -60,11 +61,7 @@ function accumulateDirectionalDispatches(inst, phase, event) {
*/
function accumulateTwoPhaseDispatchesSingle(event) {
if (event && event.dispatchConfig.phasedRegistrationNames) {
ReactTreeTraversal.traverseTwoPhase(
event._targetInst,
accumulateDirectionalDispatches,
event,
);
traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event);
}
}

Expand All @@ -74,14 +71,8 @@ function accumulateTwoPhaseDispatchesSingle(event) {
function accumulateTwoPhaseDispatchesSingleSkipTarget(event) {
if (event && event.dispatchConfig.phasedRegistrationNames) {
var targetInst = event._targetInst;
var parentInst = targetInst
? ReactTreeTraversal.getParentInstance(targetInst)
: null;
ReactTreeTraversal.traverseTwoPhase(
parentInst,
accumulateDirectionalDispatches,
event,
);
var parentInst = targetInst ? getParentInstance(targetInst) : null;
traverseTwoPhase(parentInst, accumulateDirectionalDispatches, event);
}
}

Expand Down Expand Up @@ -124,13 +115,7 @@ function accumulateTwoPhaseDispatchesSkipTarget(events) {
}

function accumulateEnterLeaveDispatches(leave, enter, from, to) {
ReactTreeTraversal.traverseEnterLeave(
from,
to,
accumulateDispatches,
leave,
enter,
);
traverseEnterLeave(from, to, accumulateDispatches, leave, enter);
}

function accumulateDirectDispatches(events) {
Expand All @@ -155,4 +140,4 @@ var EventPropagators = {
accumulateEnterLeaveDispatches: accumulateEnterLeaveDispatches,
};

module.exports = EventPropagators;
export default EventPropagators;
6 changes: 3 additions & 3 deletions packages/events/ReactControlledComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -83,4 +83,4 @@ var ReactControlledComponent = {
},
};

module.exports = ReactControlledComponent;
export default ReactControlledComponent;
4 changes: 2 additions & 2 deletions packages/events/ReactEventEmitterMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

'use strict';

var EventPluginHub = require('./EventPluginHub');
import EventPluginHub from './EventPluginHub';

function runEventQueueInBatch(events) {
EventPluginHub.enqueueEvents(events);
Expand Down Expand Up @@ -35,4 +35,4 @@ var ReactEventEmitterMixin = {
},
};

module.exports = ReactEventEmitterMixin;
export default ReactEventEmitterMixin;
4 changes: 2 additions & 2 deletions packages/events/ReactGenericBatching.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -58,4 +58,4 @@ var ReactGenericBatching = {
injection: ReactGenericBatchingInjection,
};

module.exports = ReactGenericBatching;
export default ReactGenericBatching;
18 changes: 9 additions & 9 deletions packages/events/ResponderEventPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

'use strict';

var ReactTreeTraversal = require('shared/ReactTreeTraversal');
import {getLowestCommonAncestor, isAncestor} 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;
Expand Down Expand Up @@ -327,7 +327,7 @@ function setResponderAndExtractTransfer(
// TODO: stop one short of the current responder.
var bubbleShouldSetFrom = !responderInst
? targetInst
: ReactTreeTraversal.getLowestCommonAncestor(responderInst, targetInst);
: getLowestCommonAncestor(responderInst, targetInst);

// When capturing/bubbling the "shouldSet" event, we want to skip the target
// (deepest ID) if it happens to be the current responder. The reasoning:
Expand Down Expand Up @@ -450,7 +450,7 @@ function noResponderTouches(nativeEvent) {
if (target !== null && target !== undefined && target !== 0) {
// Is the original touch location inside of the current responder?
var targetInst = EventPluginUtils.getInstanceFromNode(target);
if (ReactTreeTraversal.isAncestor(responderInst, targetInst)) {
if (isAncestor(responderInst, targetInst)) {
return false;
}
}
Expand Down Expand Up @@ -592,4 +592,4 @@ var ResponderEventPlugin = {
},
};

module.exports = ResponderEventPlugin;
export default ResponderEventPlugin;
4 changes: 2 additions & 2 deletions packages/events/ResponderSyntheticEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -43,4 +43,4 @@ function ResponderSyntheticEvent(

SyntheticEvent.augmentClass(ResponderSyntheticEvent, ResponderEventInterface);

module.exports = ResponderSyntheticEvent;
export default ResponderSyntheticEvent;
12 changes: 5 additions & 7 deletions packages/events/ResponderTouchHistoryStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -218,4 +216,4 @@ const ResponderTouchHistoryStore = {
touchHistory,
};

module.exports = ResponderTouchHistoryStore;
export default ResponderTouchHistoryStore;
13 changes: 5 additions & 8 deletions packages/events/SyntheticEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -271,8 +268,6 @@ if (__DEV__) {

addEventPoolingTo(SyntheticEvent);

module.exports = SyntheticEvent;

/**
* Helper to nullify syntheticEvent instance properties when destructing
*
Expand Down Expand Up @@ -356,3 +351,5 @@ function addEventPoolingTo(EventConstructor) {
EventConstructor.getPooled = getPooledEvent;
EventConstructor.release = releasePooledEvent;
}

export default SyntheticEvent;
2 changes: 1 addition & 1 deletion packages/events/TouchHistoryMath.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,4 @@ var TouchHistoryMath = {
noCentroid: -1,
};

module.exports = TouchHistoryMath;
export default TouchHistoryMath;
2 changes: 1 addition & 1 deletion packages/events/__tests__/EventPluginRegistry-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion packages/events/__tests__/accumulateInto-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/events/accumulate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -44,4 +44,4 @@ function accumulate<T>(
return [current, next];
}

module.exports = accumulate;
export default accumulate;
4 changes: 2 additions & 2 deletions packages/events/accumulateInto.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -56,4 +56,4 @@ function accumulateInto<T>(
return [current, next];
}

module.exports = accumulateInto;
export default accumulateInto;
2 changes: 1 addition & 1 deletion packages/events/forEachAccumulated.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ function forEachAccumulated<T>(
}
}

module.exports = forEachAccumulated;
export default forEachAccumulated;
4 changes: 3 additions & 1 deletion packages/react-art/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@

'use strict';

module.exports = require('./src/ReactART');
var ReactART = require('./src/ReactART');

module.exports = ReactART;
Loading