How to use the metro-resolver.FailedToResolveNameError function in metro-resolver

To help you get started, we’ve selected a few metro-resolver 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 facebook / metro / packages / metro / src / node-haste / DependencyGraph / ModuleResolution.js View on Github external
const {candidates} = error;
        throw new UnableToResolveError(
          path.relative(this._options.projectRoot, fromModule.path),
          moduleName,
          [
            '\n\nNone of these files exist:',
            `  * ${Resolver.formatFileCandidates(
              this._removeRoot(candidates.file),
            )}`,
            `  * ${Resolver.formatFileCandidates(
              this._removeRoot(candidates.dir),
            )}`,
          ].join('\n'),
        );
      }
      if (error instanceof Resolver.FailedToResolveNameError) {
        const {
          dirPaths,
          extraPaths,
        }: {
          // $flowfixme these types are defined explicitly in FailedToResolveNameError but Flow refuses to recognize them here
          dirPaths: $ReadOnlyArray,
          extraPaths: $ReadOnlyArray,
          ...
        } = error;
        const displayDirPaths = dirPaths
          .filter((dirPath: string) => this._options.dirExists(dirPath))
          .map(dirPath => path.relative(this._options.projectRoot, dirPath))
          .concat(extraPaths);

        const hint = displayDirPaths.length ? ' or in these directories:' : '';
        throw new UnableToResolveError(
github alan-ai / alan-sdk-reactnative / testtools / node_modules / metro / src / node-haste / DependencyGraph / ModuleResolution.js View on Github external
throw new UnableToResolveError(
          path.relative(this._options.projectRoot, fromModule.path),
          moduleName,
          [
            "\n\nNone of these files exist:",
            `  * ${Resolver.formatFileCandidates(
              this._removeRoot(candidates.file)
            )}`,
            `  * ${Resolver.formatFileCandidates(
              this._removeRoot(candidates.dir)
            )}`
          ].join("\n")
        );
      }

      if (error instanceof Resolver.FailedToResolveNameError) {
        const dirPaths = error.dirPaths,
          extraPaths = error.extraPaths;
        const displayDirPaths = dirPaths
          .filter(dirPath => this._options.dirExists(dirPath))
          .map(dirPath => path.relative(this._options.projectRoot, dirPath))
          .concat(extraPaths);
        const hint = displayDirPaths.length ? " or in these directories:" : "";
        throw new UnableToResolveError(
          path.relative(this._options.projectRoot, fromModule.path),
          moduleName,
          [`${moduleName} could not be found within the project${hint || "."}`]
            .concat(
              _toConsumableArray(
                displayDirPaths.map(dirPath => `  ${path.dirname(dirPath)}`)
              ),
              [
github Marwan01 / food-converter / node_modules / metro / src / node-haste / DependencyGraph / ModuleResolution.js View on Github external
if (error instanceof Resolver.FailedToResolvePathError) {
        const candidates = error.candidates;
        throw new UnableToResolveError(
          fromModule.path,
          moduleName,
          [
            `The module \`${moduleName}\` could not be found from \`${
              fromModule.path
            }\`. Indeed, none of these files exist:`,
            `  * \`${Resolver.formatFileCandidates(candidates.file)}\``,
            `  * \`${Resolver.formatFileCandidates(candidates.dir)}\``
          ].join("\n")
        );
      }

      if (error instanceof Resolver.FailedToResolveNameError) {
        const dirPaths = error.dirPaths,
          extraPaths = error.extraPaths;
        const displayDirPaths = dirPaths
          .filter(dirPath => this._options.dirExists(dirPath))
          .concat(extraPaths);
        const hint = displayDirPaths.length ? " or in these directories:" : "";
        throw new UnableToResolveError(
          fromModule.path,
          moduleName,
          [
            `Module \`${moduleName}\` does not exist in the Haste module map${hint}`
          ]
            .concat(
              _toConsumableArray(
                displayDirPaths.map(dirPath => `  ${path.dirname(dirPath)}`)
              ),

metro-resolver

🚇 Implementation of Metro's resolution logic.

MIT
Latest version published 1 month ago

Package Health Score

95 / 100
Full package analysis

Similar packages