[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 * @format
*/ */
'use strict'; import performanceNow from 'fbjs/lib/performanceNow';
import warning from 'fbjs/lib/warning';
/* $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');
export type FillRateInfo = Info; export type FillRateInfo = Info;
@@ -221,4 +213,4 @@ class FillRateHelper {
} }
} }
module.exports = FillRateHelper; export default FillRateHelper;
@@ -7,9 +7,8 @@
* @noflow * @noflow
* @format * @format
*/ */
'use strict';
const invariant = require('fbjs/lib/invariant'); import invariant from 'fbjs/lib/invariant';
export type ViewToken = { export type ViewToken = {
item: any, item: any,
@@ -275,4 +274,4 @@ function _isEntirelyVisible(top: number, bottom: number, viewportHeight: number)
return top >= 0 && bottom <= viewportHeight && bottom > top; return top >= 0 && bottom <= viewportHeight && bottom > top;
} }
module.exports = ViewabilityHelper; export default ViewabilityHelper;
@@ -7,16 +7,15 @@
* @flow * @flow
* @format * @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 * 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 * items that bound different windows of content, such as the visible area or the buffered overscan
* area. * area.
*/ */
function elementsThatOverlapOffsets( export function elementsThatOverlapOffsets(
offsets: Array<number>, offsets: Array<number>,
itemCount: number, itemCount: number,
getFrameMetrics: (index: number) => { length: number, offset: 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 * can restrict the number of new items render at once so that content can appear on the screen
* faster. * faster.
*/ */
function newRangeCount( export function newRangeCount(
prev: { first: number, last: number }, prev: { first: number, last: number },
next: { first: number, last: number } next: { first: number, last: number }
): number { ): number {
@@ -68,7 +67,7 @@ function newRangeCount(
* prioritizes the visible area first, then expands that with overscan regions ahead and behind, * prioritizes the visible area first, then expands that with overscan regions ahead and behind,
* biased in the direction of scroll. * biased in the direction of scroll.
*/ */
function computeWindowedRenderLimits( export function computeWindowedRenderLimits(
props: { props: {
data: any, data: any,
getItemCount: (data: any) => number, getItemCount: (data: any) => number,
@@ -201,4 +200,4 @@ const VirtualizeUtils = {
newRangeCount newRangeCount
}; };
module.exports = VirtualizeUtils; export default VirtualizeUtils;
@@ -1593,4 +1593,4 @@ const styles = StyleSheet.create({
} }
}); });
module.exports = VirtualizedList; export default VirtualizedList;