Last active
March 8, 2020 16:21
-
-
Save ptmt/b1473dead098cf53d667e355aedf2a7b to your computer and use it in GitHub Desktop.
rn-cli.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
}, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@ndbroadbent, indeed, you're right, thanks for the correction