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

Remove unused production code #18

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion checkPropTypes.js
Expand Up @@ -9,13 +9,19 @@

'use strict';

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

var ReactPropTypesSecret = require('./lib/ReactPropTypesSecret');

var invariant = emptyFunction;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's call this invariantInDevOnly. This is not how we usually use invariant so it might be very confusing.


var loggedTypeFailures = {};

if (process.env.NODE_ENV !== 'production') {
invariant = require('fbjs/lib/invariant');
}

/**
* Assert that the values match with the type specs.
* Error messages are memorized and will only be shown once.
Expand Down
3 changes: 1 addition & 2 deletions factory.js
Expand Up @@ -10,7 +10,6 @@
'use strict';

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

var ReactPropTypesSecret = require('./lib/ReactPropTypesSecret');
Expand Down Expand Up @@ -116,7 +115,7 @@ module.exports = function (isValidElement) {
};
} else {
var productionTypeChecker = function () {
invariant(false, 'React.PropTypes type checking code is stripped in production.');
throw new Error('prop-types type checking code is stripped in production.');
};
productionTypeChecker.isRequired = productionTypeChecker;
var getProductionTypeChecker = function () {
Expand Down
4 changes: 3 additions & 1 deletion package.json
Expand Up @@ -29,17 +29,19 @@
"scripts": {
"test": "jest",
"umd": "NODE_ENV=development browserify index.js -t envify --standalone PropTypes -o prop-types.js",
"umd-min": "NODE_ENV=production browserify index.js -t envify --standalone PropTypes -o | uglifyjs --compress unused,dead_code -o prop-types.min.js",
"umd-min": "NODE_ENV=production browserify index.js -t envify -t uglifyify --standalone PropTypes -p bundle-collapser/plugin -o | uglifyjs --compress unused,dead_code -o prop-types.min.js",
"build": "yarn umd && yarn umd-min",
"prepublish": "yarn build"
},
"devDependencies": {
"babel-jest": "^19.0.0",
"babel-preset-react": "^6.24.1",
"browserify": "^14.3.0",
"bundle-collapser": "^1.2.1",
"envify": "^4.0.0",
"jest": "^19.0.2",
"react": "^15.5.1",
"uglifyify": "^3.0.4",
"uglifyjs": "^2.4.10"
}
}
110 changes: 103 additions & 7 deletions yarn.lock
Expand Up @@ -19,6 +19,10 @@ acorn-globals@^3.1.0:
dependencies:
acorn "^4.0.4"

acorn@^1.0.3:
version "1.2.2"
resolved "http://npme.walmart.com/acorn/-/acorn-1.2.2.tgz#c8ce27de0acc76d896d2b1fad3df588d9e82f014"

acorn@^4.0.3, acorn@^4.0.4:
version "4.0.11"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-4.0.11.tgz#edcda3bd937e7556410d42ed5860f67399c794c0"
Expand Down Expand Up @@ -426,6 +430,16 @@ brorand@^1.0.1:
version "1.1.0"
resolved "https://registry.yarnpkg.com/brorand/-/brorand-1.1.0.tgz#12c25efe40a45e3c323eb8675a0a0ce57b22371f"

browser-pack@^5.0.1:
version "5.0.1"
resolved "http://npme.walmart.com/browser-pack/-/browser-pack-5.0.1.tgz#4197719b20c6e0aaa09451c5111e53efb6fbc18d"
dependencies:
JSONStream "^1.0.3"
combine-source-map "~0.6.1"
defined "^1.0.0"
through2 "^1.0.0"
umd "^3.0.0"

browser-pack@^6.0.1:
version "6.0.2"
resolved "https://registry.yarnpkg.com/browser-pack/-/browser-pack-6.0.2.tgz#f86cd6cef4f5300c8e63e07a4d512f65fbff4531"
Expand All @@ -442,6 +456,15 @@ browser-resolve@^1.11.0, browser-resolve@^1.11.2, browser-resolve@^1.7.0:
dependencies:
resolve "1.1.7"

browser-unpack@^1.1.0:
version "1.2.0"
resolved "http://npme.walmart.com/browser-unpack/-/browser-unpack-1.2.0.tgz#357aee31fc467831684d063e4355e070a782970d"
dependencies:
acorn "^4.0.3"
browser-pack "^5.0.1"
concat-stream "^1.5.0"
minimist "^1.1.1"

browserify-aes@^1.0.0, browserify-aes@^1.0.4:
version "1.0.6"
resolved "https://registry.yarnpkg.com/browserify-aes/-/browserify-aes-1.0.6.tgz#5e7725dbdef1fd5930d4ebab48567ce451c48a0a"
Expand Down Expand Up @@ -580,6 +603,17 @@ builtin-status-codes@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz#85982878e21b98e1c66425e03d0174788f569ee8"

bundle-collapser@^1.2.1:
version "1.2.1"
resolved "http://npme.walmart.com/bundle-collapser/-/bundle-collapser-1.2.1.tgz#e119afc92638e440b9085f47ae081fa756cba33d"
dependencies:
browser-pack "^5.0.1"
browser-unpack "^1.1.0"
concat-stream "^1.5.0"
falafel "^1.2.0"
minimist "^1.1.1"
through2 "^2.0.0"

cached-path-relative@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/cached-path-relative/-/cached-path-relative-1.0.1.tgz#d09c4b52800aa4c078e2dd81a869aac90d2e54e7"
Expand Down Expand Up @@ -661,6 +695,15 @@ color-name@^1.1.1:
version "1.1.2"
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.2.tgz#5c8ab72b64bd2215d617ae9559ebb148475cf98d"

combine-source-map@~0.6.1:
version "0.6.1"
resolved "http://npme.walmart.com/combine-source-map/-/combine-source-map-0.6.1.tgz#9b4a09c316033d768e0f11e029fa2730e079ad96"
dependencies:
convert-source-map "~1.1.0"
inline-source-map "~0.5.0"
lodash.memoize "~3.0.3"
source-map "~0.4.2"

combine-source-map@~0.7.1:
version "0.7.2"
resolved "https://registry.yarnpkg.com/combine-source-map/-/combine-source-map-0.7.2.tgz#0870312856b307a87cc4ac486f3a9a62aeccc09e"
Expand All @@ -680,7 +723,7 @@ concat-map@0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"

concat-stream@~1.5.0, concat-stream@~1.5.1:
concat-stream@^1.5.0, concat-stream@~1.5.0, concat-stream@~1.5.1:
version "1.5.2"
resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.5.2.tgz#708978624d856af41a5a741defdd261da752c266"
dependencies:
Expand Down Expand Up @@ -967,6 +1010,10 @@ expand-range@^1.8.1:
dependencies:
fill-range "^2.1.0"

extend@^1.2.1:
version "1.3.0"
resolved "http://npme.walmart.com/extend/-/extend-1.3.0.tgz#d1516fb0ff5624d2ebf9123ea1dac5a1994004f8"

extend@~3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.0.tgz#5a474353b9f3353ddd8176dfd37b91c83a46f1d4"
Expand All @@ -981,6 +1028,15 @@ extsprintf@1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.0.2.tgz#e1080e0658e300b06294990cc70e1502235fd550"

falafel@^1.2.0:
version "1.2.0"
resolved "http://npme.walmart.com/falafel/-/falafel-1.2.0.tgz#c18d24ef5091174a497f318cd24b026a25cddab4"
dependencies:
acorn "^1.0.3"
foreach "^2.0.5"
isarray "0.0.1"
object-keys "^1.0.6"

fast-levenshtein@~2.0.4:
version "2.0.6"
resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917"
Expand Down Expand Up @@ -1053,6 +1109,10 @@ for-own@^0.1.4:
dependencies:
for-in "^1.0.1"

foreach@^2.0.5:
version "2.0.5"
resolved "http://npme.walmart.com/foreach/-/foreach-2.0.5.tgz#0bee005018aeb260d0a3af3ae658dd0136ec1b99"

forever-agent@~0.6.1:
version "0.6.1"
resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91"
Expand Down Expand Up @@ -1247,6 +1307,12 @@ inherits@2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.1.tgz#b17d08d326b4423e568eff719f91b0b1cbdf69f1"

inline-source-map@~0.5.0:
version "0.5.0"
resolved "http://npme.walmart.com/inline-source-map/-/inline-source-map-0.5.0.tgz#4a4c5dd8e4fb5e9b3cda60c822dfadcaee66e0af"
dependencies:
source-map "~0.4.0"

inline-source-map@~0.6.0:
version "0.6.2"
resolved "https://registry.yarnpkg.com/inline-source-map/-/inline-source-map-0.6.2.tgz#f9393471c18a79d1724f863fa38b586370ade2a5"
Expand Down Expand Up @@ -1358,14 +1424,14 @@ is-utf8@^0.2.0:
version "0.2.1"
resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72"

isarray@0.0.1, isarray@~0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf"

isarray@1.0.0, isarray@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11"

isarray@~0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf"

isexe@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10"
Expand Down Expand Up @@ -1969,6 +2035,10 @@ object-assign@^4.1.0:
version "4.1.1"
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"

object-keys@^1.0.6:
version "1.0.11"
resolved "http://npme.walmart.com/object-keys/-/object-keys-1.0.11.tgz#c54601778ad560f1142ce0e01bcca8b56d13426d"

object.omit@^2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/object.omit/-/object.omit-2.0.1.tgz#1a9c744829f39dbb858c76ca3579ae2a54ebd1fa"
Expand Down Expand Up @@ -2238,6 +2308,15 @@ read-pkg@^1.0.0:
normalize-package-data "^2.3.2"
path-type "^1.0.0"

"readable-stream@>=1.1.13-1 <1.2.0-0":
version "1.1.14"
resolved "http://npme.walmart.com/readable-stream/-/readable-stream-1.1.14.tgz#7cf4c54ef648e3813084c636dd2079e166c081d9"
dependencies:
core-util-is "~1.0.0"
inherits "~2.0.1"
isarray "0.0.1"
string_decoder "~0.10.x"

readable-stream@^2.0.2, readable-stream@^2.1.5, readable-stream@^2.2.6:
version "2.2.8"
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.2.8.tgz#ad28b686f3554c73d39bc32347fa058356624705"
Expand Down Expand Up @@ -2431,7 +2510,7 @@ source-map@0.1.34:
dependencies:
amdefine ">=0.0.4"

source-map@^0.4.4:
source-map@^0.4.4, source-map@~0.4.0, source-map@~0.4.2:
version "0.4.4"
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.4.4.tgz#eba4f5da9c0dc999de68032d8b4f76173652036b"
dependencies:
Expand Down Expand Up @@ -2595,6 +2674,13 @@ throat@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/throat/-/throat-3.0.0.tgz#e7c64c867cbb3845f10877642f7b60055b8ec0d6"

through2@^1.0.0:
version "1.1.1"
resolved "http://npme.walmart.com/through2/-/through2-1.1.1.tgz#0847cbc4449f3405574dbdccd9bb841b83ac3545"
dependencies:
readable-stream ">=1.1.13-1 <1.2.0-0"
xtend ">=4.0.0 <4.1.0-0"

through2@^2.0.0:
version "2.0.3"
resolved "https://registry.yarnpkg.com/through2/-/through2-2.0.3.tgz#0004569b37c7c74ba39c43f3ced78d1ad94140be"
Expand Down Expand Up @@ -2666,7 +2752,7 @@ ua-parser-js@^0.7.9:
version "0.7.12"
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.12.tgz#04c81a99bdd5dc52263ea29d24c6bf8d4818a4bb"

uglify-js@^2.6:
uglify-js@2.x.x, uglify-js@^2.6:
version "2.8.21"
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.8.21.tgz#1733f669ae6f82fc90c7b25ec0f5c783ee375314"
dependencies:
Expand All @@ -2679,6 +2765,16 @@ uglify-to-browserify@~1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz#6e0924d6bda6b5afe349e39a6d632850a0f882b7"

uglifyify@^3.0.4:
version "3.0.4"
resolved "http://npme.walmart.com/uglifyify/-/uglifyify-3.0.4.tgz#487e080a5a7798880e68e90def9b06681fb13bd2"
dependencies:
convert-source-map "~1.1.0"
extend "^1.2.1"
minimatch "^3.0.2"
through "~2.3.4"
uglify-js "2.x.x"

uglifyjs@^2.4.10:
version "2.4.10"
resolved "https://registry.yarnpkg.com/uglifyjs/-/uglifyjs-2.4.10.tgz#632927319fa6a3da3fc91f9773ac27bfe6c3ee92"
Expand Down