Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
} else if(!Array.isArray(moduleDescriptor)) {
moduleDescriptor.register(require(moduleDescriptor.module));
} else {
for(var i = 0; i < moduleDescriptor.length; i++) {
try {
registerCompiler(moduleDescriptor[i]);
break;
} catch(e) {
// do nothing
}
}
}
}
}
registerCompiler(interpret.extensions[ext]);
options = require(configPath);
}
return processConfiguredOptions(options);
function processConfiguredOptions(options) {
if(typeof options !== "object" || options === null) {
console.log("Config did not export an object.");
process.exit(-1); // eslint-disable-line
}
// process Promise
if(typeof options.then === "function") {
return options.then(processConfiguredOptions);
}
var jsVars = require('interpret').jsVariants,
endsWith = require('lodash.endswith'),
availableExts = Object.keys(jsVars),
chalk = require('chalk');
// sort extensions to ensure that .babel.js and
// similar ones are always matched before .js
availableExts.sort(function(a, b) {
var res = -(a.split(/\./).length - b.split(/\./).length);
// all things being equal, we need to
// prioritize .js as it is most likely
if(res === 0) {
if(a === '.js') {
return -1;
}
if(b === '.js') {
return 1;
}
return 0;
// Shortcuts
if(argv.d) {
argv.debug = true;
argv["output-pathinfo"] = true;
if(!argv.devtool) {
argv.devtool = "eval-cheap-module-source-map";
}
}
if(argv.p) {
argv["optimize-minimize"] = true;
argv["define"] = [].concat(argv["define"] || []).concat("process.env.NODE_ENV=\"production\"");
}
var configFileLoaded = false;
var configFiles = [];
var extensions = Object.keys(interpret.extensions).sort(function(a, b) {
return a === ".js" ? -1 : b === ".js" ? 1 : a.length - b.length;
});
var defaultConfigFiles = ["webpack.config", "webpackfile"].map(function(filename) {
return extensions.map(function(ext) {
return {
path: path.resolve(filename + ext),
ext: ext
};
});
}).reduce(function(a, i) {
return a.concat(i);
}, []);
var i;
if(argv.config) {
var getConfigExtension = function getConfigExtension(configPath) {
function forEachDataExt(f) {
for (var key in interpret.extensions) {
if (hasOwn.call(interpret.extensions, key) &&
!hasOwn.call(interpret.jsVariants, key)) {
f(key)
}
}
}
function forEachDataExt(f) {
for (var key in interpret.extensions) {
if (hasOwn.call(interpret.extensions, key) &&
!hasOwn.call(interpret.jsVariants, key)) {
f(key)
}
}
}
argv.mode = "production";
}
}
if (argv.output) {
let output = argv.output;
if (!path.isAbsolute(argv.o)) {
output = path.resolve(process.cwd(), output);
}
argv["output-filename"] = path.basename(output);
argv["output-path"] = path.dirname(output);
}
let configFileLoaded = false;
let configFiles = [];
const extensions = Object.keys(interpret.extensions).sort(function(a, b) {
return a === ".js" ? -1 : b === ".js" ? 1 : a.length - b.length;
});
let i;
if (argv.config) {
const getConfigExtension = function getConfigExtension(configPath) {
for (i = extensions.length - 1; i >= 0; i--) {
const tmpExt = extensions[i];
if (configPath.indexOf(tmpExt, configPath.length - tmpExt.length) > -1) {
return tmpExt;
}
}
return path.extname(configPath);
};
const mapConfigArg = function mapConfigArg(configArg) {
configFiles.forEach(function(file) {
registerCompiler(interpret.extensions[file.ext]);
options.push(requireConfig(file.path));
});
configFileLoaded = true;
configFiles.forEach(function(file) {
registerCompiler(interpret.extensions[file.ext]);
options.push(requireConfig(file.path));
});
configFileLoaded = true;
configFiles.forEach(function(file) {
registerCompiler(interpret.extensions[file.ext]);
options.push(requireConfig(file.path));
});
configFileLoaded = true;
configFiles.forEach(function(file) {
registerCompiler(interpret.extensions[file.ext]);
options.push(requireConfig(file.path));
});
configFileLoaded = true;