Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

webpack

Package Overview
Dependencies
Maintainers
1
Versions
839
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 0.2.0 to 0.2.1

49

bin/webpack.js

@@ -9,2 +9,4 @@ #!/usr/bin/env node

var fs = require("fs");
var util = require("util");
var sprintf = require("sprintf").sprintf;
var argv = require("optimist")

@@ -38,2 +40,6 @@ .usage("Usage: $0 <input> <output>")

.boolean("json")
.describe("json", "Output Stats as JSON")
.default("json", false)
.demand(1)

@@ -101,4 +107,45 @@ .argv;

}
console.log(require("util").inspect(stats, false, 10, argv.colors));
if(argv.json)
console.log(util.inspect(stats, false, 10, argv.colors));
else {
console.log("Chunks: \033[1m" + stats.chunkCount + "\033[22m");
console.log("Modules: \033[1m" + stats.modulesCount + "\033[22m");
console.log("Modules including duplicates: \033[1m" + stats.modulesIncludingDuplicates + "\033[22m");
console.log("Modules pre chunk: \033[1m" + stats.modulesPerChunk + "\033[22m");
console.log("Modules first chunk: \033[1m" + stats.modulesFirstChunk + "\033[22m");
if(stats.fileSizes)
for(var file in stats.fileSizes) {
console.log("\033[1m" + sprintf("%" + (5 + options.output.length) + "s", file) + "\033[22m: \033[1m" + sprintf("%8d", stats.fileSizes[file]) + "\033[22m characters");
};
if(stats.fileModules) {
for(var file in stats.fileModules) {
console.log("\033[1m\033[32m" + file + "\033[39m\033[22m");
var modules = stats.fileModules[file];
modules.forEach(function(module) {
console.log(" \033[1m" + sprintf("%3s", module.id+"") + " " + (module.filename || (module.dirname && ("generated " + module.dirname)) || "generated") + "\033[22m");
module.reasons.forEach(function(reason) {
switch(reason.type) {
case "require":
console.log(" \033[36mrequire (" + reason.count + "x) from " + reason.filename + "\033[39m");
break;
case "context":
console.log(" \033[90mcontext from " + reason.filename + "\033[39m");
break;
case "ensure":
console.log(" \033[35mensure from " + reason.filename + "\033[39m");
break;
default:
console.log(" \033[31m" + reason.type + "\033[39m");
}
});
});
}
}
if(stats.warnings) {
stats.warnings.forEach(function(warning) {
console.log("\033[1m\033[33mWARNING: " + warning + "\033[39m\033[22m");
});
}
}
});
}

49

lib/buildDeps.js

