Skip to content

Commit

Permalink
Fix UMD build
Browse files Browse the repository at this point in the history
  • Loading branch information
acdlite committed Apr 8, 2017
1 parent 85a4561 commit 31e9344
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 209 deletions.
5 changes: 4 additions & 1 deletion package.json
Expand Up @@ -27,12 +27,15 @@
},
"scripts": {
"test": "jest",
"umd": "browserify index.js --standalone PropTypes -o prop-types.js && uglifyjs prop-types.js --compress unused,dead_code -o prop-types.min.js"
"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",
"build": "yarn umd && yarn umd-min"
},
"devDependencies": {
"babel-jest": "^19.0.0",
"babel-preset-react": "^6.24.1",
"browserify": "^14.3.0",
"envify": "^4.0.0",
"jest": "^19.0.2",
"react": "^15.5.1",
"uglifyjs": "^2.4.10"
Expand Down
220 changes: 15 additions & 205 deletions prop-types.js
@@ -1,5 +1,4 @@
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.PropTypes = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
(function (process){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
Expand Down Expand Up @@ -30,7 +29,7 @@ var loggedTypeFailures = {};
* @private
*/
function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
if (process.env.NODE_ENV !== 'production') {
if ("development" !== 'production') {
for (var typeSpecName in typeSpecs) {
if (typeSpecs.hasOwnProperty(typeSpecName)) {
var error;
Expand All @@ -45,15 +44,15 @@ function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
} catch (ex) {
error = ex;
}
process.env.NODE_ENV !== 'production' ? warning(!error || error instanceof Error, '%s: type specification of %s `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error) : void 0;
"development" !== 'production' ? warning(!error || error instanceof Error, '%s: type specification of %s `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error) : void 0;
if (error instanceof Error && !(error.message in loggedTypeFailures)) {
// Only monitor this failure once because there tends to be a lot of the
// same error.
loggedTypeFailures[error.message] = true;

var stack = getStack ? getStack() : '';

process.env.NODE_ENV !== 'production' ? warning(false, 'Failed %s type: %s%s', location, error.message, stack != null ? stack : '') : void 0;
"development" !== 'production' ? warning(false, 'Failed %s type: %s%s', location, error.message, stack != null ? stack : '') : void 0;
}
}
}
Expand All @@ -62,9 +61,7 @@ function checkPropTypes(typeSpecs, values, location, componentName, getStack) {

module.exports = checkPropTypes;

}).call(this,require('_process'))
},{"./lib/ReactPropTypesSecret":4,"_process":8,"fbjs/lib/invariant":6,"fbjs/lib/warning":7}],2:[function(require,module,exports){
(function (process){
},{"./lib/ReactPropTypesSecret":4,"fbjs/lib/invariant":6,"fbjs/lib/warning":7}],2:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
Expand Down Expand Up @@ -160,7 +157,7 @@ module.exports = function (isValidElement) {

var ReactPropTypes;

if (process.env.NODE_ENV !== 'production') {
if ("development" !== 'production') {
// Keep in sync with production version below
ReactPropTypes = {
array: createPrimitiveTypeChecker('array'),
Expand Down Expand Up @@ -244,17 +241,17 @@ module.exports = function (isValidElement) {
PropTypeError.prototype = Error.prototype;

function createChainableTypeChecker(validate) {
if (process.env.NODE_ENV !== 'production') {
if ("development" !== 'production') {
var manualPropTypeCallCache = {};
}
function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
componentName = componentName || ANONYMOUS;
propFullName = propFullName || propName;
if (process.env.NODE_ENV !== 'production') {
if ("development" !== 'production') {
if (secret !== ReactPropTypesSecret && typeof console !== 'undefined') {
var cacheKey = componentName + ':' + propName;
if (!manualPropTypeCallCache[cacheKey]) {
process.env.NODE_ENV !== 'production' ? warning(false, 'You are manually calling a React.PropTypes validation ' + 'function for the `%s` prop on `%s`. This is deprecated ' + 'and will not work in production with the next major version. ' + 'You may be seeing this warning due to a third-party PropTypes ' + 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.', propFullName, componentName) : void 0;
"development" !== 'production' ? warning(false, 'You are manually calling a React.PropTypes validation ' + 'function for the `%s` prop on `%s`. This is deprecated ' + 'and will not work in production with the next major version. ' + 'You may be seeing this warning due to a third-party PropTypes ' + 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.', propFullName, componentName) : void 0;
manualPropTypeCallCache[cacheKey] = true;
}
}
Expand Down Expand Up @@ -346,7 +343,7 @@ module.exports = function (isValidElement) {

function createEnumTypeChecker(expectedValues) {
if (!Array.isArray(expectedValues)) {
process.env.NODE_ENV !== 'production' ? warning(false, 'Invalid argument supplied to oneOf, expected an instance of array.') : void 0;
"development" !== 'production' ? warning(false, 'Invalid argument supplied to oneOf, expected an instance of array.') : void 0;
return emptyFunction.thatReturnsNull;
}

Expand Down Expand Up @@ -389,7 +386,7 @@ module.exports = function (isValidElement) {

function createUnionTypeChecker(arrayOfTypeCheckers) {
if (!Array.isArray(arrayOfTypeCheckers)) {
process.env.NODE_ENV !== 'production' ? warning(false, 'Invalid argument supplied to oneOfType, expected an instance of array.') : void 0;
"development" !== 'production' ? warning(false, 'Invalid argument supplied to oneOfType, expected an instance of array.') : void 0;
return emptyFunction.thatReturnsNull;
}

Expand Down Expand Up @@ -550,8 +547,7 @@ module.exports = function (isValidElement) {
return ReactPropTypes;
};

}).call(this,require('_process'))
},{"./checkPropTypes":1,"./lib/ReactPropTypesSecret":4,"_process":8,"fbjs/lib/emptyFunction":5,"fbjs/lib/invariant":6,"fbjs/lib/warning":7}],3:[function(require,module,exports){
},{"./checkPropTypes":1,"./lib/ReactPropTypesSecret":4,"fbjs/lib/emptyFunction":5,"fbjs/lib/invariant":6,"fbjs/lib/warning":7}],3:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
Expand Down Expand Up @@ -632,7 +628,6 @@ emptyFunction.thatReturnsArgument = function (arg) {

module.exports = emptyFunction;
},{}],6:[function(require,module,exports){
(function (process){
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
Expand All @@ -658,7 +653,7 @@ module.exports = emptyFunction;

var validateFormat = function validateFormat(format) {};

if (process.env.NODE_ENV !== 'production') {
if ("development" !== 'production') {
validateFormat = function validateFormat(format) {
if (format === undefined) {
throw new Error('invariant requires an error message argument');
Expand Down Expand Up @@ -688,9 +683,7 @@ function invariant(condition, format, a, b, c, d, e, f) {
}

module.exports = invariant;
}).call(this,require('_process'))
},{"_process":8}],7:[function(require,module,exports){
(function (process){
},{}],7:[function(require,module,exports){
/**
* Copyright 2014-2015, Facebook, Inc.
* All rights reserved.
Expand All @@ -714,7 +707,7 @@ var emptyFunction = require('./emptyFunction');

var warning = emptyFunction;

if (process.env.NODE_ENV !== 'production') {
if ("development" !== 'production') {
(function () {
var printWarning = function printWarning(format) {
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
Expand Down Expand Up @@ -757,188 +750,5 @@ if (process.env.NODE_ENV !== 'production') {
}

module.exports = warning;
}).call(this,require('_process'))
},{"./emptyFunction":5,"_process":8}],8:[function(require,module,exports){
// shim for using process in browser
var process = module.exports = {};

// cached from whatever global is present so that test runners that stub it
// don't break things. But we need to wrap it in a try catch in case it is
// wrapped in strict mode code which doesn't define any globals. It's inside a
// function because try/catches deoptimize in certain engines.

var cachedSetTimeout;
var cachedClearTimeout;

function defaultSetTimout() {
throw new Error('setTimeout has not been defined');
}
function defaultClearTimeout () {
throw new Error('clearTimeout has not been defined');
}
(function () {
try {
if (typeof setTimeout === 'function') {
cachedSetTimeout = setTimeout;
} else {
cachedSetTimeout = defaultSetTimout;
}
} catch (e) {
cachedSetTimeout = defaultSetTimout;
}
try {
if (typeof clearTimeout === 'function') {
cachedClearTimeout = clearTimeout;
} else {
cachedClearTimeout = defaultClearTimeout;
}
} catch (e) {
cachedClearTimeout = defaultClearTimeout;
}
} ())
function runTimeout(fun) {
if (cachedSetTimeout === setTimeout) {
//normal enviroments in sane situations
return setTimeout(fun, 0);
}
// if setTimeout wasn't available but was latter defined
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
cachedSetTimeout = setTimeout;
return setTimeout(fun, 0);
}
try {
// when when somebody has screwed with setTimeout but no I.E. maddness
return cachedSetTimeout(fun, 0);
} catch(e){
try {
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
return cachedSetTimeout.call(null, fun, 0);
} catch(e){
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
return cachedSetTimeout.call(this, fun, 0);
}
}


}
function runClearTimeout(marker) {
if (cachedClearTimeout === clearTimeout) {
//normal enviroments in sane situations
return clearTimeout(marker);
}
// if clearTimeout wasn't available but was latter defined
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
cachedClearTimeout = clearTimeout;
return clearTimeout(marker);
}
try {
// when when somebody has screwed with setTimeout but no I.E. maddness
return cachedClearTimeout(marker);
} catch (e){
try {
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
return cachedClearTimeout.call(null, marker);
} catch (e){
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
// Some versions of I.E. have different rules for clearTimeout vs setTimeout
return cachedClearTimeout.call(this, marker);
}
}



}
var queue = [];
var draining = false;
var currentQueue;
var queueIndex = -1;

function cleanUpNextTick() {
if (!draining || !currentQueue) {
return;
}
draining = false;
if (currentQueue.length) {
queue = currentQueue.concat(queue);
} else {
queueIndex = -1;
}
if (queue.length) {
drainQueue();
}
}

function drainQueue() {
if (draining) {
return;
}
var timeout = runTimeout(cleanUpNextTick);
draining = true;

var len = queue.length;
while(len) {
currentQueue = queue;
queue = [];
while (++queueIndex < len) {
if (currentQueue) {
currentQueue[queueIndex].run();
}
}
queueIndex = -1;
len = queue.length;
}
currentQueue = null;
draining = false;
runClearTimeout(timeout);
}

process.nextTick = function (fun) {
var args = new Array(arguments.length - 1);
if (arguments.length > 1) {
for (var i = 1; i < arguments.length; i++) {
args[i - 1] = arguments[i];
}
}
queue.push(new Item(fun, args));
if (queue.length === 1 && !draining) {
runTimeout(drainQueue);
}
};

// v8 likes predictible objects
function Item(fun, array) {
this.fun = fun;
this.array = array;
}
Item.prototype.run = function () {
this.fun.apply(null, this.array);
};
process.title = 'browser';
process.browser = true;
process.env = {};
process.argv = [];
process.version = ''; // empty string to avoid regexp issues
process.versions = {};

function noop() {}

process.on = noop;
process.addListener = noop;
process.once = noop;
process.off = noop;
process.removeListener = noop;
process.removeAllListeners = noop;
process.emit = noop;

process.binding = function (name) {
throw new Error('process.binding is not supported');
};

process.cwd = function () { return '/' };
process.chdir = function (dir) {
throw new Error('process.chdir is not supported');
};
process.umask = function() { return 0; };

},{}]},{},[3])(3)
},{"./emptyFunction":5}]},{},[3])(3)
});

0 comments on commit 31e9344

Please sign in to comment.