Skip to content

Commit

Permalink
Drop Haste (#11303)
Browse files Browse the repository at this point in the history
* Use relative paths in packages/react

* Use relative paths in packages/react-art

* Use relative paths in packages/react-cs

* Use relative paths in other packages

* Fix as many issues as I can

This uncovered an interesting problem where ./b from package/src/a would resolve to a different instantiation of package/src/b in Jest.

Either this is a showstopper or we can solve it by completely fobbidding remaining /src/.

* Fix all tests

It seems we can't use relative requires in tests anymore. Otherwise Jest becomes confused between real file and symlink.
jestjs/jest#3830

This seems bad... Except that we already *don't* want people to create tests that import individual source files.
All existing cases of us doing so are actually TODOs waiting to be fixed.

So perhaps this requirement isn't too bad because it makes bad code looks bad.

Of course, if we go with this, we'll have to lint against relative requires in tests.
It also makes moving things more painful.

* Prettier

* Remove @providesModule

* Fix remaining Haste imports I missed earlier

* Fix up paths to reflect new flat structure

* Fix Flow

* Fix CJS and UMD builds

* Fix FB bundles

* Fix RN bundles

* Prettier

* Fix lint

* Fix warning printing and error codes

* Fix buggy return

* Fix lint and Flow

* Use Yarn on CI

* Unbreak Jest

* Fix lint

* Fix aliased originals getting included in DEV

Shouldn't affect correctness (they were ignored) but fixes DEV size regression.

* Record sizes

* Fix weird version in package.json

* Tweak bundle labels

* Get rid of output option by introducing react-dom/server.node

* Reconciler should depend on prop-types

* Update sizes last time
  • Loading branch information
gaearon authored Oct 24, 2017
1 parent 37baacb commit 1eed302
Show file tree
Hide file tree
Showing 262 changed files with 1,180 additions and 1,809 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
".*": "./scripts/jest/preprocessor.js"
},
"transformIgnorePatterns": [
"/node_modules/(?!react)"
"/node_modules/(?!react|shared|events)"
],
"setupFiles": [
"./scripts/jest/setup.js",
Expand Down
12 changes: 5 additions & 7 deletions packages/events/EventPluginHub.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,16 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @providesModule EventPluginHub
*/

'use strict';

var EventPluginRegistry = require('EventPluginRegistry');
var EventPluginUtils = require('EventPluginUtils');
var ReactErrorUtils = require('ReactErrorUtils');
var EventPluginRegistry = require('./EventPluginRegistry');
var EventPluginUtils = require('./EventPluginUtils');
var ReactErrorUtils = require('shared/ReactErrorUtils');

var accumulateInto = require('accumulateInto');
var forEachAccumulated = require('forEachAccumulated');
var accumulateInto = require('./accumulateInto');
var forEachAccumulated = require('./forEachAccumulated');
var invariant = require('fbjs/lib/invariant');

/**
Expand Down
9 changes: 6 additions & 3 deletions packages/events/EventPluginRegistry.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @providesModule EventPluginRegistry
* @flow
*/

'use strict';

import type {DispatchConfig} from 'ReactSyntheticEventType';
import type {DispatchConfig} from './ReactSyntheticEventType';

import type {AnyNativeEvent, PluginName, PluginModule} from 'PluginModuleType';
import type {
AnyNativeEvent,
PluginName,
PluginModule,
} from './PluginModuleType';

type NamesToPlugins = {[key: PluginName]: PluginModule<AnyNativeEvent>};

Expand Down
4 changes: 1 addition & 3 deletions packages/events/EventPluginUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @providesModule EventPluginUtils
*/

'use strict';

var ReactErrorUtils = require('ReactErrorUtils');
var ReactErrorUtils = require('shared/ReactErrorUtils');

var invariant = require('fbjs/lib/invariant');

Expand Down
10 changes: 4 additions & 6 deletions packages/events/EventPropagators.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @providesModule EventPropagators
*/

'use strict';

var EventPluginHub = require('EventPluginHub');
var ReactTreeTraversal = require('ReactTreeTraversal');
var EventPluginHub = require('./EventPluginHub');
var ReactTreeTraversal = require('shared/ReactTreeTraversal');

var accumulateInto = require('accumulateInto');
var forEachAccumulated = require('forEachAccumulated');
var accumulateInto = require('./accumulateInto');
var forEachAccumulated = require('./forEachAccumulated');

type PropagationPhases = 'bubbled' | 'captured';

Expand Down
5 changes: 2 additions & 3 deletions packages/events/PluginModuleType.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @providesModule PluginModuleType
* @flow
*/

'use strict';

import type {Fiber} from 'ReactFiber';
import type {Fiber} from 'react-reconciler/src/ReactFiber';
import type {
DispatchConfig,
ReactSyntheticEvent,
} from 'ReactSyntheticEventType';
} from './ReactSyntheticEventType';