@@ -33,3 +33,3 @@ /*

var mainModuleId;
addModule(depTree, context, mainModule, options, function(err, id) {
addModule(depTree, context, mainModule, options, {type: "main"}, function(err, id) {
if(err) {

@@ -49,2 +49,10 @@ callback(err);

}
// cleanup
delete depTree.chunkModules;
depTree.modulesByFile = depTree.modules;
depTree.modules = depTree.modulesById;
delete depTree.modulesById;
delete depTree.nextModuleId;
delete depTree.nextChunkId;
// return
callback(null, depTree);

@@ -54,3 +62,3 @@ }

function addModule(depTree, context, module, options, callback) {
function addModule(depTree, context, module, options, reason, callback) {
if(context)

@@ -66,2 +74,3 @@ resolve(context, module, options.resolve, resolved);

if(depTree.modules[filename]) {
depTree.modules[filename].reasons.push(reason);
callback(null, depTree.modules[filename].id);

@@ -71,3 +80,4 @@ } else {

id: depTree.nextModuleId++,
filename: filename
filename: filename,
reasons: [reason]
};

@@ -121,3 +131,8 @@ depTree.modulesById[module.id] = module;

requiresNames.forEach(function(moduleName) {
addModule(depTree, path.dirname(filename), moduleName, options, function(err, moduleId) {
var reason = {
type: "require",
count: requires[moduleName].length,
filename: filename
};
addModule(depTree, path.dirname(filename), moduleName, options, reason, function(err, moduleId) {
if(err) {

@@ -137,3 +152,7 @@ errors.push(err+"\n @ " + filename + " (line " + requires[moduleName][0].line + ", column " + requires[moduleName][0].column + ")");

var module = contextObj.module;
addContextModule(depTree, path.dirname(filename), context.name, options, function(err, contextModuleId) {
var reason = {
type: "ensure",
filename: filename
};
addContextModule(depTree, path.dirname(filename), context.name, options, reason, function(err, contextModuleId) {
if(err) {

@@ -169,3 +188,3 @@ errors.push(err+"\n @ " + filename + " (line " + context.line + ", column " + context.column + ")");

function addContextModule(depTree, context, contextModuleName, options, callback) {
function addContextModule(depTree, context, contextModuleName, options, reason, callback) {
resolve.context(context, contextModuleName, options.resolve, resolved);

@@ -178,2 +197,3 @@ function resolved(err, dirname) {

if(depTree.modules[dirname]) {
depTree.modules[dirname].reasons.push(reason);
callback(null, depTree.modules[dirname].id);

@@ -183,5 +203,7 @@ } else {

name: contextModuleName,
dirname: dirname,
id: depTree.nextModuleId++,
requireMap: {},
requires: []
requires: [],
reasons: [reason]
};

@@ -217,3 +239,6 @@ depTree.modulesById[contextModule.id] = contextModule;

if(stat.isDirectory()) {
doDir(filename, moduleName + "/" + file, endOne);
if(file === "node_modules" || file === "web_modules")
endOne();
else
doDir(filename, moduleName + "/" + file, endOne);
} else {

@@ -229,3 +254,7 @@ var hasExt = false;

}
addModule(depTree, null, filename, options, function(err, moduleId) {
var modulereason = {
type: "context",
filename: reason.filename
};
addModule(depTree, null, filename, options, modulereason, function(err, moduleId) {
if(err) {

@@ -255,3 +284,3 @@ endOne(err);

extensionsAccess.push("||map[name+\"");
extensionsAccess.push(ext.replace(/"/g, "\\\""));
extensionsAccess.push(ext.replace(/\\/g, "\\\\").replace(/"/g, "\\\""));
extensionsAccess.push("\"]");

@@ -258,0 +287,0 @@ });

@@ -121,4 +121,9 @@ /*

for(var moduleId in chunk.modules) {
var modu = depTree.modules[moduleId];
if(chunk.modules[moduleId] === "include")
modulesArray.push({id: moduleId, filename: depTree.modulesById[moduleId].filename});
modulesArray.push({
id: moduleId,
filename: depTree.modules[moduleId].filename,
dirname: depTree.modules[moduleId].dirname,
reasons: modu.reasons});
}

@@ -129,3 +134,3 @@ fileModulesMap[path.basename(filename)] = modulesArray;

buffer.chunkCount = chunksCount;
buffer.modulesCount = Object.keys(depTree.modulesById).length;
buffer.modulesCount = Object.keys(depTree.modules).length;
var sum = 0;

@@ -132,0 +137,0 @@ for(var chunkId in depTree.chunks) {

@@ -13,3 +13,3 @@ /*

var buffer = [];
var modules = chunk ? chunk.modules : depTree.modulesById;
var modules = chunk ? chunk.modules : depTree.modules;
for(var moduleId in modules) {

@@ -20,3 +20,3 @@ if(chunk) {

}
var module = depTree.modulesById[moduleId];
var module = depTree.modules[moduleId];
buffer.push("/******/");

@@ -23,0 +23,0 @@ buffer.push(moduleId);

{
"name": "webpack",
"version": "0.2.0",
"version": "0.2.1",
"author": "Tobias Koppers @sokra",

@@ -9,3 +9,4 @@ "description": "Packs CommonJs Modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand.",

"optimist": "0.2.x",
"uglify-js": "1.2.5"
"uglify-js": "1.2.5",
"sprintf": "0.1.x"
},

