[fix] convert VirtualizedList vendor code to ES modules

Webpack has trouble bundling a mix of CommonJS and ES modules in the
same package.

Fix #957
This commit is contained in:
Nicolas Gallagher
2018-05-19 08:42:32 -07:00
parent def873e9e3
commit 15d5e57e92
5 changed files with 12 additions and 22 deletions
+1 -1
View File
@@ -70,4 +70,4 @@ class Batchinator {
}
}
module.exports = Batchinator;
export default Batchinator;
@@ -8,16 +8,8 @@
* @format
*/
'use strict';
/* $FlowFixMe(>=0.54.0 site=react_native_oss) This comment suppresses an error
* found when Flow v0.54 was deployed. To see the error delete this comment and
* run Flow. */
const performanceNow = require('fbjs/lib/performanceNow');
/* $FlowFixMe(>=0.54.0 site=react_native_oss) This comment suppresses an error
* found when Flow v0.54 was deployed. To see the error delete this comment and
* run Flow. */
const warning = require('fbjs/lib/warning');
import performanceNow from 'fbjs/lib/performanceNow';
import warning from 'fbjs/lib/warning';
export type FillRateInfo = Info;
@@ -221,4 +213,4 @@ class FillRateHelper {
}
}
module.exports = FillRateHelper;
export default FillRateHelper;
@@ -7,9 +7,8 @@
* @noflow
* @format
*/
'use strict';
const invariant = require('fbjs/lib/invariant');
import invariant from 'fbjs/lib/invariant';
export type ViewToken = {
item: any,
@@ -275,4 +274,4 @@ function _isEntirelyVisible(top: number, bottom: number, viewportHeight: number)
return top >= 0 && bottom <= viewportHeight && bottom > top;
}
module.exports = ViewabilityHelper;
export default ViewabilityHelper;
@@ -7,16 +7,15 @@
* @flow
* @format
*/
'use strict';
const invariant = require('fbjs/lib/invariant');
import invariant from 'fbjs/lib/invariant';
/**
* Used to find the indices of the frames that overlap the given offsets. Useful for finding the
* items that bound different windows of content, such as the visible area or the buffered overscan
* area.
*/
function elementsThatOverlapOffsets(
export function elementsThatOverlapOffsets(
offsets: Array<number>,
itemCount: number,
getFrameMetrics: (index: number) => { length: number, offset: number }
@@ -50,7 +49,7 @@ function elementsThatOverlapOffsets(
* can restrict the number of new items render at once so that content can appear on the screen
* faster.
*/
function newRangeCount(
export function newRangeCount(
prev: { first: number, last: number },
next: { first: number, last: number }
): number {
@@ -68,7 +67,7 @@ function newRangeCount(
* prioritizes the visible area first, then expands that with overscan regions ahead and behind,
* biased in the direction of scroll.
*/
function computeWindowedRenderLimits(
export function computeWindowedRenderLimits(
props: {
data: any,
getItemCount: (data: any) => number,
@@ -201,4 +200,4 @@ const VirtualizeUtils = {
newRangeCount
};
module.exports = VirtualizeUtils;
export default VirtualizeUtils;
@@ -1593,4 +1593,4 @@ const styles = StyleSheet.create({
}
});
module.exports = VirtualizedList;
export default VirtualizedList;