Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
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;
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;
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;
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;
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;
stats.toJson({modules: true}).modules.forEach(function(mod) {
// Ignore origin modules
if (mod.name.indexOf('~') === -1) {
return;
}
// Resolve webpack query string and loaders to retrieve the resource path.
// webpack dependencies are prepended with (webpack)
// Module directories are represented by a ~
var modulePath = resolve.parse(mod.name).resource.path.replace('(webpack)', './~/webpack');
var moduleFullPath = resolve.parse(mod.identifier).resource.path;
// The following code maps every `~/module_name` in `modulePath` to its corresponding
// `module_folder/module_name` in `moduleFullPath`
// Split at each `~/module_name` and escape for use in a regexp
var splitParts = modulePath.split(/~\/[^\/]+\//).map(escapeRegExp);
// Find and traverse every `module_folder/module_name` construct in `moduleFullPath`
var parentTree = tree;
for (var i = 1; i < splitParts.length; i++) {
// Remove everything before the module occurrence so that match.index points
// to the beginning of the module_folder/module_name construct
var regexpParts = splitParts.slice(i);
var regexpHead = '([^\/]+\/([^\/]+)\/)'; // match `module_folder/module_name`
var regexpTail = regexpParts.join('[^\/]+\/[^\/]+\/'); // match the rest of the path
stats.toJson({modules: true}).modules.forEach(function(mod) {
// Ignore origin modules
if (mod.name.indexOf('~') === -1) {
return;
}
// Resolve webpack query string and loaders to retrieve the resource path.
// webpack dependencies are prepended with (webpack)
// Module directories are represented by a ~
var modulePath = resolve.parse(mod.name).resource.path.replace('(webpack)', './~/webpack');
var moduleFullPath = resolve.parse(mod.identifier).resource.path;
// The following code maps every `~/module_name` in `modulePath` to its corresponding
// `module_folder/module_name` in `moduleFullPath`
// Split at each `~/module_name` and escape for use in a regexp
var splitParts = modulePath.split(/~\/[^\/]+\//).map(escapeRegExp);
// Find and traverse every `module_folder/module_name` construct in `moduleFullPath`
var parentTree = tree;
for (var i = 1; i < splitParts.length; i++) {
// Remove everything before the module occurrence so that match.index points
// to the beginning of the module_folder/module_name construct
var regexpParts = splitParts.slice(i);
var regexpHead = '([^\/]+\/([^\/]+)\/)'; // match `module_folder/module_name`
var regexpTail = regexpParts.join('[^\/]+\/[^\/]+\/'); // match the rest of the path
var regexp = new RegExp(regexpHead + regexpTail + '$');
// @flow
import path from 'path';
import enhancedResolve from 'enhanced-resolve';
import isRequestInRequestMap from './isRequestInRequestMap';
const resolveLoaderSync = enhancedResolve.loader.sync;
export default (context: string, requestMap: Object, request: string, parentFilename: string): any => {
const loaders = request.split('!');
const requestFilePath = loaders.pop();
const resolvedLoaders = loaders
.map((loader: string): string => {
// @todo What is the purpose of the context parameter?
return resolveLoaderSync({}, parentFilename, loader);
})
.map((loaderAbsolutePath: string): string => {
return path.relative(context, loaderAbsolutePath);
});
const absoluteRequestPath = path.resolve(path.dirname(parentFilename), requestFilePath);
const relativeTargetResourcePath = './' + path.relative(context, absoluteRequestPath);
resolver.plugin("described-relative", (request, callback) => {
const directory = request.path;
DescriptionFileUtils.loadDescriptionFile(resolver, directory, ["wat.json"], ((err, result) => {
console.log(directory);
if(err) return callback(err);
if(!result) {
if(callback.missing) {
callback.missing.push(resolver.join(directory, "wat.json"));
}
if(callback.log) callback.log("No description file found");
return callback();
}
const relativePath = "." + request.path.substr(result.directory.length).replace(/\\/g, "/");
// This is the requst that will be passed on to the next resolver plugin.
const obj = Object.assign({}, request, {
descriptionFilePath: result.path,
descriptionFileData: result.content,