<commit_before>'use strict';

var fs = require('fs');
var path = require('path');

/**
 * Extract the React Native module paths for a given directory
 *
 * @param {String} rootDir
 * @return {Object}
 */
function getReactNativeExternals(rootDir) {
  var externals = {};
  var file;

  var walk = function(dir) {
    fs.readdirSync(dir).forEach(function(mod) {
      file = path.resolve(dir, mod);
      if (fs.lstatSync(file).isDirectory()) {
        walk(file);
      } else if (path.extname(mod) === '.js') {
        mod = mod.replace(/\.js$/, '');
        // Only externalize RN's "React" dependency (uppercase).
        if (mod !== 'react') {
          externals[mod] = 'commonjs ' + mod;
        }
      }
    });
  }

  walk(rootDir);

  // 'react-native' is aliased as `React` in the global object
  externals['react-native'] = 'React';

  return externals;
}

module.exports = getReactNativeExternals;<commit_msg>allow use of browserified node core modules<commit_after>'use strict';

var fs = require('fs');
var path = require('path');

/**
 * Extract the React Native module paths for a given directory
 *
 * @param {String} rootDir
 * @return {Object}
 */
function getReactNativeExternals(rootDir) {
  var externals = {};
  var file;

  var walk = function(dir) {
    fs.readdirSync(dir).forEach(function(mod) {
      file = path.resolve(dir, mod);
      if (fs.lstatSync(file).isDirectory()) {
        // Skip node_modules directories
        if (!dir.match(/node_modules/)) {
          walk(file);
        }
      } else if (path.extname(mod) === '.js') {
        mod = mod.replace(/\.js$/, '');
        // Only externalize RN's "React" dependency (uppercase).
        if (mod !== 'react') {
          externals[mod] = 'commonjs ' + mod;
        }
      }
    });
  }

  walk(rootDir);

  // 'react-native' is aliased as `React` in the global object
  externals['react-native'] = 'React';

  return externals;
}

module.exports = getReactNativeExternals;
{'fraction_non_alphanumeric': 0.15861718352821555, 'fraction_numerical': 0.0, 'mean_word_length': 2.7557251908396947, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3285210', 'n_tokens_mistral': 638, 'n_tokens_neox': 631, 'n_words': 156}