How to use the resolve.sync 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 angelozerr / tern.java / core / ternjs / node_modules / tern-eslint / node_modules / eslint / lib / config / config-file.js View on Github external
if (config) {

        // ensure plugins are properly loaded first
        if (config.plugins) {
            Plugins.loadAll(config.plugins);
        }

        // remove parser from config if it is the default parser
        if (config.parser === defaultOptions.parser) {
            config.parser = null;
        }

        // include full path of parser if present
        if (config.parser) {
            config.parser = resolveModule.sync(config.parser, {basedir: basedir});
        }

        // validate the configuration before continuing
        validator.validate(config, filePath);

        // If an `extends` property is defined, it represents a configuration file to use as
        // a "parent". Load the referenced file and merge the configuration recursively.
        if (config.extends) {
            config = applyExtends(config, filePath, basedir);
        }

        if (config.env && applyEnvironments) {
            // Merge in environment-specific globals and parserOptions.
            config = ConfigOps.applyEnvironments(config);
        }
github embroider-build / embroider / packages / compat / src / compat-app.ts View on Github external
private internalTemplateResolver(): CompatResolver {
    let resolver = new CompatResolver({
      root: this.root,
      modulePrefix: this.modulePrefix(),
      options: this.options,
      activePackageRules: this.activeRules(),
      resolvableExtensions: this.resolvableExtensions(),
    });
    // It's ok that this isn't a fully configured template compiler. We're only
    // using it to parse component snippets out of rules.
    resolver.astTransformer(
      new TemplateCompiler({
        compilerPath: resolveSync(this.templateCompilerPath(), { basedir: this.root }),
        EmberENV: {},
        plugins: {},
      })
    );
    return resolver;
  }
github holo-rea / holo-rea-proto / src / ui / config / webpack.config.js View on Github external
clientsClaim: true,
          exclude: [/\.map$/, /asset-manifest\.json$/],
          importWorkboxFrom: 'cdn',
          navigateFallback: publicUrl + '/index.html',
          navigateFallbackBlacklist: [
            // Exclude URLs starting with /_, as they're likely an API call
            new RegExp('^/_'),
            // Exclude URLs containing a dot, as they're likely a resource in
            // public/ and not a SPA route
            new RegExp('/[^/]+\\.[^/]+$')
          ]
        }),
      // TypeScript type checking
      useTypeScript &&
        new ForkTsCheckerWebpackPlugin({
          typescript: resolve.sync('typescript', {
            basedir: paths.appNodeModules
          }),
          async: false,
          checkSyntacticErrors: true,
          tsconfig: paths.appTsConfig,
          compilerOptions: {
            module: 'esnext',
            moduleResolution: 'node',
            resolveJsonModule: true,
            isolatedModules: true,
            noEmit: true,
            jsx: 'preserve'
          },
          reportFiles: [
            '**',
            '!**/*.json',
github UCSD / campus-mobile / node_modules / eslint-plugin-react / lib / util / version.js View on Github external
function detectFlowVersion() {
  try {
    const flowPackageJsonPath = resolve.sync('flow-bin/package.json', {basedir: process.cwd()});
    const flowPackageJson = require(flowPackageJsonPath); // eslint-disable-line import/no-dynamic-require
    return flowPackageJson.version;
  } catch (e) {
    if (e.code === 'MODULE_NOT_FOUND') {
      error('Warning: Flow version was set to "detect" in eslint-plugin-react settings, ' +
        'but the "flow-bin" package is not installed. Assuming latest Flow version for linting.');
      return '999.999.999';
    }
    throw e;
  }
}
github lifegadget / ember-cli-bootstrap-sassy / index.js View on Github external
init() {
    this._super.init && this._super.init.apply(this, arguments);

    this._bootstrapPath = path.dirname(resolve.sync('bootstrap-sass/package.json')) + '/assets';
  },
github BohdanTkachenko / eslint-plugin-require-path-exists / src / exists.js View on Github external
return;
  }

  if (aliases[value] !== undefined) {
    value = aliases[value];
  } else {
    for (const key of Object.keys(aliases)) {
      if (value.startsWith(`${key}/`)) {
        value = value.replace(`${key}/`, `${aliases[key]}/`);
        break;
      }
    }
  }

  try {
    resolve.sync(value, {
      basedir: fileDir,
      extensions,
      paths: process.env.NODE_PATH
        ? [process.env.NODE_PATH]
        : undefined
    });
  } catch (e) {
    return e.message;
  }
}
github sequelize / cli / src / helpers / path-helper.js View on Github external
resolve (packageName) {
    let result;

    try {
      result = resolve(packageName, { basedir: process.cwd() });
      result = require(result);
    } catch (e) {
      try {
        result = require(packageName);
      } catch (err) {}
    }

    return result;
  },
github h2non / requireg / lib / resolvers.js View on Github external
function resolveFn(module, basePath, dirname) {
  try {
    return resolve(module, {
      basedir: path.join(basePath, dirname || '')
    })
  } catch (e) {}
}
github embroider-build / embroider / packages / core / src / app.ts View on Github external
private impliedAddonAssets(type: keyof ImplicitAssetPaths): string[] {
    let result: Array = [];
    for (let addon of sortBy(this.adapter.allActiveAddons, this.scriptPriority.bind(this))) {
      let implicitScripts = addon.meta[type];
      if (implicitScripts) {
        let styles = [];
        let options = { basedir: addon.root };
        for (let mod of implicitScripts) {
          if (type === 'implicit-styles') {
            styles.push(resolve.sync(mod, options));
          } else {
            result.push(resolve.sync(mod, options));
          }
        }
        if (styles.length) {
          result = [...styles, ...result];
        }
      }
    }
    return result;
  }
github KidkArolis / healthier / options.js View on Github external
function usingReact() {
  try {
    const reactPath = resolve.sync('react', { basedir: process.cwd() })
    require(reactPath)
    return true
  } catch (e) {
    return false
  }
}

resolve

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

MIT
Latest version published 7 months ago

Package Health Score

76 / 100
Full package analysis