Skip to content

Instantly share code, notes, and snippets.

@ptmt
Last active March 8, 2020 16:21
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ptmt/b1473dead098cf53d667e355aedf2a7b to your computer and use it in GitHub Desktop.
Save ptmt/b1473dead098cf53d667e355aedf2a7b to your computer and use it in GitHub Desktop.
rn-cli.config.js
const path = require('path');
// Don't forget to everything listed here to `package.json`
// modulePathIgnorePatterns.
const sharedBlacklist = [
/node_modules[/\\]react[/\\]dist[/\\].*/,
'downstream/core/invariant.js',
/website\/node_modules\/.*/,
// TODO(jkassens, #9876132): Remove this rule when it's no longer needed.
'Libraries/Relay/relay/tools/relayUnstableBatchedUpdates.js',
];
const platformBlacklists = {
web: [
'.ios.js',
'.android.js',
],
ios: [
'.web.js',
// '.android.js',
/node_modules\/react-native-macos\/.*/,
],
android: [
'.web.js',
'.ios.js',
/node_modules\/react-native-macos\/.*/,
],
macos: [
'.ios.js',
'.android.js',
/node_modules\/react-native\/.*/,
],
};
function escapeRegExp(pattern) {
if (Object.prototype.toString.call(pattern) === '[object RegExp]') {
return pattern.source.replace(/\//g, path.sep);
} else if (typeof pattern === 'string') {
const escaped = pattern.replace(/[\-\[\]\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
// convert the '/' into an escaped local file separator
return escaped.replace(/\//g, `\\${path.sep}`);
}
throw new Error(`Unexpected packager blacklist pattern: ${pattern}`);
}
function blacklist(platform, additionalBlacklist) {
// eslint-disable-next-line
return new RegExp('(' +
(additionalBlacklist || []).concat(sharedBlacklist)
.concat(platformBlacklists[platform] || [])
.map(escapeRegExp)
.join('|') +
')$'
);
}
module.exports = {
getBlacklistRE(platform) {
if (process && process.argv.filter(a => a.indexOf('react-native-macos') > -1).length > 0) {
return blacklist('macos')
}
return blacklist(platform);
},
};
@ndbroadbent
Copy link

Hi @ptmt, just wanted to mention that you have a bug on line 65 - I think it should be:

return blacklist(platform);

@ptmt
Copy link
Author

ptmt commented Jul 13, 2017

@ndbroadbent, indeed, you're right, thanks for the correction

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment