Skip to content
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

providesModule -> explicit requires for cross-package dependencies #9078

Merged
merged 4 commits into from
Mar 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
47 changes: 32 additions & 15 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,35 +103,52 @@ var paths = {
},
};

var moduleMapBase = Object.assign(
{'object-assign': 'object-assign'},
require('fbjs/module-map')
);
var moduleMapBase = {'object-assign': 'object-assign'};

var fbjsModules = require('fbjs/module-map');
for (var key in fbjsModules) {
var path = fbjsModules[key];
moduleMapBase[path] = path;
}

var moduleMapReact = Object.assign(
{
// Addons needs to reach into DOM internals
ReactDOM: 'react-dom/lib/ReactDOM',
ReactInstanceMap: 'react-dom/lib/ReactInstanceMap',
ReactTestUtils: 'react-dom/lib/ReactTestUtils',
ReactPerf: 'react-dom/lib/ReactPerf',
getVendorPrefixedEventName: 'react-dom/lib/getVendorPrefixedEventName',
'react-dom': 'react-dom',
'react-dom/lib/ReactInstanceMap': 'react-dom/lib/ReactInstanceMap',
'react-dom/lib/ReactTestUtils': 'react-dom/lib/ReactTestUtils',
'react-dom/lib/ReactPerf': 'react-dom/lib/ReactPerf',
'react-dom/lib/getVendorPrefixedEventName': 'react-dom/lib/getVendorPrefixedEventName',

// Alias
'react': './React',
// Shared state
'react/lib/ReactCurrentOwner': './ReactCurrentOwner',
'react/lib/checkPropTypes': './checkPropTypes',
'react/lib/ReactComponentTreeHook': './ReactComponentTreeHook',
'react/lib/ReactDebugCurrentFrame': './ReactDebugCurrentFrame',
},
moduleMapBase
);

var rendererSharedState = {
// Alias
React: 'react/lib/React',
'react': 'react/lib/React',
// Shared state
ReactCurrentOwner: 'react/lib/ReactCurrentOwner',
checkPropTypes: 'react/lib/checkPropTypes',
ReactComponentTreeHook: 'react/lib/ReactComponentTreeHook',
ReactDebugCurrentFrame: 'react/lib/ReactDebugCurrentFrame',
'react/lib/ReactCurrentOwner': 'react/lib/ReactCurrentOwner',
'react/lib/checkPropTypes': 'react/lib/checkPropTypes',
'react/lib/ReactComponentTreeHook': 'react/lib/ReactComponentTreeHook',
'react/lib/ReactDebugCurrentFrame': 'react/lib/ReactDebugCurrentFrame',
};

var moduleMapReactDOM = Object.assign(
{},
{
'react-dom': './ReactDOM',
'react-dom/lib/ReactInstanceMap': './ReactInstanceMap',
'react-dom/lib/ReactTestUtils': './ReactTestUtils',
'react-dom/lib/ReactPerf': './ReactPerf',
'react-dom/lib/getVendorPrefixedEventName': './getVendorPrefixedEventName',
},
rendererSharedState,
moduleMapBase
);
Expand Down
6 changes: 3 additions & 3 deletions src/addons/ReactAddonsDOMDependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

'use strict';

var ReactDOM = require('ReactDOM');
var ReactDOM = require('react-dom');

