Skip to content

Commit 549e418

Browse files
authored
Move remaining things to named exports (#18165)
* Move remaining things to named exports The interesting case here is the noop renderers. The wrappers around the reconciler now changed to use a local export that gets mutated. ReactNoop and ReactNoopPersistent now have to destructure the object to list out the names it's going to export. We should probably refactor ReactNoop away from createReactNoop. Especially since it's also not Flow typed. * Switch interactions to star exports This will have esModule compatibility flag on them. They should ideally export default instead.
1 parent 739f20b commit 549e418

40 files changed

+113
-200
lines changed

packages/eslint-plugin-react-hooks/index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,4 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
'use strict';
9-
10-
module.exports = require('./src/index');
8+
export * from './src/index';

packages/react-art/Circle.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,4 @@
77
* @flow
88
*/
99

10-
'use strict';
11-
12-
const Circle = require('./npm/Circle');
13-
14-
module.exports = Circle;
10+
export {default} from './npm/Circle';

packages/react-art/Rectangle.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,4 @@
77
* @flow
88
*/
99

10-
'use strict';
11-
12-
const Rectangle = require('./npm/Rectangle');
13-
14-
module.exports = Rectangle;
10+
export {default} from './npm/Rectangle';

packages/react-art/Wedge.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,4 @@
77
* @flow
88
*/
99

10-
'use strict';
11-
12-
const Wedge = require('./npm/Wedge');
13-
14-
module.exports = Wedge;
10+
export {default} from './npm/Wedge';

packages/react-art/index.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,4 @@
77
* @flow
88
*/
99

10-
'use strict';
11-
12-
const ReactART = require('./src/ReactART');
13-
14-
module.exports = ReactART;
10+
export * from './src/ReactART';

packages/react-art/src/__tests__/ReactART-test.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,26 @@
1111

1212
'use strict';
1313

14-
const React = require('react');
14+
import * as React from 'react';
15+
16+
import * as ReactART from 'react-art';
17+
import ARTSVGMode from 'art/modes/svg';
18+
import ARTCurrentMode from 'art/modes/current';
19+
// Since these are default exports, we need to import them using ESM.
20+
// Since they must be on top, we need to import this before ReactDOM.
21+
import Circle from 'react-art/Circle';
22+
import Rectangle from 'react-art/Rectangle';
23+
import Wedge from 'react-art/Wedge';
24+
25+
// Isolate DOM renderer.
26+
jest.resetModules();
1527
const ReactDOM = require('react-dom');
1628
const ReactTestUtils = require('react-dom/test-utils');
1729

1830
// Isolate test renderer.
1931
jest.resetModules();
2032
const ReactTestRenderer = require('react-test-renderer');
2133

22-
// Isolate ART renderer.
23-
jest.resetModules();
24-
const ReactART = require('react-art');
25-
const ARTSVGMode = require('art/modes/svg');
26-
const ARTCurrentMode = require('art/modes/current');
27-
const Circle = require('react-art/Circle');
28-
const Rectangle = require('react-art/Rectangle');
29-
const Wedge = require('react-art/Wedge');
30-
3134
// Isolate the noop renderer
3235
jest.resetModules();
3336
const ReactNoop = require('react-noop-renderer');

packages/react-debug-tools/index.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,4 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
'use strict';
9-
10-
const ReactDebugTools = require('./src/ReactDebugTools');
11-
12-
// This is hacky but makes it work with both Rollup and Jest.
13-
module.exports = ReactDebugTools.default || ReactDebugTools;
8+
export * from './src/ReactDebugTools';

packages/react-flight-dom-webpack/index.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,4 @@
77
* @flow
88
*/
99

10-
'use strict';
11-
12-
const ReactFlightDOMClient = require('./src/ReactFlightDOMClient');
13-
14-
// TODO: decide on the top-level export form.
15-
// This is hacky but makes it work with both Rollup and Jest
16-
module.exports = ReactFlightDOMClient.default || ReactFlightDOMClient;
10+
export * from './src/ReactFlightDOMClient';

packages/react-flight-dom-webpack/server.browser.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,4 @@
77
* @flow
88
*/
99

10-
'use strict';
11-
12-
const ReactFlightDOMServerBrowser = require('./src/ReactFlightDOMServerBrowser');
13-
14-
// TODO: decide on the top-level export form.
15-
// This is hacky but makes it work with both Rollup and Jest
16-
module.exports =
17-
ReactFlightDOMServerBrowser.default || ReactFlightDOMServerBrowser;
10+
export * from './src/ReactFlightDOMServerBrowser';

packages/react-flight-dom-webpack/server.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,4 @@
77
* @flow
88
*/
99

10-
'use strict';
11-
12-
module.exports = require('./server.node');
10+
export * from './server.node';

0 commit comments

Comments
 (0)