2015-02-20 04:10:52 +00:00
|
|
|
/**
|
2015-03-23 18:48:02 +00:00
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This source code is licensed under the BSD-style license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
2015-02-20 04:10:52 +00:00
|
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
|
2015-06-26 23:18:49 +00:00
|
|
|
var path = require('path');
|
|
|
|
|
2016-01-08 14:51:45 +00:00
|
|
|
// Don't forget to everything listed here to `package.json`
|
2015-02-20 04:10:52 +00:00
|
|
|
// modulePathIgnorePatterns.
|
|
|
|
var sharedBlacklist = [
|
2015-12-30 19:38:44 +00:00
|
|
|
/node_modules[/\\]react[/\\]dist[/\\].*/,
|
|
|
|
'node_modules/react/lib/React.js',
|
|
|
|
'node_modules/react/lib/ReactDOM.js',
|
2015-09-26 02:22:21 +00:00
|
|
|
|
2016-03-03 01:13:47 +00:00
|
|
|
'downstream/core/invariant.js',
|
|
|
|
|
2015-12-30 19:38:44 +00:00
|
|
|
/website\/node_modules\/.*/,
|
2016-01-30 02:17:16 +00:00
|
|
|
|
|
|
|
// TODO(jkassens, #9876132): Remove this rule when it's no longer needed.
|
2016-02-02 04:10:12 +00:00
|
|
|
'Libraries/Relay/relay/tools/relayUnstableBatchedUpdates.js',
|
2015-09-11 22:48:35 +00:00
|
|
|
];
|
|
|
|
|
2015-04-14 15:52:40 +00:00
|
|
|
var platformBlacklists = {
|
|
|
|
web: [
|
2015-09-11 22:48:35 +00:00
|
|
|
'.ios.js',
|
|
|
|
'.android.js',
|
2015-04-14 15:52:40 +00:00
|
|
|
],
|
|
|
|
ios: [
|
|
|
|
'.web.js',
|
|
|
|
'.android.js',
|
|
|
|
],
|
|
|
|
android: [
|
|
|
|
'.web.js',
|
|
|
|
'.ios.js',
|
|
|
|
],
|
|
|
|
};
|
2015-02-20 04:10:52 +00:00
|
|
|
|
2015-12-30 19:38:44 +00:00
|
|
|
function escapeRegExp(pattern) {
|
|
|
|
if (Object.prototype.toString.call(pattern) === '[object RegExp]') {
|
2016-01-02 08:56:32 +00:00
|
|
|
return pattern.source.replace(/\//g, path.sep);
|
2015-12-30 19:38:44 +00:00
|
|
|
} else if (typeof pattern === 'string') {
|
|
|
|
var escaped = pattern.replace(/[\-\[\]\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
|
|
|
|
// convert the '/' into an escaped local file separator
|
|
|
|
return escaped.replace(/\//g,'\\' + path.sep);
|
|
|
|
} else {
|
|
|
|
throw new Error('Unexpected packager blacklist pattern: ' + pattern);
|
|
|
|
}
|
2015-02-20 04:10:52 +00:00
|
|
|
}
|
|
|
|
|
2015-04-14 15:52:40 +00:00
|
|
|
function blacklist(platform, additionalBlacklist) {
|
2015-02-20 04:10:52 +00:00
|
|
|
return new RegExp('(' +
|
2015-03-12 00:44:49 +00:00
|
|
|
(additionalBlacklist || []).concat(sharedBlacklist)
|
2015-04-14 15:52:40 +00:00
|
|
|
.concat(platformBlacklists[platform] || [])
|
2015-02-20 04:10:52 +00:00
|
|
|
.map(escapeRegExp)
|
|
|
|
.join('|') +
|
|
|
|
')$'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = blacklist;
|