How to use the metro-resolver.InvalidPackageError 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 Marwan01 / food-converter / node_modules / metro / src / node-haste / DependencyGraph / ResolutionRequest.js View on Github external
*
 *
 * @format
 */
"use strict";

const path = require("path");

const _require = require("metro-core"),
  AmbiguousModuleResolutionError = _require.AmbiguousModuleResolutionError;

const DuplicateHasteCandidatesError = require("jest-haste-map").ModuleMap
  .DuplicateHasteCandidatesError;

const _require2 = require("metro-resolver"),
  InvalidPackageError = _require2.InvalidPackageError;

const _require3 = require("metro-core"),
  PackageResolutionError = _require3.PackageResolutionError;

class ResolutionRequest {
  constructor(options) {
    this._options = options;

    this._resetResolutionCache();
  }

  resolveDependency(fromModule, toModuleName) {
    const resHash = getResolutionCacheKey(fromModule.path, toModuleName);
    const immediateResolution = this._immediateResolutionCache[resHash];

    if (immediateResolution) {
github Marwan01 / food-converter / node_modules / metro-core / src / errors / PackageResolutionError.js View on Github external
/**
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 *  strict-local
 * @format
 */
"use strict";

const _require = require("metro-resolver"),
  formatFileCandidates = _require.formatFileCandidates;

const _require2 = require("metro-resolver"),
  InvalidPackageError = _require2.InvalidPackageError;

class PackageResolutionError extends Error {
  constructor(opts) {
    const perr = opts.packageError;
    super(
      `While trying to resolve module \`${opts.targetModuleName}\` from file ` +
        `\`${opts.originModulePath}\`, the package ` +
        `\`${perr.packageJsonPath}\` was successfully found. However, ` +
        "this package itself specifies " +
        "a `main` module field that could not be resolved (" +
        `\`${perr.mainPrefixPath}\`. Indeed, none of these files exist:\n\n` +
        `  * \`${formatFileCandidates(perr.fileCandidates)}\`\n` +
        `  * \`${formatFileCandidates(perr.indexCandidates)}\``
    );
    Object.assign(this, opts);
  }

metro-resolver

🚇 Implementation of Metro's resolution logic.

MIT
Latest version published 2 days ago

Package Health Score

95 / 100
Full package analysis

Similar packages