export type EventTypes = {[key: string]: DispatchConfig};

Expand Down
4 changes: 1 addition & 3 deletions packages/events/ReactControlledComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @providesModule ReactControlledComponent
*/

'use strict';

var EventPluginUtils = require('EventPluginUtils');
var EventPluginUtils = require('./EventPluginUtils');

var invariant = require('fbjs/lib/invariant');

Expand Down
4 changes: 1 addition & 3 deletions packages/events/ReactEventEmitterMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @providesModule ReactEventEmitterMixin
*/

'use strict';

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

function runEventQueueInBatch(events) {
EventPluginHub.enqueueEvents(events);
Expand Down
4 changes: 1 addition & 3 deletions packages/events/ReactGenericBatching.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @providesModule ReactGenericBatching
*/

'use strict';

var ReactControlledComponent = require('ReactControlledComponent');
var ReactControlledComponent = require('./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
4 changes: 1 addition & 3 deletions packages/events/ReactSyntheticEventType.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@
* LICENSE file in the root directory of this source tree.
*
* Flow type for SyntheticEvent class that includes private properties
*
* @providesModule ReactSyntheticEventType
* @flow
*/

'use strict';

import type {Fiber} from 'ReactFiber';
import type {Fiber} from 'react-reconciler/src/ReactFiber';

export type DispatchConfig = {
dependencies: Array<string>,
Expand Down
14 changes: 6 additions & 8 deletions packages/events/ResponderEventPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,17 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @providesModule ResponderEventPlugin
*/

'use strict';

var EventPluginUtils = require('EventPluginUtils');
var EventPropagators = require('EventPropagators');
var ReactTreeTraversal = require('ReactTreeTraversal');
var ResponderSyntheticEvent = require('ResponderSyntheticEvent');
var ResponderTouchHistoryStore = require('ResponderTouchHistoryStore');
var EventPluginUtils = require('./EventPluginUtils');
var EventPropagators = require('./EventPropagators');
var ReactTreeTraversal = require('shared/ReactTreeTraversal');
var ResponderSyntheticEvent = require('./ResponderSyntheticEvent');
var ResponderTouchHistoryStore = require('./ResponderTouchHistoryStore');

var accumulate = require('accumulate');
var accumulate = require('./accumulate');

var isStartish = EventPluginUtils.isStartish;
var isMoveish = EventPluginUtils.isMoveish;
Expand Down
4 changes: 1 addition & 3 deletions packages/events/ResponderSyntheticEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @providesModule ResponderSyntheticEvent
*/

'use strict';

var SyntheticEvent = require('SyntheticEvent');
var SyntheticEvent = require('./SyntheticEvent');

/**
* `touchHistory` isn't actually on the native event, but putting it in the
Expand Down
3 changes: 1 addition & 2 deletions packages/events/ResponderTouchHistoryStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @providesModule ResponderTouchHistoryStore
* @flow
*/

'use strict';

const EventPluginUtils = require('EventPluginUtils');
const EventPluginUtils = require('./EventPluginUtils');

const invariant = require('fbjs/lib/invariant');

Expand Down
2 changes: 0 additions & 2 deletions packages/events/SyntheticEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @providesModule SyntheticEvent
*/

/* eslint valid-typeof: 0 */
Expand Down
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('EventPluginRegistry');
EventPluginRegistry = require('events/EventPluginRegistry');

createPlugin = function(properties) {
return Object.assign({extractEvents: function() {}}, properties);
Expand Down
2 changes: 1 addition & 1 deletion packages/events/__tests__/ResponderEventPlugin-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

'use strict';

var {HostComponent} = require('ReactTypeOfWork');
var {HostComponent} = require('shared/ReactTypeOfWork');

var EventPluginHub;
var ResponderEventPlugin;
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('accumulateInto');
accumulateInto = require('events/accumulateInto');
});

it('throws if the second item is null', () => {
Expand Down
1 change: 0 additions & 1 deletion packages/events/accumulate.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @providesModule accumulate
* @flow
*/

Expand Down
1 change: 0 additions & 1 deletion packages/events/accumulateInto.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @providesModule accumulateInto
* @flow
*/

Expand Down
1 change: 0 additions & 1 deletion packages/events/forEachAccumulated.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @providesModule forEachAccumulated
* @flow
*/

Expand Down
5 changes: 5 additions & 0 deletions packages/events/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"private": true,
"name": "events",
"version": "0.0.0"
}
2 changes: 0 additions & 2 deletions packages/react-art/npm/Circle.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @providesModule Circle.art
* @typechecks
*
* Example usage:
Expand Down
2 changes: 0 additions & 2 deletions packages/react-art/npm/Rectangle.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @providesModule Rectangle.art
* @typechecks
*
* Example usage:
Expand Down
2 changes: 0 additions & 2 deletions packages/react-art/npm/Wedge.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @providesModule Wedge.art
* @typechecks
*
* Example usage:
Expand Down
1 change: 1 addition & 0 deletions packages/react-art/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"prop-types": "^15.6.0"
},
"peerDependencies": {
"art": "^0.10.1",
"react": "^16.0.0"
},
"files": [
Expand Down
2 changes: 1 addition & 1 deletion packages/react-art/src/ReactART.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const invariant = require('fbjs/lib/invariant');
const emptyObject = require('fbjs/lib/emptyObject');
const React = require('react');
const ReactFiberReconciler = require('react-reconciler');
const ReactDOMFrameScheduling = require('ReactDOMFrameScheduling');
const ReactDOMFrameScheduling = require('shared/ReactDOMFrameScheduling');

const {Component} = React;

Expand Down
6 changes: 5 additions & 1 deletion packages/react-cs-renderer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
"repository": "facebook/react",
"dependencies": {
"fbjs": "^0.8.16",
"object-assign": "^4.1.1"
"object-assign": "^4.1.1",
"prop-types": "^15.6.0"
},
"peerDependencies": {
"react": "^16.0.0"
}
}
11 changes: 7 additions & 4 deletions packages/react-cs-renderer/src/ReactNativeCS.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@

'use strict';

const ReactGenericBatching = require('ReactGenericBatching');
const ReactVersion = require('ReactVersion');
const ReactGenericBatching = require('events/ReactGenericBatching');
const ReactVersion = require('shared/ReactVersion');

const {injectInternals} = require('ReactFiberDevToolsHook');
// TODO: direct imports like some-package/src/* are bad. Fix me.
const {
injectInternals,
} = require('react-reconciler/src/ReactFiberDevToolsHook');

import type {ReactNativeCSType} from 'ReactNativeCSTypes';
import type {ReactNativeCSType} from './ReactNativeCSTypes';

const ReactFiberReconciler = require('react-reconciler');

Expand Down
3 changes: 1 addition & 2 deletions packages/react-cs-renderer/src/ReactNativeCSFeatureFlags.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @providesModule ReactNativeCSFeatureFlags
* @flow
*/

'use strict';

import type {FeatureFlags} from 'ReactFeatureFlags';
import type {FeatureFlags} from 'shared/ReactFeatureFlags';

var ReactNativeCSFeatureFlags: FeatureFlags = {
enableAsyncSubtreeAPI: true,
Expand Down
1 change: 0 additions & 1 deletion packages/react-cs-renderer/src/ReactNativeCSTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @providesModule ReactNativeCSTypes
* @flow
*/
'use strict';
Expand Down
Loading

0 comments on commit 1eed302

Please sign in to comment.