How to use the metro.getOrderedDependencyPaths function in metro

To help you get started, we’ve selected a few metro 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 react-native-community / cli / packages / cli / src / commands / dependencies / dependencies.js View on Github external
const options = {
    platform: args.platform,
    entryFile: relativePath,
    dev: args.dev,
    minify: false,
    generateSourceMaps: !args.dev,
  };

  const writeToFile = args.output;
  const outStream = writeToFile
    ? fs.createWriteStream(args.output)
    : process.stdout;

  const deps = packagerInstance
    ? await packagerInstance.getOrderedDependencyPaths(options)
    : await Metro.getOrderedDependencyPaths(config, options);

  deps.forEach(modulePath => {
    // Temporary hack to disable listing dependencies not under this directory.
    // Long term, we need either
    // (a) JS code to not depend on anything outside this directory, or
    // (b) Come up with a way to declare this dependency in Buck.
    const isInsideProjectRoots =
      config.watchFolders.filter(root => modulePath.startsWith(root)).length >
      0;

    if (isInsideProjectRoots) {
      outStream.write(`${modulePath}\n`);
    }
  });
  return writeToFile
    ? denodeify(outStream.end).bind(outStream)()
github react-native-community / cli / packages / local-cli / dependencies / dependencies.js View on Github external
const options = {
    platform: args.platform,
    entryFile: relativePath,
    dev: args.dev,
    minify: false,
    generateSourceMaps: !args.dev,
  };

  const writeToFile = args.output;
  const outStream = writeToFile
    ? fs.createWriteStream(args.output)
    : process.stdout;

  const deps = packagerInstance
    ? await packagerInstance.getOrderedDependencyPaths(options)
    : await Metro.getOrderedDependencyPaths(config, options);

  deps.forEach(modulePath => {
    // Temporary hack to disable listing dependencies not under this directory.
    // Long term, we need either
    // (a) JS code to not depend on anything outside this directory, or
    // (b) Come up with a way to declare this dependency in Buck.
    const isInsideProjectRoots =
      config.watchFolders.filter(root => modulePath.startsWith(root)).length >
      0;

    if (isInsideProjectRoots) {
      outStream.write(`${modulePath}\n`);
    }
  });
  return writeToFile
    ? denodeify(outStream.end).bind(outStream)()