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.3.7 to 0.3.8

12

bin/webpack.js

@@ -128,5 +128,2 @@ #!/usr/bin/env node

if(!options.outputPostfix) options.outputPostfix = "." + path.basename(output);
var outExists = path.existsSync(options.outputDirectory);
if(!outExists)
fs.mkdirSync(options.outputDirectory);
webpack(input, options, function(err, stats) {

@@ -143,2 +140,3 @@ if(err) {

}
console.log("Hash: "+c("\033[1m") + stats.hash + c("\033[22m"));
console.log("Chunks: "+c("\033[1m") + stats.chunkCount + c("\033[22m"));

@@ -150,5 +148,5 @@ console.log("Modules: "+c("\033[1m") + stats.modulesCount + c("\033[22m"));

if(stats.fileSizes)
for(var file in stats.fileSizes) {
Object.keys(stats.fileSizes).reverse().forEach(function(file) {
console.log(c("\033[1m") + sprintf("%" + (5 + options.output.length) + "s", file) + c("\033[22m")+": "+c("\033[1m") + sprintf("%8d", stats.fileSizes[file]) + c("\033[22m") + " characters");
};
});
var cwd = process.cwd();

@@ -180,3 +178,3 @@ var cwdParent = path.dirname(cwd);

console.log(" <reason> from <filename>");
for(var file in stats.fileModules) {
Object.keys(stats.fileModules).reverse().forEach(function(file) {
console.log(c("\033[1m\033[32m") + file + c("\033[39m\033[22m"));

@@ -214,3 +212,3 @@ var modules = stats.fileModules[file];

});
}
});
}

@@ -217,0 +215,0 @@ if(stats.warnings) {

@@ -10,2 +10,4 @@ /*

var HASH_REGEXP = /\[hash\]/i;
var templateAsync = require("fs").readFileSync(path.join(__dirname, "templateAsync.js"));

@@ -112,12 +114,38 @@ var templateSingle = require("fs").readFileSync(path.join(__dirname, "templateSingle.js"));

var fileModulesMap = {};
var fileWrites = [];
var chunksCount = 0;
for(var chunkId in depTree.chunks) {
var chunkIds = Object.keys(depTree.chunks);
chunkIds.sort(function(a,b) {
return parseInt(b, 10) - parseInt(a, 10);
});
var hash;
try {
hash = new (require("crypto").Hash)("md5");
hash.update(JSON.stringify(options.libary || ""));
hash.update(JSON.stringify(options.outputPostfix));
hash.update(JSON.stringify(options.outputJsonpFunction));
hash.update(JSON.stringify(options.scriptSrcPrefix));
hash.update(templateAsync);
hash.update(templateSingle);
hash.update("1");
} catch(e) {
callback(e);
return;
hash = null;
}
chunkIds.forEach(function(chunkId) {
var chunk = depTree.chunks[chunkId];
if(chunk.empty) continue;
if(chunk.equals !== undefined) continue;
if(chunk.empty) return;
if(chunk.equals !== undefined) return;
chunksCount++;
var filename = path.join(options.outputDirectory,
chunk.id === 0 ? options.output : chunk.id + options.outputPostfix);
var content = writeChunk(depTree, chunk, options);
if(hash) hash.update(content);
buffer = [];
if(chunk.id === 0) {
if(hash)
hash = hash.digest("hex");
else
hash = "";
if(options.libary) {

@@ -128,10 +156,10 @@ buffer.push("/******/var ");

}
if(Object.keys(depTree.chunks).length > 1) {
if(chunkIds.length > 1) {
buffer.push(templateAsync);
buffer.push("/******/({a:");
buffer.push(JSON.stringify(options.outputPostfix));
buffer.push(JSON.stringify(options.outputPostfix.replace(HASH_REGEXP, hash)));
buffer.push(",b:");
buffer.push(JSON.stringify(options.outputJsonpFunction));
buffer.push(",c:");
buffer.push(JSON.stringify(options.scriptSrcPrefix));
buffer.push(JSON.stringify(options.scriptSrcPrefix.replace(HASH_REGEXP, hash)));
buffer.push(",\n");

@@ -149,3 +177,3 @@ } else {

}
buffer.push(writeChunk(depTree, chunk, options));
buffer.push(content);
buffer.push("/******/})");

@@ -159,5 +187,3 @@ buffer = buffer.join("");

}
fs.writeFile(filename, buffer, "utf-8", function(err) {
if(err) throw err;
});
fileWrites.push([filename, buffer]);
fileSizeMap[path.basename(filename)] = buffer.length;

@@ -180,26 +206,71 @@ var modulesArray = [];

fileModulesMap[path.basename(filename)] = modulesArray;
});
// write files
var remFiles = fileWrites.length;
var outDir = options.outputDirectory.replace(HASH_REGEXP, hash);
function createDir(dir, callback) {
path.exists(dir, function(exists) {
if(exists)
callback();
else {
fs.mkdir(dir, function(err) {
if(err) {
var parentDir = path.join(dir, "..");
if(parentDir == dir)
return callback(err);
createDir(parentDir, function(err) {
if(err) return callback(err);
fs.mkdir(dir, function(err) {
if(err) return callback(err);
callback();
});
});
return;
}
callback();
});
}
});
}
buffer = {};
buffer.chunkCount = chunksCount;
buffer.modulesCount = Object.keys(depTree.modules).length;
var sum = 0;
for(var chunkId in depTree.chunks) {
for(var moduleId in depTree.chunks[chunkId].modules) {
if(depTree.chunks[chunkId].modules[moduleId] === "include")
createDir(outDir, function(err) {
if(err) return callback(err);
writeFiles();
});
function writeFiles() {
fileWrites.forEach(function(writeAction) {
fs.writeFile(writeAction[0].replace(HASH_REGEXP, hash), writeAction[1], "utf-8", function(err) {
if(err) throw err;
remFiles--;
if(remFiles === 0)
writingFinished();
});
});
}
function writingFinished() {
// Stats
buffer = {};
buffer.hash = hash;
buffer.chunkCount = chunksCount;
buffer.modulesCount = Object.keys(depTree.modules).length;
var sum = 0;
for(var chunkId in depTree.chunks) {
for(var moduleId in depTree.chunks[chunkId].modules) {
if(depTree.chunks[chunkId].modules[moduleId] === "include")
sum++;
}
}
buffer.modulesIncludingDuplicates = sum;
buffer.modulesPerChunk = Math.round(sum / chunksCount*10)/10;
sum = 0;
for(var moduleId in depTree.chunks[0].modules) {
if(depTree.chunks[0].modules[moduleId] === "include")
sum++;
}
buffer.modulesFirstChunk = sum;
buffer.fileSizes = fileSizeMap;
buffer.warnings = depTree.warnings;
buffer.errors = depTree.errors;
buffer.fileModules = fileModulesMap;
callback(null, buffer);
}
buffer.modulesIncludingDuplicates = sum;
buffer.modulesPerChunk = Math.round(sum / chunksCount*10)/10;
sum = 0;
for(var moduleId in depTree.chunks[0].modules) {
if(depTree.chunks[0].modules[moduleId] === "include")
sum++;
}
buffer.modulesFirstChunk = sum;
buffer.fileSizes = fileSizeMap;
buffer.warnings = depTree.warnings;
buffer.errors = depTree.errors;
buffer.fileModules = fileModulesMap;
callback(null, buffer);
} else {

@@ -206,0 +277,0 @@ if(options.libary) {

{
"name": "webpack",
"version": "0.3.7",
"version": "0.3.8",
"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.",

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