exports.getReactDOM = function() {
return ReactDOM;
Expand All @@ -23,14 +23,14 @@ if (__DEV__) {

exports.getReactPerf = function() {
if (!ReactPerf) {
ReactPerf = require('ReactPerf');
ReactPerf = require('react-dom/lib/ReactPerf');
}
return ReactPerf;
};

exports.getReactTestUtils = function() {
if (!ReactTestUtils) {
ReactTestUtils = require('ReactTestUtils');
ReactTestUtils = require('react-dom/lib/ReactTestUtils');
}
return ReactTestUtils;
};
Expand Down
6 changes: 3 additions & 3 deletions src/addons/ReactFragment.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
var ReactChildren = require('ReactChildren');
var ReactElement = require('ReactElement');

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

/**
* We used to allow keyed objects to serve as a collection of ReactElements,
Expand Down
2 changes: 1 addition & 1 deletion src/addons/ReactWithAddons.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

'use strict';

var React = require('React');
var React = require('react');
var ReactAddonsDOMDependencies = require('ReactAddonsDOMDependencies');
var ReactComponentWithPureRenderMixin =
require('ReactComponentWithPureRenderMixin');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var ReactTestUtils;
describe('ReactComponentWithPureRenderMixin', () => {

beforeEach(() => {
React = require('React');
React = require('react');
ReactComponentWithPureRenderMixin =
require('ReactComponentWithPureRenderMixin');
ReactTestUtils = require('ReactTestUtils');
Expand Down
4 changes: 2 additions & 2 deletions src/addons/__tests__/ReactFragment-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ var ReactFragment;
describe('ReactFragment', () => {

beforeEach(() => {
React = require('React');
ReactDOM = require('ReactDOM');
React = require('react');
ReactDOM = require('react-dom');
ReactFragment = require('ReactFragment');
});

Expand Down
4 changes: 2 additions & 2 deletions src/addons/__tests__/renderSubtreeIntoContainer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

'use strict';

var React = require('React');
var ReactDOM = require('ReactDOM');
var React = require('react');
var ReactDOM = require('react-dom');
var ReactTestUtils = require('ReactTestUtils');
var renderSubtreeIntoContainer = require('renderSubtreeIntoContainer');

Expand Down
2 changes: 1 addition & 1 deletion src/addons/shallowCompare.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

'use strict';

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

/**
* Does a shallow comparison for props and state.
Expand Down
2 changes: 1 addition & 1 deletion src/addons/transitions/ReactCSSTransitionGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

'use strict';

var React = require('React');
var React = require('react');

var ReactTransitionGroup = require('ReactTransitionGroup');
var ReactCSSTransitionGroupChild = require('ReactCSSTransitionGroupChild');
Expand Down
4 changes: 2 additions & 2 deletions src/addons/transitions/ReactCSSTransitionGroupChild.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@

'use strict';

var React = require('React');
var React = require('react');
var ReactAddonsDOMDependencies = require('ReactAddonsDOMDependencies');

var CSSCore = require('CSSCore');
var CSSCore = require('fbjs/lib/CSSCore');
var ReactTransitionEvents = require('ReactTransitionEvents');

var onlyChild = require('onlyChild');
Expand Down
4 changes: 2 additions & 2 deletions src/addons/transitions/ReactTransitionEvents.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

'use strict';

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

var getVendorPrefixedEventName = require('getVendorPrefixedEventName');
var getVendorPrefixedEventName = require('react-dom/lib/getVendorPrefixedEventName');

var endEvents = [];

Expand Down
4 changes: 2 additions & 2 deletions src/addons/transitions/ReactTransitionGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@

'use strict';

var React = require('React');
var React = require('react');
var ReactTransitionChildMapping = require('ReactTransitionChildMapping');

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

/**
* A basis for animations. When children are declaratively added or removed,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

'use strict';

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

var React;
var ReactDOM;
Expand All @@ -24,8 +24,8 @@ describe('ReactCSSTransitionGroup', () => {

beforeEach(() => {
jest.resetModules();
React = require('React');
ReactDOM = require('ReactDOM');
React = require('react');
ReactDOM = require('react-dom');
ReactCSSTransitionGroup = require('ReactCSSTransitionGroup');

container = document.createElement('div');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var ReactTransitionChildMapping;

describe('ReactTransitionChildMapping', () => {
beforeEach(() => {
React = require('React');
React = require('react');
ReactTransitionChildMapping = require('ReactTransitionChildMapping');
});

Expand Down
4 changes: 2 additions & 2 deletions src/addons/transitions/__tests__/ReactTransitionGroup-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ describe('ReactTransitionGroup', () => {
var container;

beforeEach(() => {
React = require('React');
ReactDOM = require('ReactDOM');
React = require('react');
ReactDOM = require('react-dom');
ReactTransitionGroup = require('ReactTransitionGroup');

container = document.createElement('div');
Expand Down
2 changes: 1 addition & 1 deletion src/addons/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

'use strict';

var invariant = require('invariant');
var invariant = require('fbjs/lib/invariant');
var hasOwnProperty = {}.hasOwnProperty;

function shallowCopy(x) {
Expand Down
2 changes: 1 addition & 1 deletion src/isomorphic/React.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var ReactPropTypes = require('ReactPropTypes');
var ReactVersion = require('ReactVersion');

var onlyChild = require('onlyChild');
var warning = require('warning');
var warning = require('fbjs/lib/warning');
var checkPropTypes = require('checkPropTypes');

var createElement = ReactElement.createElement;
Expand Down
2 changes: 1 addition & 1 deletion src/isomorphic/__tests__/React-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('React', () => {
var React;

beforeEach(() => {
React = require('React');
React = require('react');
});

it('should log a deprecation warning once when using React.createMixin', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/isomorphic/children/ReactChildren.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
var PooledClass = require('PooledClass');
var ReactElement = require('ReactElement');

var emptyFunction = require('emptyFunction');
var emptyFunction = require('fbjs/lib/emptyFunction');
var traverseAllChildren = require('traverseAllChildren');

var twoArgumentPooler = PooledClass.twoArgumentPooler;
Expand Down
2 changes: 1 addition & 1 deletion src/isomorphic/children/__tests__/ReactChildren-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('ReactChildren', () => {

beforeEach(() => {
jest.resetModules();
React = require('React');
React = require('react');
ReactFragment = require('ReactFragment');
});

Expand Down
2 changes: 1 addition & 1 deletion src/isomorphic/children/__tests__/onlyChild-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('onlyChild', () => {
var WrapComponent;

beforeEach(() => {
React = require('React');
React = require('react');
ReactFragment = require('ReactFragment');
onlyChild = require('onlyChild');
WrapComponent = class extends React.Component {
Expand Down
2 changes: 1 addition & 1 deletion src/isomorphic/children/__tests__/sliceChildren-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('sliceChildren', () => {
var sliceChildren;

beforeEach(() => {
React = require('React');
React = require('react');

sliceChildren = require('sliceChildren');
});
Expand Down
2 changes: 1 addition & 1 deletion src/isomorphic/children/onlyChild.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

var ReactElement = require('ReactElement');

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

/**
* Returns the first child in a collection of children and verifies that there
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ describe('ReactContextValidator', () => {
beforeEach(() => {
jest.resetModules();

React = require('React');
ReactDOM = require('ReactDOM');
React = require('react');
ReactDOM = require('react-dom');
ReactTestUtils = require('ReactTestUtils');
});

Expand Down
6 changes: 3 additions & 3 deletions src/isomorphic/classic/class/ReactClass.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ var ReactBaseClasses = require('ReactBaseClasses');
var ReactElement = require('ReactElement');
var ReactNoopUpdateQueue = require('ReactNoopUpdateQueue');

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

var ReactComponent = ReactBaseClasses.Component;

Expand Down
2 changes: 1 addition & 1 deletion src/isomorphic/classic/class/__tests__/ReactBind-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/*global global:true*/
'use strict';

var React = require('React');
var React = require('react');
var ReactTestUtils = require('ReactTestUtils');

// TODO: Test render and all stock methods.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/*global global:true*/
'use strict';

var React = require('React');
var React = require('react');
var ReactTestUtils = require('ReactTestUtils');

// TODO: Test render and all stock methods.
Expand Down
4 changes: 2 additions & 2 deletions src/isomorphic/classic/class/__tests__/ReactClass-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ var ReactTestUtils;
describe('ReactClass-spec', () => {

beforeEach(() => {
React = require('React');
ReactDOM = require('ReactDOM');
React = require('react');
ReactDOM = require('react-dom');
ReactTestUtils = require('ReactTestUtils');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var componentPropValidator;
describe('ReactClass-mixin', () => {

beforeEach(() => {
React = require('React');
React = require('react');
ReactTestUtils = require('ReactTestUtils');
mixinPropValidator = jest.fn();
componentPropValidator = jest.fn();
Expand Down
2 changes: 1 addition & 1 deletion src/isomorphic/classic/element/ReactElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

var ReactCurrentOwner = require('ReactCurrentOwner');

var warning = require('warning');
var warning = require('fbjs/lib/warning');
var canDefineProperty = require('canDefineProperty');
var hasOwnProperty = Object.prototype.hasOwnProperty;

Expand Down
2 changes: 1 addition & 1 deletion src/isomorphic/classic/element/ReactElementValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var getComponentName = require('getComponentName');
var getIteratorFn = require('getIteratorFn');

if (__DEV__) {
var warning = require('warning');
var warning = require('fbjs/lib/warning');
var ReactDebugCurrentFrame = require('ReactDebugCurrentFrame');
}

Expand Down
Loading