How to use the resolve.isCore function in resolve

To help you get started, we’ve selected a few resolve 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 mysticatea / eslint-plugin-node / lib / util / visit-import.js View on Github external
]](node) {
            const sourceNode = node.source

            // skip `import(foo)`
            if (
                node.type === "ImportExpression" &&
                sourceNode &&
                sourceNode.type !== "Literal"
            ) {
                return
            }

            const name = sourceNode && stripImportPathParams(sourceNode.value)
            if (name && (includeCore || !resolve.isCore(name))) {
                targets.push(new ImportTarget(sourceNode, name, options))
            }
        },
github Testlio / lambda-tools / lib / helpers / dependencies.js View on Github external
pkgResolve(id, { basedir: basedir }, function(error, result, pkg) {
            if (pkgResolve.isCore(id)) {
                resolve({
                    name: id,
                    core: true
                });
            } else if (pkg && pkgResolve.isCore(pkg.name)) {
                resolve({
                    name: pkg.name,
                    core: true
                });
            } else if (pkg && !(_.startsWith(id, '.') || _.startsWith(id, '/'))) {
                const pkgPath = path.resolve(path.dirname(result).split(pkg.name)[0] + '/', pkg.name);

                resolve({
                    name: pkg.name,
                    version: pkg.version,
                    dependencies: pkg.dependencies,
                    path: pkgPath
                });
            } else {
                resolve({
                    name: id,
github npm / normalize-package-data / lib / fixer.js View on Github external
, fixNameField: function(data, options) {
    if (typeof options === "boolean") options = {strict: options}
    else if (typeof options === "undefined") options = {}
    var strict = options.strict
    if (!data.name && !strict) {
      data.name = ""
      return
    }
    if (typeof data.name !== "string") {
      throw new Error("name field must be a string.")
    }
    if (!strict)
      data.name = data.name.trim()
    ensureValidName(data.name, strict, options.allowLegacyCase)
    if (isBuiltinModule(data.name))
      this.warn("conflictingName", data.name)
  }
github mysticatea / eslint-plugin-node / lib / util / visit-require.js View on Github external
"Program:exit"() {
            const tracker = new ReferenceTracker(context.getScope())
            const references = tracker.iterateGlobalReferences({
                require: {
                    [CALL]: true,
                    resolve: { [CALL]: true },
                },
            })

            for (const { node } of references) {
                const targetNode = node.arguments[0]
                const rawName = getStringIfConstant(targetNode)
                const name = rawName && stripImportPathParams(rawName)
                if (name && (includeCore || !resolve.isCore(name))) {
                    targets.push(new ImportTarget(targetNode, name, options))
                }
            }

            callback(targets)
        },
    }
github learningequality / kolibri / packages / kolibri-tools / lib / alias_import_resolver.js View on Github external
function nodeResolver(source, file, config) {
  if (resolve.isCore(source)) {
    return { found: true, path: null };
  }
  try {
    return { found: true, path: resolve.sync(source, opts(file, config)) };
  } catch (err) {
    return { found: false };
  }
}
github facebook / jest / eslintImportResolver.js View on Github external
module.exports.resolve = function(source, file, config) {
  log('Resolving:', source, 'from:', file);
  let resolvedPath;

  if (resolve.isCore(source)) {
    log('resolved to core');
    return {found: true, path: null};
  }

  source = applyModuleNameMapper(source, config);

  try {
    resolvedPath = resolve.sync(source, opts(file, config));
    log('Resolved to:', resolvedPath);
    return {found: true, path: resolvedPath};
  } catch (err) {
    log('resolve threw error:', err);
    return {found: false};
  }
};
github android-js / androidjs-builder / example / helloworld / node_modules / normalize-package-data / lib / fixer.js View on Github external
, fixNameField: function(data, options) {
    if (typeof options === "boolean") options = {strict: options}
    else if (typeof options === "undefined") options = {}
    var strict = options.strict
    if (!data.name && !strict) {
      data.name = ""
      return
    }
    if (typeof data.name !== "string") {
      throw new Error("name field must be a string.")
    }
    if (!strict)
      data.name = data.name.trim()
    ensureValidName(data.name, strict, options.allowLegacyCase)
    if (isBuiltinModule(data.name))
      this.warn("conflictingName", data.name)
  }
github benmosher / eslint-plugin-import / resolvers / node / index.js View on Github external
exports.resolve = function (source, file, config) {
  log('Resolving:', source, 'from:', file)
  var resolvedPath

  if (resolve.isCore(source)) {
    log('resolved to core')
    return { found: true, path: null }
  }

  try {
    resolvedPath = resolve.sync(source, opts(file, config))
    log('Resolved to:', resolvedPath)
    return { found: true, path: resolvedPath }
  } catch (err) {
    log('resolve threw error:', err)
    return { found: false }
  }
}
github makuga01 / dnsFookup / FE / node_modules / eslint-import-resolver-node / index.js View on Github external
exports.resolve = function (source, file, config) {
  log('Resolving:', source, 'from:', file)
  var resolvedPath

  if (resolve.isCore(source)) {
    log('resolved to core')
    return { found: true, path: null }
  }

  try {
    resolvedPath = resolve.sync(source, opts(file, config))
    log('Resolved to:', resolvedPath)
    return { found: true, path: resolvedPath }
  } catch (err) {
    log('resolve threw error:', err)
    return { found: false }
  }
}

resolve

resolve like require.resolve() on behalf of files asynchronously and synchronously

MIT
Latest version published 3 days ago

Package Health Score

80 / 100
Full package analysis