Skip to content

Commit

Permalink
Added deprecation warning for React.checkPropTypes and updated Rollup…
Browse files Browse the repository at this point in the history
… build scripts
  • Loading branch information
Brian Vaughn committed Apr 11, 2017
1 parent d34109a commit 488c8d2
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 70 deletions.
1 change: 1 addition & 0 deletions scripts/fiber/tests-passing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ src/isomorphic/__tests__/React-test.js
* should log a deprecation warning once when using React.createMixin
* should warn once when attempting to access React.createClass
* should warn once when attempting to access React.PropTypes
* should warn once when attempting to access React.checkPropTypes

src/isomorphic/children/__tests__/ReactChildren-test.js
* should support identity for simple
Expand Down
22 changes: 16 additions & 6 deletions scripts/rollup/bundles.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const bundles = [
sourceMap: false,
},
entry: 'src/renderers/dom/ReactDOM.js',
externals: ['prop-types'],
externals: ['prop-types', 'prop-types/checkPropTypes'],
fbEntry: 'src/fb/ReactDOMFBEntry.js',
hasteName: 'ReactDOMStack',
isRenderer: true,
Expand All @@ -91,6 +91,7 @@ const bundles = [
'src/renderers/shared/**/*.js',
'src/test/**/*.js', // ReactTestUtils is currently very coupled to DOM.

'src/isomorphic/classic/types/checkPropTypes.js',
'src/ReactVersion.js',
'src/shared/**/*.js',
],
Expand All @@ -107,7 +108,7 @@ const bundles = [
sourceMap: false,
},
entry: 'src/renderers/dom/fiber/ReactDOMFiber.js',
externals: ['prop-types'],
externals: ['prop-types', 'prop-types/checkPropTypes'],
fbEntry: 'src/fb/ReactDOMFiberFBEntry.js',
hasteName: 'ReactDOMFiber',
isRenderer: true,
Expand All @@ -119,6 +120,7 @@ const bundles = [
'src/renderers/shared/**/*.js',
'src/test/**/*.js', // ReactTestUtils is currently very coupled to DOM.

'src/isomorphic/classic/types/checkPropTypes.js',
'src/ReactVersion.js',
'src/shared/**/*.js',
],
Expand All @@ -138,7 +140,7 @@ const bundles = [
sourceMap: false,
},
entry: 'src/renderers/dom/ReactDOMServer.js',
externals: ['prop-types'],
externals: ['prop-types', 'prop-types/checkPropTypes'],
fbEntry: 'src/renderers/dom/ReactDOMServer.js',
hasteName: 'ReactDOMServerStack',
isRenderer: true,
Expand All @@ -149,6 +151,7 @@ const bundles = [
'src/renderers/dom/**/*.js',
'src/renderers/shared/**/*.js',

'src/isomorphic/classic/types/checkPropTypes.js',
'src/ReactVersion.js',
'src/shared/**/*.js',
],
Expand All @@ -174,6 +177,7 @@ const bundles = [
'art/modes/current',
'art/modes/fast-noSideEffects',
'art/core/transform',
'prop-types/checkPropTypes',
'react-dom',
],
fbEntry: 'src/renderers/art/ReactARTStack.js',
Expand All @@ -186,6 +190,7 @@ const bundles = [
'src/renderers/art/**/*.js',
'src/renderers/shared/**/*.js',

'src/isomorphic/classic/types/checkPropTypes.js',
'src/ReactVersion.js',
'src/shared/**/*.js',
],
Expand All @@ -208,6 +213,7 @@ const bundles = [
'art/modes/current',
'art/modes/fast-noSideEffects',
'art/core/transform',
'prop-types/checkPropTypes',
'react-dom',
],
fbEntry: 'src/renderers/art/ReactARTFiber.js',
Expand All @@ -220,6 +226,7 @@ const bundles = [
'src/renderers/art/**/*.js',
'src/renderers/shared/**/*.js',

'src/isomorphic/classic/types/checkPropTypes.js',
'src/ReactVersion.js',
'src/shared/**/*.js',
],
Expand Down Expand Up @@ -309,7 +316,7 @@ const bundles = [
sourceMap: false,
},
entry: 'src/renderers/testing/ReactTestRendererFiber',
externals: [],
externals: ['prop-types/checkPropTypes'],
fbEntry: 'src/renderers/testing/ReactTestRendererFiber',
hasteName: 'ReactTestRendererFiber',
isRenderer: true,
Expand All @@ -321,6 +328,7 @@ const bundles = [
'src/renderers/shared/**/*.js',
'src/renderers/testing/**/*.js',

'src/isomorphic/classic/types/checkPropTypes.js',
'src/ReactVersion.js',
'src/shared/**/*.js',
],
Expand All @@ -335,7 +343,7 @@ const bundles = [
sourceMap: false,
},
entry: 'src/renderers/testing/stack/ReactTestRendererStack',
externals: [],
externals: ['prop-types/checkPropTypes'],
fbEntry: 'src/renderers/testing/stack/ReactTestRendererStack',
hasteName: 'ReactTestRendererStack',
isRenderer: true,
Expand All @@ -347,6 +355,7 @@ const bundles = [
'src/renderers/shared/**/*.js',
'src/renderers/testing/**/*.js',

'src/isomorphic/classic/types/checkPropTypes.js',
'src/ReactVersion.js',
'src/shared/**/*.js',
],
Expand All @@ -365,7 +374,7 @@ const bundles = [
sourceMap: false,
},
entry: 'src/renderers/noop/ReactNoop.js',
externals: [],
externals: ['prop-types/checkPropTypes'],
isRenderer: true,
label: 'noop-fiber',
manglePropertiesOnProd: false,
Expand All @@ -374,6 +383,7 @@ const bundles = [
'src/renderers/noop/**/*.js',
'src/renderers/shared/**/*.js',

'src/isomorphic/classic/types/checkPropTypes.js',
'src/ReactVersion.js',
'src/shared/**/*.js',
],
Expand Down
2 changes: 1 addition & 1 deletion scripts/rollup/modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ function replaceLegacyModuleAliases(bundleType) {
case UMD_DEV:
case UMD_PROD:
const modulesAlias = {};
for (var legacyModule in legacyModules) {
for (let legacyModule in legacyModules) {
modulesAlias[legacyModule] = resolve(
`./node_modules/${legacyModules[legacyModule]}`
);
Expand Down
114 changes: 57 additions & 57 deletions scripts/rollup/results.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,116 +2,116 @@
"branch": "prop-types",
"bundleSizes": {
"react.development.js (UMD_DEV)": {
"size": 120916,
"gzip": 30481
"size": 121272,
"gzip": 30505
},
"react.production.min.js (UMD_PROD)": {
"size": 15685,
"gzip": 5764
"gzip": 5765
},
"react-dom.development.js (UMD_DEV)": {
"size": 583318,
"gzip": 134555
"size": 583352,
"gzip": 134572
},
"react-dom.production.min.js (UMD_PROD)": {
"size": 120740,
"gzip": 38092
},
"react-dom-server.development.js (UMD_DEV)": {
"size": 495519,
"gzip": 119683
"size": 495558,
"gzip": 119685
},
"react-dom-server.production.min.js (UMD_PROD)": {
"size": 107033,
"gzip": 33273
},
"react-art.development.js (UMD_DEV)": {
"size": 339929,
"gzip": 76018
"size": 342770,
"gzip": 76828
},
"react-art.production.min.js (UMD_PROD)": {
"size": 95013,
"gzip": 28991
"gzip": 28990
},
"react.development.js (NODE_DEV)": {
"size": 69612,
"gzip": 17522
"size": 69913,
"gzip": 17542
},
"react.production.min.js (NODE_PROD)": {
"size": 9226,
"gzip": 3623
"gzip": 3626
},
"React-dev.js (FB_DEV)": {
"size": 71469,
"gzip": 18157
"size": 71770,
"gzip": 18179
},
"React-prod.js (FB_PROD)": {
"size": 36701,
"gzip": 9254
"size": 36643,
"gzip": 9256
},
"ReactDOMStack-dev.js (FB_DEV)": {
"size": 522667,
"gzip": 124718
"size": 522763,
"gzip": 124727
},
"ReactDOMStack-prod.js (FB_PROD)": {
"size": 352737,
"gzip": 84668
"size": 352776,
"gzip": 84675
},
"react-dom.development.js (NODE_DEV)": {
"size": 542259,
"gzip": 125174
"size": 542350,
"gzip": 125199
},
"react-dom.production.min.js (NODE_PROD)": {
"size": 116884,
"gzip": 36722
"size": 116925,
"gzip": 36732
},
"ReactDOMFiber-dev.js (FB_DEV)": {
"size": 797309,
"gzip": 184144
"size": 797397,
"gzip": 184161
},
"ReactDOMFiber-prod.js (FB_PROD)": {
"size": 407569,
"gzip": 93574
"size": 407613,
"gzip": 93586
},
"react-dom-server.development.js (NODE_DEV)": {
"size": 445493,
"gzip": 107585
"size": 445589,
"gzip": 107597
},
"react-dom-server.production.min.js (NODE_PROD)": {
"size": 101370,
"gzip": 31284
"size": 101411,
"gzip": 31292
},
"ReactDOMServerStack-dev.js (FB_DEV)": {
"size": 444185,
"gzip": 107436
"size": 444281,
"gzip": 107443
},
"ReactDOMServerStack-prod.js (FB_PROD)": {
"size": 333773,
"gzip": 80431
"size": 334166,
"gzip": 80444
},
"ReactARTStack-dev.js (FB_DEV)": {
"size": 142890,
"gzip": 32689
"size": 142986,
"gzip": 32714
},
"ReactARTStack-prod.js (FB_PROD)": {
"size": 101099,
"gzip": 22973
"size": 101143,
"gzip": 22993
},
"react-art.development.js (NODE_DEV)": {
"size": 265123,
"gzip": 56951
"size": 265214,
"gzip": 56974
},
"react-art.production.min.js (NODE_PROD)": {
"size": 56591,
"gzip": 17132
"size": 56628,
"gzip": 17152
},
"ReactARTFiber-dev.js (FB_DEV)": {
"size": 264301,
"gzip": 56758
"size": 264392,
"gzip": 56780
},
"ReactARTFiber-prod.js (FB_PROD)": {
"size": 205292,
"gzip": 43132
"size": 205336,
"gzip": 43154
},
"ReactNativeStack.js (RN)": {
"size": 233993,
Expand All @@ -122,20 +122,20 @@
"gzip": 84001
},
"ReactTestRendererFiber-dev.js (FB_DEV)": {
"size": 262210,
"gzip": 55722
"size": 262301,
"gzip": 55747
},
"ReactTestRendererStack-dev.js (FB_DEV)": {
"size": 151425,
"gzip": 34728
"size": 151521,
"gzip": 34765
},
"react-noop-renderer.development.js (NODE_DEV)": {
"size": 254207,
"gzip": 53701
"size": 254298,
"gzip": 53728
},
"react-test-renderer.development.js (NODE_DEV)": {
"size": 263041,
"gzip": 55919
"size": 263132,
"gzip": 55938
}
}
}
18 changes: 16 additions & 2 deletions src/isomorphic/React.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,13 @@ var React = {
cloneElement: cloneElement,
isValidElement: ReactElement.isValidElement,

// TODO (bvaughn) Remove these getters in 16.0.0-alpha.10
PropTypes: ReactPropTypes,
checkPropTypes: checkPropTypes,
createClass: createReactClass,

// Classic

PropTypes: ReactPropTypes, // TODO (bvaughn) Remove this getter in 16.0.0-alpha.10
createClass: createReactClass, // TODO (bvaughn) Remove this getter in 16.0.0-alpha.10
createFactory: createFactory,
createMixin: createMixin,

Expand All @@ -84,6 +85,7 @@ if (__DEV__) {
ReactDebugCurrentFrame: require('ReactDebugCurrentFrame'),
});

let warnedForCheckPropTypes = false;
let warnedForCreateMixin = false;
let warnedForCreateClass = false;
let warnedForPropTypes = false;
Expand All @@ -100,6 +102,18 @@ if (__DEV__) {

// TODO (bvaughn) Remove both of these deprecation warnings in 16.0.0-alpha.10
if (canDefineProperty) {
Object.defineProperty(React, 'checkPropTypes', {
get() {
warning(
warnedForCheckPropTypes,
'checkPropTypes has moved out of the react package. ' +
'Use the prop-types package from npm instead.',
);
warnedForCheckPropTypes = true;
return ReactPropTypes;
},
});

Object.defineProperty(React, 'createClass', {
get: function() {
warning(
Expand Down
Loading

0 comments on commit 488c8d2

Please sign in to comment.