How to use the @expo/config.resolveModule function in @expo/config

To help you get started, we’ve selected a few @expo/config examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github expo / expo-cli / packages / xdl / src / project / Doctor.ts View on Github external
}

    ProjectUtils.clearNotification(projectRoot, 'doctor-node-modules-missing');
  } catch (e) {
    ProjectUtils.logError(
      projectRoot,
      'expo',
      `Error: node_modules directory is missing. Please run \`npm install\` in your project directory.`,
      'doctor-node-modules-missing'
    );
    return FATAL;
  }

  // Check to make sure react native is installed
  try {
    resolveModule('react-native/local-cli/cli.js', projectRoot, exp);
    ProjectUtils.clearNotification(projectRoot, 'doctor-react-native-not-installed');
  } catch (e) {
    if (e.code === 'MODULE_NOT_FOUND') {
      ProjectUtils.logError(
        projectRoot,
        'expo',
        `Error: React Native is not installed. Please run \`npm install\` in your project directory.`,
        'doctor-react-native-not-installed'
      );
      return FATAL;
    } else {
      throw e;
    }
  }
  return NO_ISSUES;
}
github expo / expo-cli / packages / xdl / src / Project.ts View on Github external
const customLogReporterPath: string = require.resolve(path.join(__dirname, 'reporter'));

  let packagerOpts: { [key: string]: any } = {
    port: packagerPort,
    customLogReporterPath,
    // TODO: Bacon: Support .mjs (short-lived JS modules extension that some packages use)
    sourceExts: getManagedExtensions([], { isTS: true, isReact: true, isModern: false }),
  };

  if (options.nonPersistent && Versions.lteSdkVersion(exp, '32.0.0')) {
    packagerOpts.nonPersistent = true;
  }

  if (Versions.gteSdkVersion(exp, '33.0.0')) {
    packagerOpts.assetPlugins = resolveModule('expo/tools/hashAssetFiles', projectRoot, exp);
  }

  if (options.maxWorkers) {
    packagerOpts['max-workers'] = options.maxWorkers;
  }

  if (!Versions.gteSdkVersion(exp, '16.0.0')) {
    delete packagerOpts.customLogReporterPath;
  }
  const userPackagerOpts = exp.packagerOpts;
  if (userPackagerOpts) {
    // The RN CLI expects rn-cli.config.js's path to be absolute. We use the
    // project root to resolve relative paths since that was the original
    // behavior of the RN CLI.
    if (userPackagerOpts.config) {
      userPackagerOpts.config = path.resolve(projectRoot, userPackagerOpts.config);
github expo / expo-cli / packages / xdl / src / Project.ts View on Github external
function _requireFromProject(modulePath: string, projectRoot: string, exp: ExpoConfig) {
  try {
    let fullPath = resolveModule(modulePath, projectRoot, exp);
    // Clear the require cache for this module so get a fresh version of it
    // without requiring the user to restart Expo CLI
    decache(fullPath);
    // $FlowIssue: doesn't work with dynamic requires
    return require(fullPath);
  } catch (e) {
    return null;
  }
}
github expo / expo-cli / packages / expo-cli / src / commands / upgrade.ts View on Github external
async function getUpdatedDependenciesAsync(
  projectRoot: string,
  workflow: 'managed' | 'bare',
  targetSdkVersion: {
    expoReactNativeTag: string;
    facebookReactVersion?: string;
    facebookReactNativeVersion: string;
    relatedPackages?: { [name: string]: string };
  } | null
): Promise {
  let result: DependencyList = {};

  // Get the updated version for any bundled modules
  let { exp, pkg } = await ConfigUtils.readConfigJsonAsync(projectRoot);
  let bundledNativeModules = (await JsonFile.readAsync(
    ConfigUtils.resolveModule('expo/bundledNativeModules.json', projectRoot, exp)
  )) as DependencyList;

  // Smoosh regular and dev dependencies together for now
  let dependencies = { ...pkg.dependencies, ...pkg.devDependencies };

  Object.keys(bundledNativeModules).forEach(name => {
    if (dependencies[name]) {
      result[name] = bundledNativeModules[name];
    }
  });

  if (!targetSdkVersion) {
    log.warn(
      `Supported React, React Native, and React DOM versions are unknown because we don't have version information for the target SDK, please update them manually.`
    );
    return result;
github expo / expo-cli / packages / dev-server / src / MetroDevServer.ts View on Github external
function getMetroInstance(projectRoot: string): any {
  const { exp } = readConfigJson(projectRoot, true, true);
  const Metro = require(resolveModule('metro', projectRoot, exp));
  return Metro;
}
github expo / expo-cli / packages / expo-cli / src / commands / start.js View on Github external
const bundleNativeModulesPath = attempt(() =>
    ConfigUtils.resolveModule('expo/bundledNativeModules.json', projectDir, exp)
  );