🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

webpack

Package Overview
Dependencies
Maintainers
1
Versions
852
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webpack - npm Package Compare versions

Comparing version

to
0.4.17

test/browsertest/libary2config.js

36

lib/buildDeps.js

@@ -153,7 +153,33 @@ /*

// exec the loaders
execLoaders(context, filenameWithLoaders, loaders, [filename], [content], cacheEntry, options, processJs);
var preLoaders = matchLoadersList(options.preLoaders);
var postLoaders = matchLoadersList(options.postLoaders);
resolve.loaders(context, preLoaders, options.resolve, function(err, preLoaders) {
if(err) return callback(err);
resolve.loaders(context, postLoaders, options.resolve, function(err, postLoaders) {
if(err) return callback(err);
execLoaders(context, filenameWithLoaders, preLoaders, [filename], [content], cacheEntry, options,
function(err, result, preLoadersCacheable) {
execLoaders(context, filenameWithLoaders, loaders, [filename], result, cacheEntry, options,
function(err, result, loadersCacheable) {
execLoaders(context, filenameWithLoaders, postLoaders, [filename], result, cacheEntry, options,
function(err, result, postLoadersCacheable) {
if(err) return callback(err);
return processJs(result, loadersCacheable && preLoadersCacheable && postLoadersCacheable)
});
});
});
});
});
});
}
function matchLoadersList(list) {
return list.filter(function(item) {
return (item.test.test(filename));
}).map(function(item) {
return item.loader;
}).join("!");
}
// process the result delivered from loaders or direct from file

@@ -163,7 +189,3 @@ // for inclusion into the result

// [this step is cached]
function processJs(err, resultBuffers, cacheable) {
if(err) {
callback(err);
return;
}
function processJs(resultBuffers, cacheable) {
var source = resultBuffers[0].toString("utf-8")

@@ -170,0 +192,0 @@ var deps;

130

lib/resolve.js

@@ -53,6 +53,58 @@ /*

function doResolve(context, identifier, options, type, callback) {
if(!callback) {
callback = options;
options = {};
var identifiers = identifier.replace(/^!|!$/g, "").replace(/!!/g, "!").split(/!/g);
var resource = identifiers.pop();
resolve(context, resource, options, type, function(err, resource) {
if(err) return callback(err);
if(identifier.indexOf("!") === -1) {
for(var i = 0; i < options.loaders.length; i++) {
var line = options.loaders[i];
if(line.test.test(resource)) {
Array.prototype.push.apply(identifiers, line.loader.split(/!/g));
break;
}
}
}
resolveLoaders(context, identifiers, options, function(err, identifiers) {
identifiers.push(resource);
var intermediateResult = identifiers.join("!");
var postprocessors = options.postprocess[type].slice(0);
postprocessors.push(function(result) {
callback(null, result);
});
(function next(err, result) {
if(err)
return callback(new Error("File \"" + intermediateResult + "\" is blocked by postprocessors: " + err));
postprocessors.shift()(result, next);
})(null, intermediateResult);
});
});
}
function resolveLoaders(context, identifiers, options, callback) {
var errors = [];
var count = identifiers.length;
function endOne() {
count--;
if(count === 0) {
if(errors.length > 0) {
callback(new Error(errors.join("\n")));
return;
}
callback(null, identifiers);
}
}
if(count == 0) endOne(count++);
identifiers.forEach(function(ident, index) {
resolve(context, ident, options, "loader", function(err, filename) {
if(err) {
errors.push(err);
} else {
identifiers[index] = filename;
}
endOne()
});
});
}
function setupDefaultOptions(options) {
if(!options)

@@ -80,49 +132,3 @@ options = {};

options.postprocess.context = [];
var identifiers = identifier.replace(/^!|!$/g, "").replace(/!!/g, "!").split(/!/g);
var resource = identifiers.pop();
resolve(context, resource, options, type, function(err, resource) {
if(err) return callback(err);
if(identifier.indexOf("!") === -1) {
for(var i = 0; i < options.loaders.length; i++) {
var line = options.loaders[i];
if(line.test.test(resource)) {
Array.prototype.push.apply(identifiers, line.loader.split(/!/g));
break;
}
}
}
var errors = [];
var count = identifiers.length;
function endOne() {
count--;
if(count === 0) {
if(errors.length > 0) {
callback(new Error(errors.join("\n")));
return;
}
identifiers.push(resource);
var intermediateResult = identifiers.join("!");
var postprocessors = options.postprocess[type].slice(0);
postprocessors.push(function(result) {
callback(null, result);
});
(function next(err, result) {
if(err)
return callback(new Error("File \"" + intermediateResult + "\" is blocked by postprocessors: " + err));
postprocessors.shift()(result, next);
})(null, intermediateResult);
}
}
if(count == 0) endOne(count++);
identifiers.forEach(function(ident, index) {
resolve(context, ident, options, "loader", function(err, filename) {
if(err) {
errors.push(err);
} else {
identifiers[index] = filename;
}
endOne()
});
});
});
return options;
}

@@ -138,2 +144,7 @@

module.exports = function(context, identifier, options, callback) {
if(!callback) {
callback = options;
options = {};
}
options = setupDefaultOptions(options);
return doResolve(context, identifier, options, "normal", callback);

@@ -143,6 +154,25 @@ }

module.exports.context = function(context, identifier, options, callback) {
if(!callback) {
callback = options;
options = {};
}
options = setupDefaultOptions(options);
return doResolve(context, identifier, options, "context", callback);
}
/**
* callback: function(err, absoluteFilenamesArray)
*/
module.exports.loaders = function(context, identifier, options, callback) {
if(!callback) {
callback = options;
options = {};
}
options = setupDefaultOptions(options);
var identifiers = identifier.replace(/^!|!$/g, "").replace(/!!/g, "!").split(/!/g);
if(identifiers.length == 1 && identifiers[0] == "") return callback(null, []);
return resolveLoaders(context, identifiers, options, callback);
}
function split(a) {

@@ -149,0 +179,0 @@ return a.split(/[\/\\]/g);

@@ -120,2 +120,5 @@ /*

options.preLoaders = options.preLoaders || [];
options.postLoaders = options.postLoaders || [];
options.loader = options.loader || {};

@@ -122,0 +125,0 @@ options.loader.emitFile = options.loader.emitFile || function(filename, content) {

{
"name": "webpack",
"version": "0.4.16",
"version": "0.4.17",
"author": "Tobias Koppers @sokra",

@@ -5,0 +5,0 @@ "description": "Packs CommonJs Modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loading of js, json, jade, coffee, css, ... out of the box and more with custom loaders.",

@@ -53,4 +53,4 @@ /*

var libary2 = cp.spawn("node", join(["../../bin/webpack.js", "--colors", "--libary", "libary2",
"--script-src-prefix", "js/", "node_modules/libary2", "js/libary2.js"], extraArgs));
"--script-src-prefix", "js/", "--options", "libary2config.js", "node_modules/libary2", "js/libary2.js"], extraArgs));
bindOutput(libary2);
}

@@ -10,3 +10,3 @@ // Chunked File Libary

asnycOk2 = true;
window.test(require("./extra") === "Lib2 extra", "Lib2 extra loaded");
window.test(require("./extra") === "Lib2 extra2 with post loader", "Lib2 extra loaded");
window.test(sameTick, "Lib2 Should be in the same tick, as it is a empty chunk");

@@ -13,0 +13,0 @@ });