@@ -12,0 +13,0 @@ "licenses": [

@@ -17,6 +17,6 @@ /*

"all modules loaded": function(depTree) {
assert.notEqual(depTree.modules[path.join(__dirname, "fixtures", "main1.js")], null);
assert.notEqual(depTree.modules[path.join(__dirname, "fixtures", "a.js")], null);
assert.notEqual(depTree.modules[path.join(__dirname, "fixtures", "b.js")], null);
assert.notEqual(depTree.modules[path.join(__dirname, "fixtures", "node_modules", "m1", "a.js")], null);
assert.notEqual(depTree.modulesByFile[path.join(__dirname, "fixtures", "main1.js")], null);
assert.notEqual(depTree.modulesByFile[path.join(__dirname, "fixtures", "a.js")], null);
assert.notEqual(depTree.modulesByFile[path.join(__dirname, "fixtures", "b.js")], null);
assert.notEqual(depTree.modulesByFile[path.join(__dirname, "fixtures", "node_modules", "m1", "a.js")], null);
},

@@ -38,7 +38,7 @@

"all modules loaded": function(depTree) {
assert.notEqual(depTree.modules[path.join(__dirname, "fixtures", "main2.js")], null);
assert.notEqual(depTree.modules[path.join(__dirname, "fixtures", "a.js")], null);
assert.notEqual(depTree.modules[path.join(__dirname, "fixtures", "b.js")], null);
assert.notEqual(depTree.modules[path.join(__dirname, "fixtures", "node_modules", "m1", "a.js")], null);
assert.notEqual(depTree.modules[path.join(__dirname, "fixtures", "node_modules", "m1", "b.js")], null);
assert.notEqual(depTree.modulesByFile[path.join(__dirname, "fixtures", "main2.js")], null);
assert.notEqual(depTree.modulesByFile[path.join(__dirname, "fixtures", "a.js")], null);
assert.notEqual(depTree.modulesByFile[path.join(__dirname, "fixtures", "b.js")], null);
assert.notEqual(depTree.modulesByFile[path.join(__dirname, "fixtures", "node_modules", "m1", "a.js")], null);
assert.notEqual(depTree.modulesByFile[path.join(__dirname, "fixtures", "node_modules", "m1", "b.js")], null);
},

@@ -48,7 +48,7 @@

assert.deepEqual(Object.keys(depTree.chunks), ["0", "1"]);
assert.deepEqual(depTree.modules[path.join(__dirname, "fixtures", "main2.js")].chunks, [0]);
assert.deepEqual(depTree.modules[path.join(__dirname, "fixtures", "a.js")].chunks, [0]);
assert.deepEqual(depTree.modules[path.join(__dirname, "fixtures", "b.js")].chunks, [0]);
assert.deepEqual(depTree.modules[path.join(__dirname, "fixtures", "node_modules", "m1", "a.js")].chunks, [1]);
assert.deepEqual(depTree.modules[path.join(__dirname, "fixtures", "node_modules", "m1", "b.js")].chunks, [1]);
assert.deepEqual(depTree.modulesByFile[path.join(__dirname, "fixtures", "main2.js")].chunks, [0]);
assert.deepEqual(depTree.modulesByFile[path.join(__dirname, "fixtures", "a.js")].chunks, [0]);
assert.deepEqual(depTree.modulesByFile[path.join(__dirname, "fixtures", "b.js")].chunks, [0]);
assert.deepEqual(depTree.modulesByFile[path.join(__dirname, "fixtures", "node_modules", "m1", "a.js")].chunks, [1]);
assert.deepEqual(depTree.modulesByFile[path.join(__dirname, "fixtures", "node_modules", "m1", "b.js")].chunks, [1]);
}

@@ -63,5 +63,5 @@ },

"all modules loaded": function(depTree) {
assert.notEqual(depTree.modules[path.join(__dirname, "fixtures", "main3.js")], null);
assert.notEqual(depTree.modules[path.join(__dirname, "fixtures", "a.js")], null);
assert.notEqual(depTree.modules[path.join(__dirname, "fixtures", "c.js")], null);
assert.notEqual(depTree.modulesByFile[path.join(__dirname, "fixtures", "main3.js")], null);
assert.notEqual(depTree.modulesByFile[path.join(__dirname, "fixtures", "a.js")], null);
assert.notEqual(depTree.modulesByFile[path.join(__dirname, "fixtures", "c.js")], null);
},

@@ -71,8 +71,8 @@

assert.deepEqual(Object.keys(depTree.chunks), ["0", "1"]);
assert.deepEqual(depTree.modules[path.join(__dirname, "fixtures", "main3.js")].chunks, [0]);
assert.deepEqual(depTree.modules[path.join(__dirname, "fixtures", "a.js")].chunks, [0, 1]);
assert.deepEqual(depTree.modules[path.join(__dirname, "fixtures", "c.js")].chunks, [1]);
var main3id = ""+depTree.modules[path.join(__dirname, "fixtures", "main3.js")].id;
var aid = ""+depTree.modules[path.join(__dirname, "fixtures", "a.js")].id;
var cid = ""+depTree.modules[path.join(__dirname, "fixtures", "c.js")].id;
assert.deepEqual(depTree.modulesByFile[path.join(__dirname, "fixtures", "main3.js")].chunks, [0]);
assert.deepEqual(depTree.modulesByFile[path.join(__dirname, "fixtures", "a.js")].chunks, [0, 1]);
assert.deepEqual(depTree.modulesByFile[path.join(__dirname, "fixtures", "c.js")].chunks, [1]);
var main3id = ""+depTree.modulesByFile[path.join(__dirname, "fixtures", "main3.js")].id;
var aid = ""+depTree.modulesByFile[path.join(__dirname, "fixtures", "a.js")].id;
var cid = ""+depTree.modulesByFile[path.join(__dirname, "fixtures", "c.js")].id;
assert.deepEqual(Object.keys(depTree.chunks[0].modules), [main3id, aid]);

@@ -79,0 +79,0 @@ assert.deepEqual(Object.keys(depTree.chunks[1].modules), [cid, aid]);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc