How to use the enhanced-resolve.sync function in enhanced-resolve

To help you get started, we’ve selected a few enhanced-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 facebookarchive / WebDriverAgent / Inspector / node_modules / webpack / bin / convert-argv.js View on Github external
var loadUtils = require("loader-utils");
			var args = null;
			try {
				var p = name && name.indexOf("?");
				if(p > -1) {
					args = loadUtils.parseQuery(name.substring(p));
					name = name.substring(0, p);
				}
			} catch(e) {
				console.log("Invalid plugin arguments " + name + " (" + e + ").");
				process.exit(-1); // eslint-disable-line
			}

			var path;
			try {
				path = resolve.sync(process.cwd(), name);
			} catch(e) {
				console.log("Cannot resolve plugin " + name + ".");
				process.exit(-1); // eslint-disable-line
			}
			var Plugin;
			try {
				Plugin = require(path);
			} catch(e) {
				console.log("Cannot load plugin " + name + ". (" + path + ")");
				throw e;
			}
			try {
				return new Plugin(args);
			} catch(e) {
				console.log("Cannot instantiate plugin " + name + ". (" + path + ")");
				throw e;
github fossasia / susper.com / node_modules / webpack / bin / convert-argv.js View on Github external
var args;
			try {
				var p = name && name.indexOf("?");
				if(p > -1) {
					args = loadUtils.parseQuery(name.substring(p));
					name = name.substring(0, p);
				}
			} catch(e) {
				console.log("Invalid plugin arguments " + name + " (" + e + ").");
				process.exit(-1); // eslint-disable-line
			}

			var path;
			try {
				var resolve = require("enhanced-resolve");
				path = resolve.sync(process.cwd(), name);
			} catch(e) {
				console.log("Cannot resolve plugin " + name + ".");
				process.exit(-1); // eslint-disable-line
			}
			var Plugin;
			try {
				Plugin = require(path);
			} catch(e) {
				console.log("Cannot load plugin " + name + ". (" + path + ")");
				throw e;
			}
			try {
				return new Plugin(args);
			} catch(e) {
				console.log("Cannot instantiate plugin " + name + ". (" + path + ")");
				throw e;
github TYRMars / ES6-StepPitGuide / es6 / node_modules / webpack / bin / convert-argv.js View on Github external
var args;
			try {
				var p = name && name.indexOf("?");
				if(p > -1) {
					args = loadUtils.parseQuery(name.substring(p));
					name = name.substring(0, p);
				}
			} catch(e) {
				console.log("Invalid plugin arguments " + name + " (" + e + ").");
				process.exit(-1); // eslint-disable-line
			}

			var path;
			try {
				var resolve = require("enhanced-resolve");
				path = resolve.sync(process.cwd(), name);
			} catch(e) {
				console.log("Cannot resolve plugin " + name + ".");
				process.exit(-1); // eslint-disable-line
			}
			var Plugin;
			try {
				Plugin = require(path);
			} catch(e) {
				console.log("Cannot load plugin " + name + ". (" + path + ")");
				throw e;
			}
			try {
				return new Plugin(args);
			} catch(e) {
				console.log("Cannot instantiate plugin " + name + ". (" + path + ")");
				throw e;
github sx1989827 / DOClever / node_modules / webpack / bin / convert-argv.js View on Github external
var args;
			try {
				var p = name && name.indexOf("?");
				if(p > -1) {
					args = loadUtils.parseQuery(name.substring(p));
					name = name.substring(0, p);
				}
			} catch(e) {
				console.log("Invalid plugin arguments " + name + " (" + e + ").");
				process.exit(-1); // eslint-disable-line
			}

			var path;
			try {
				var resolve = require("enhanced-resolve");
				path = resolve.sync(process.cwd(), name);
			} catch(e) {
				console.log("Cannot resolve plugin " + name + ".");
				process.exit(-1); // eslint-disable-line
			}
			var Plugin;
			try {
				Plugin = require(path);
			} catch(e) {
				console.log("Cannot load plugin " + name + ". (" + path + ")");
				throw e;
			}
			try {
				return new Plugin(args);
			} catch(e) {
				console.log("Cannot instantiate plugin " + name + ". (" + path + ")");
				throw e;
github tamb / domponent / node_modules / webpack-cli / bin / utils / convert-argv.js View on Github external
let args;
			try {
				const p = name && name.indexOf("?");
				if (p > -1) {
					args = loadUtils.parseQuery(name.substring(p));
					name = name.substring(0, p);
				}
			} catch (e) {
				console.log("Invalid plugin arguments " + name + " (" + e + ").");
				process.exit(-1); // eslint-disable-line
			}

			let path;
			try {
				const resolve = require("enhanced-resolve");
				path = resolve.sync(process.cwd(), name);
			} catch (e) {
				console.log("Cannot resolve plugin " + name + ".");
				process.exit(-1); // eslint-disable-line
			}
			let Plugin;
			try {
				Plugin = require(path);
			} catch (e) {
				console.log("Cannot load plugin " + name + ". (" + path + ")");
				throw e;
			}
			try {
				return new Plugin(args);
			} catch (e) {
				console.log("Cannot instantiate plugin " + name + ". (" + path + ")");
				throw e;
github sx1989827 / DOClever / Desktop / node_modules / webpack / bin / convert-argv.js View on Github external
var args;
			try {
				var p = name && name.indexOf("?");
				if(p > -1) {
					args = loadUtils.parseQuery(name.substring(p));
					name = name.substring(0, p);
				}
			} catch(e) {
				console.log("Invalid plugin arguments " + name + " (" + e + ").");
				process.exit(-1); // eslint-disable-line
			}

			var path;
			try {
				var resolve = require("enhanced-resolve");
				path = resolve.sync(process.cwd(), name);
			} catch(e) {
				console.log("Cannot resolve plugin " + name + ".");
				process.exit(-1); // eslint-disable-line
			}
			var Plugin;
			try {
				Plugin = require(path);
			} catch(e) {
				console.log("Cannot load plugin " + name + ". (" + path + ")");
				throw e;
			}
			try {
				return new Plugin(args);
			} catch(e) {
				console.log("Cannot instantiate plugin " + name + ". (" + path + ")");
				throw e;
github swissquote / crafty / packages / crafty / src / configuration.js View on Github external
function resolveModule(module) {
  debug("resolveModule", module);

  const presetName = module;

  if (path.isAbsolute(presetName)) {
    return [getPresetName(module), module];
  }

  try {
    // Try the naive way
    return [presetName, require.resolve(module)];
  } catch (e) {
    // Try a more advanced way
    return [presetName, resolve.sync(process.cwd() + "/node_modules", module)];
  }
}
github xing / hops / packages / cli / lib / run.js View on Github external
run() {
    try {
      const rootDir = getRootDir();
      const yargsPath = resolve(rootDir, '@untool/yargs');
      const { configure: configureYargs } = require(yargsPath);
      configureYargs(config, options).run();
    } catch (error) {
      if (error.message && error.message.startsWith("Can't resolve")) {
        console.error("Error: Can't find @untool/yargs \n");
      } else {
        console.error(error.stack ? error.stack.toString() : error.toString());
      }
      process.exit(1);
    }
  },
  configure,
github webpack / enhanced-require / lib / RequireContext.js View on Github external
RequireContext.prototype.theResolve = function theResolve(name, callback) {
	if(callback) {
		if(existsNativeModule(name)) return callback(null, name);
		return resolve(this.context, name, this.root.options.resolve, callback);
	} else {
		if(existsNativeModule(name)) return name;
		return resolve.sync(this.context, name, this.root.options.resolve);
	}
}