Socket
Socket
Sign inDemoInstall

webpack

Package Overview
Dependencies
Maintainers
1
Versions
837
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.5.10 to 0.6.0

README.md

2

api/getPublicPrefix.js

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

*/
module.exports = "(require.valueOf().modules.c||'')";
module.exports = "(require.modules.c||'')";

@@ -34,3 +34,2 @@ #!/usr/bin/env node

.string("public-prefix")
.alias("public-prefix", "script-src-prefix")
.describe("public-prefix", "Path Prefix For JavaScript Loading")

@@ -37,0 +36,0 @@

var amdRequire = require("./__webpack_amd_require");
module.exports = function(module, req) {
req = amdRequire(req);
function define(name, requires, fn) {
if(!fn) {
fn = requires;
requires = name;
module.exports = function(module) {
function define(id, dependencies, factory) {
if(typeof id != "number") {
factory = dependencies;
dependencies = id;
id = null;
}
if(!fn) {
return module.exports = name.call(module.exports, req);
if(!factory) {
factory = dependencies;
dependencies = [amdRequire, module.exports, module];
}
return module.exports = fn.apply(module.exports, requires);
var result = typeof factory == "function" ? factory.apply(null, dependencies) : factory;
if(result !== undefined)
module.exports = result;
return module.exports;
}

@@ -14,0 +18,0 @@ define.amd = amdRequire.amd;

@@ -1,20 +0,17 @@

function amdRequireFactory(req) {
function amdRequire(chunk, requiresFn, fn) {
if(!requiresFn) {
// commonjs
return req(chunk);
}
req.e(chunk, function() {
var modules = requiresFn();
if(fn)
return fn.apply(null, modules);
});
var req = require.valueOf();
function amdRequire(chunk, requiresFn, fn) {
if(!requiresFn) {
// commonjs
return req(chunk);
}
for(var name in req)
amdRequire[name] = req[name];
amdRequire.amd = amdRequireFactory.amd;
amdRequire.config = function() {/* config is ignored, use webpack options */};
return amdRequire;
req.e(chunk, function() {
var modules = requiresFn();
if(fn)
return fn.apply(null, modules);
});
}
amdRequireFactory.amd = {};
module.exports = amdRequireFactory;
for(var name in req)
amdRequire[name] = req[name];
amdRequire.amd = {};
amdRequire.config = function() {/* config is ignored, use webpack options */};
module.exports = amdRequire;
module.exports = function(module) {
if(!module.webpackPolyfill) {
module.deprecate = function() {};
module.id = "webpack";
module.paths = [];
// module.parent = undefined by default
module.children = [];
module.webpackPolyfill = 1;

@@ -6,0 +8,0 @@ }

@@ -42,3 +42,5 @@ exports = module.exports = new (require("events").EventEmitter);

exports.cwd = function() {
return "/app";
var pathname = (window.location.pathname+"").split("/");
pathname.pop();
return pathname.join("/");
}

@@ -45,0 +47,0 @@ exports.exit = exports.kill =

@@ -52,2 +52,4 @@ // http://wiki.commonjs.org/wiki/Unit_Testing/1.0

};
// assert.AssertionError instanceof Error
util.inherits(assert.AssertionError, Error);

@@ -89,6 +91,2 @@

// assert.AssertionError instanceof Error
assert.AssertionError.__proto__ = Error.prototype;
// At present only the three keys mentioned above are used and

@@ -313,7 +311,7 @@ // understood by the spec. Implementations or sub modules can pass

if (shouldThrow && !actual) {
fail('Missing expected exception' + message);
fail(actual, expected, 'Missing expected exception' + message);
}
if (!shouldThrow && expectedException(actual, expected)) {
fail('Got unwanted exception' + message);
fail(actual, expected, 'Got unwanted exception' + message);
}

@@ -320,0 +318,0 @@

@@ -97,4 +97,2 @@ // Copyright Joyent, Inc. and other Node contributors.

// EventEmitter is defined in src/node_events.cc
// EventEmitter.prototype.emit() is also defined there.
EventEmitter.prototype.addListener = function(type, listener) {

@@ -190,2 +188,4 @@ if ('function' !== typeof listener) {

list.splice(position, 1);
if (list.length == 0)
delete this._events[type];
} else if (list === listener ||

@@ -206,11 +206,4 @@ (list.listener && list.listener === listener))

var events = this._events && this._events[type];
if (!events) return this;
if (isArray(events)) {
events.splice(0);
} else {
this._events[type] = null;
}
// does not use listeners(), so no side effect of creating _events[type]
if (type && this._events && this._events[type]) this._events[type] = null;
return this;

@@ -217,0 +210,0 @@ };

@@ -23,4 +23,3 @@ // Copyright Joyent, Inc. and other Node contributors.

var isWindows = process.platform === 'win32';
var _deprecationWarning = require('util')._deprecationWarning;
var util = require('util');

@@ -59,208 +58,2 @@

if (isWindows) {
// Regex to split a windows path into three parts: [*, device, slash,
// tail] windows-only
var splitDeviceRe =
/^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?([\\\/])?([\s\S]*?)$/;
// Regex to split the tail part of the above into [*, dir, basename, ext]
var splitTailRe =
/^([\s\S]+[\\\/](?!$)|[\\\/])?((?:\.{1,2}$|[\s\S]+?)?(\.[^.\/\\]*)?)$/;
// Function to split a filename into [root, dir, basename, ext]
// windows version
var splitPath = function(filename) {
// Separate device+slash from tail
var result = splitDeviceRe.exec(filename),
device = (result[1] || '') + (result[2] || ''),
tail = result[3] || '';
// Split the tail into dir, basename and extension
var result2 = splitTailRe.exec(tail),
dir = result2[1] || '',
basename = result2[2] || '',
ext = result2[3] || '';
return [device, dir, basename, ext];
};
// path.resolve([from ...], to)
// windows version
exports.resolve = function() {
var resolvedDevice = '',
resolvedTail = '',
resolvedAbsolute = false;
for (var i = arguments.length - 1; i >= -1; i--) {
var path;
if (i >= 0) {
path = arguments[i];
} else if (!resolvedDevice) {
path = process.cwd();
} else {
// Windows has the concept of drive-specific current working
// directories. If we've resolved a drive letter but not yet an
// absolute path, get cwd for that drive. We're sure the device is not
// an unc path at this points, because unc paths are always absolute.
path = process.env['=' + resolvedDevice];
// Verify that a drive-local cwd was found and that it actually points
// to our drive. If not, default to the drive's root.
if (!path || path.slice(0, 3).toLowerCase() !==
resolvedDevice.toLowerCase() + '\\') {
path = resolvedDevice + '\\';
}
}
// Skip empty and invalid entries
if (typeof path !== 'string' || !path) {
continue;
}
var result = splitDeviceRe.exec(path),
device = result[1] || '',
isUnc = device && device.charAt(1) !== ':',
isAbsolute = !!result[2] || isUnc, // UNC paths are always absolute
tail = result[3];
if (device &&
resolvedDevice &&
device.toLowerCase() !== resolvedDevice.toLowerCase()) {
// This path points to another device so it is not applicable
continue;
}
if (!resolvedDevice) {
resolvedDevice = device;
}
if (!resolvedAbsolute) {
resolvedTail = tail + '\\' + resolvedTail;
resolvedAbsolute = isAbsolute;
}
if (resolvedDevice && resolvedAbsolute) {
break;
}
}
// Replace slashes (in UNC share name) by backslashes
resolvedDevice = resolvedDevice.replace(/\//g, '\\');
// At this point the path should be resolved to a full absolute path,
// but handle relative paths to be safe (might happen when process.cwd()
// fails)
// Normalize the tail path
function f(p) {
return !!p;
}
resolvedTail = normalizeArray(resolvedTail.split(/[\\\/]+/).filter(f),
!resolvedAbsolute).join('\\');
return (resolvedDevice + (resolvedAbsolute ? '\\' : '') + resolvedTail) ||
'.';
};
// windows version
exports.normalize = function(path) {
var result = splitDeviceRe.exec(path),
device = result[1] || '',
isUnc = device && device.charAt(1) !== ':',
isAbsolute = !!result[2] || isUnc, // UNC paths are always absolute
tail = result[3],
trailingSlash = /[\\\/]$/.test(tail);
// Normalize the tail path
tail = normalizeArray(tail.split(/[\\\/]+/).filter(function(p) {
return !!p;
}), !isAbsolute).join('\\');
if (!tail && !isAbsolute) {
tail = '.';
}
if (tail && trailingSlash) {
tail += '\\';
}
return device + (isAbsolute ? '\\' : '') + tail;
};
// windows version
exports.join = function() {
function f(p) {
return p && typeof p === 'string';
}
var paths = Array.prototype.slice.call(arguments, 0).filter(f);
var joined = paths.join('\\');
// Make sure that the joined path doesn't start with two slashes
// - it will be mistaken for an unc path by normalize() -
// unless the paths[0] also starts with two slashes
if (/^[\\\/]{2}/.test(joined) && !/^[\\\/]{2}/.test(paths[0])) {
joined = joined.slice(1);
}
return exports.normalize(joined);
};
// path.relative(from, to)
// it will solve the relative path from 'from' to 'to', for instance:
// from = 'C:\\orandea\\test\\aaa'
// to = 'C:\\orandea\\impl\\bbb'
// The output of the function should be: '..\\..\\impl\\bbb'
// windows version
exports.relative = function(from, to) {
from = exports.resolve(from);
to = exports.resolve(to);
// windows is not case sensitive
var lowerFrom = from.toLowerCase();
var lowerTo = to.toLowerCase();
function trim(arr) {
var start = 0;
for (; start < arr.length; start++) {
if (arr[start] !== '') break;
}
var end = arr.length - 1;
for (; end >= 0; end--) {
if (arr[end] !== '') break;
}
if (start > end) return [];
return arr.slice(start, end - start + 1);
}
var toParts = trim(to.split('\\'));
var lowerFromParts = trim(lowerFrom.split('\\'));
var lowerToParts = trim(lowerTo.split('\\'));
var length = Math.min(lowerFromParts.length, lowerToParts.length);
var samePartsLength = length;
for (var i = 0; i < length; i++) {
if (lowerFromParts[i] !== lowerToParts[i]) {
samePartsLength = i;
break;
}
}
if (samePartsLength == 0) {
return to;
}
var outputParts = [];
for (var i = samePartsLength; i < lowerFromParts.length; i++) {
outputParts.push('..');
}
outputParts = outputParts.concat(toParts.slice(samePartsLength));
return outputParts.join('\\');
};
} else /* posix */ {
// Split a filename into [root, dir, basename, ext], unix version

@@ -378,5 +171,4 @@ // 'root' is just a slash, or nothing.

}
exports.sep = '/';
exports.dirname = function(path) {

@@ -416,39 +208,14 @@ var result = splitPath(path),

/*
exports.exists = function(path, callback) {
exports.exists = util.deprecate(function(path, callback) {
require('fs').exists(path, callback);
};
module.deprecate('exists', 'It is now called `fs.exists`.');
}, 'path.exists is now called `fs.exists`.');
exports.existsSync = function(path) {
exports.existsSync = util.deprecate(function(path) {
return require('fs').existsSync(path);
};
module.deprecate('existsSync', 'It is now called `fs.existsSync`.');
}, 'path.existsSync is now called `fs.existsSync`.');
*/
if (isWindows) {
exports._makeLong = function(path) {
path = '' + path;
if (!path) {
return '';
}
var resolvedPath = exports.resolve(path);
if (resolvedPath.match(/^[a-zA-Z]\:\\/)) {
// path is local filesystem path, which needs to be converted
// to long UNC path.
return '\\\\?\\' + resolvedPath;
} else if (resolvedPath.match(/^\\\\[^?.]/)) {
// path is network UNC path, which needs to be converted
// to long UNC path.
return '\\\\?\\UNC\\' + resolvedPath.substring(2);
}
return path;
};
} else {
exports._makeLong = function(path) {
return path;
};
}

@@ -69,25 +69,23 @@ // Copyright Joyent, Inc. and other Node contributors.

eq = eq || '=';
obj = (obj === null) ? undefined : obj;
if (obj === null) {
obj = undefined;
}
switch (typeof obj) {
case 'object':
return Object.keys(obj).map(function(k) {
if (Array.isArray(obj[k])) {
return obj[k].map(function(v) {
return QueryString.escape(stringifyPrimitive(k)) +
eq +
QueryString.escape(stringifyPrimitive(v));
}).join(sep);
} else {
return QueryString.escape(stringifyPrimitive(k)) +
eq +
QueryString.escape(stringifyPrimitive(obj[k]));
}
}).join(sep);
if (typeof obj === 'object') {
return Object.keys(obj).map(function(k) {
var ks = QueryString.escape(stringifyPrimitive(k)) + eq;
if (Array.isArray(obj[k])) {
return obj[k].map(function(v) {
return ks + QueryString.escape(stringifyPrimitive(v));
}).join(sep);
} else {
return ks + QueryString.escape(stringifyPrimitive(obj[k]));
}
}).join(sep);
default:
if (!name) return '';
return QueryString.escape(stringifyPrimitive(name)) + eq +
QueryString.escape(stringifyPrimitive(obj));
}
if (!name) return '';
return QueryString.escape(stringifyPrimitive(name)) + eq +
QueryString.escape(stringifyPrimitive(obj));
};

@@ -99,10 +97,4 @@

eq = eq || '=';
var obj = {},
maxKeys = 1000;
var obj = {};
// Handle maxKeys = 0 case
if (options && typeof options.maxKeys === 'number') {
maxKeys = options.maxKeys;
}
if (typeof qs !== 'string' || qs.length === 0) {

@@ -115,13 +107,26 @@ return obj;

var maxKeys = 1000;
if (options && typeof options.maxKeys === 'number') {
maxKeys = options.maxKeys;
}
var len = qs.length;
// maxKeys <= 0 means that we should not limit keys count
if (maxKeys > 0) {
qs = qs.slice(0, maxKeys);
if (maxKeys > 0 && len > maxKeys) {
len = maxKeys;
}
for (var i = 0, len = qs.length; i < len; ++i) {
for (var i = 0; i < len; ++i) {
var x = qs[i].replace(regexp, '%20'),
idx = x.indexOf(eq),
kstr = x.substring(0, idx),
vstr = x.substring(idx + 1), k, v;
kstr, vstr, k, v;
if (idx >= 0) {
kstr = x.substr(0, idx);
vstr = x.substr(idx + 1);
} else {
kstr = x;
vstr = '';
}
try {

@@ -137,6 +142,6 @@ k = decodeURIComponent(kstr);

obj[k] = v;
} else if (!Array.isArray(obj[k])) {
} else if (Array.isArray(obj[k])) {
obj[k].push(v);
} else {
obj[k] = [obj[k], v];
} else {
obj[k].push(v);
}

@@ -143,0 +148,0 @@ }

@@ -35,8 +35,12 @@ // Copyright Joyent, Inc. and other Node contributors.

portPattern = /:[0-9]*$/,
// RFC 2396: characters reserved for delimiting URLs.
// We actually just auto-escape these.
delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t'],
// RFC 2396: characters not allowed for various reasons.
unwise = ['{', '}', '|', '\\', '^', '~', '`'].concat(delims),
// Allowed by RFCs, but cause of XSS attacks. Always escape these.
autoEscape = ['\''],
autoEscape = ['\''].concat(delims),
// Characters that are never ever allowed in a hostname.

@@ -99,10 +103,6 @@ // Note that any invalid chars are also handled, but these

// cut off any delimiters.
// This is to support parse stuff like "<http://foo.com>"
for (var i = 0, l = rest.length; i < l; i++) {
if (delims.indexOf(rest.charAt(i)) === -1) break;
}
if (i !== 0) rest = rest.substr(i);
// trim before proceeding.
// This is to support parse stuff like " http://foo.com \n"
rest = rest.trim();
var proto = protocolPattern.exec(rest);

@@ -276,12 +276,2 @@ if (proto) {

}
// Now make sure that delims never appear in a url.
var chop = rest.length;
for (var i = 0, l = delims.length; i < l; i++) {
var c = rest.indexOf(delims[i]);
if (c !== -1) {
chop = Math.min(c, chop);
}
}
rest = rest.substr(0, chop);
}

@@ -288,0 +278,0 @@

@@ -57,2 +57,27 @@ // Copyright Joyent, Inc. and other Node contributors.

// Mark that a method should not be used.
// Returns a modified function which warns once by default.
// If --no-deprecation is set, then it is a no-op.
exports.deprecate = function(fn, msg) {
if (process.noDeprecation === true) {
return fn;
}
var warned = false;
function deprecated() {
if (!warned) {
if (process.traceDeprecation) {
console.trace(msg);
} else {
console.error(msg);
}
warned = true;
}
return fn.apply(this, arguments);
}
return deprecated;
};
exports.print = function() {

@@ -141,4 +166,4 @@ for (var i = 0, len = arguments.length; i < len; ++i) {

if (style) {
return '\033[' + colors[style][0] + 'm' + str +
'\033[' + colors[style][1] + 'm';
return '\u001b[' + colors[style][0] + 'm' + str +
'\u001b[' + colors[style][1] + 'm';
} else {

@@ -155,2 +180,13 @@ return str;

function arrayToHash(array) {
var hash = {};
array.forEach(function(val, idx) {
hash[val] = true;
});
return hash;
}
function formatValue(ctx, value, recurseTimes) {

@@ -164,3 +200,3 @@ // Provide a hook for user-specified inspect functions.

!(value.constructor && value.constructor.prototype === value)) {
return value.inspect(recurseTimes);
return String(value.inspect(recurseTimes));
}

@@ -175,5 +211,9 @@

// Look up the keys of the object.
var visibleKeys = Object.keys(value);
var keys = ctx.showHidden ? Object.getOwnPropertyNames(value) : visibleKeys;
var keys = Object.keys(value);
var visibleKeys = arrayToHash(keys);
if (ctx.showHidden) {
keys = Object.getOwnPropertyNames(value);
}
// Some type of object without properties can be shortcutted.

@@ -317,3 +357,3 @@ if (keys.length === 0) {

}
if (visibleKeys.indexOf(key) < 0) {
if (!visibleKeys.hasOwnProperty(key)) {
name = '[' + key + ']';

@@ -416,8 +456,7 @@ }

exports.p = function() {
exports.p = exports.deprecate(function() {
for (var i = 0, len = arguments.length; i < len; ++i) {
error(exports.inspect(arguments[i]));
}
};
module.deprecate('p', 'Use `util.puts(util.inspect())` instead.');
}, 'util.p: Use console.error() instead.');

@@ -448,6 +487,5 @@

exports.exec = function() {
exports.exec = exports.deprecate(function() {
return require('child_process').exec.apply(this, arguments);
};
module.deprecate('exec', 'It is now called `child_process.exec`.');
}, 'util.exec is now called `child_process.exec`.');

@@ -520,3 +558,3 @@

// Don't do anything if add isn't an object
if (!add) return origin;
if (!add || typeof add !== 'object') return origin;

@@ -523,0 +561,0 @@ var keys = Object.keys(add);

@@ -6,4 +6,4 @@ /*

var parse = require("./parse");
var resolve = require("./resolve");
var execLoaders = require("./execLoaders");
var resolve = require("enhanced-resolve");
var execLoaders = require("enhanced-require/lib/execLoaders");
var fs = require("fs");

@@ -10,0 +10,0 @@ var path = require("path");

@@ -229,2 +229,11 @@ /*

}
} else if(param.value == "require") {
// require function
context.requires = context.requires || [];
context.requires.push({
requireFunction: true,
expressionRange: elements[idx].range,
line: elements[idx].loc.start.line,
column: elements[idx].loc.start.column
});
} else {

@@ -254,3 +263,2 @@ // normal require

name: "__webpack_amd_require",
append: "(require)",
line: expression.callee.loc.start.line,

@@ -273,3 +281,2 @@ column: expression.callee.loc.start.column,

name: "__webpack_amd_require",
append: "(require)",
line: expression.callee.loc.start.line,

@@ -311,12 +318,19 @@ column: expression.callee.loc.start.column,

expression.callee.name === "define") {
var params = parseCalculatedStringArray(expression.arguments[0]);
var elements = expression.arguments[0].type == "ArrayExpression" ?
expression.arguments[0].elements : [expression.arguments[0]];
processAmdArray(params, elements);
var amdNameRange;
if(expression.arguments[0].type == "ArrayExpression") {
var params = parseCalculatedStringArray(expression.arguments[0]);
var elements = expression.arguments[0].elements;
processAmdArray(params, elements);
} else {
amdNameRange = expression.arguments[0].range;
}
context.requires = context.requires || [];
context.requires.push({
name: "__webpack_amd_define",
append: "(module,require)",
append: "(module)",
line: expression.callee.loc.start.line,
column: expression.callee.loc.start.column,
amdNameRange: amdNameRange,
label: expression.arguments[0].value,
variable: "define"

@@ -334,3 +348,3 @@ });

name: "__webpack_amd_define",
append: "(module,require)",
append: "(module)",
line: expression.callee.loc.start.line,

@@ -355,3 +369,3 @@ column: expression.callee.loc.start.column,

name: "__webpack_amd_define",
append: "(module,require)",
append: "(module)",
amdNameRange: expression.arguments[0].range,

@@ -531,3 +545,3 @@ label: expression.arguments[0].value+"",

expression.property.type === "Identifier" &&
expression.property.name === "exports")
{exports:1, id:1, loaded:1}.hasOwnProperty(expression.property.name))
break;

@@ -534,0 +548,0 @@ if(expression.object.type === "Identifier" &&

@@ -16,5 +16,3 @@ /*

webpack(context, moduleName, options, callback);
webpack(context, moduleName, callback);
webpack(absoluteModulePath, options, callback);
webpack(absoluteModulePath, callback);

@@ -71,15 +69,2 @@ callback: function(err, source / stats)

}
if(typeof moduleName === "function") {
callback = moduleName;
options = {};
context = context.split("!");
var file = context.pop();
context.push("./" + path.basename(file));
moduleName = context.join("!");
context = path.dirname(file);
}
if(!callback) {
callback = options;
options = {};
}

@@ -89,4 +74,3 @@ // Defaults

options.outputJsonpFunction = "webpackJsonp" + (options.libary || "");
options.scriptSrcPrefix = options.scriptSrcPrefix || ""; // DEPRECATED
options.publicPrefix = options.publicPrefix || options.scriptSrcPrefix
options.publicPrefix = options.publicPrefix || "";

@@ -107,3 +91,5 @@ options.context = options.context || context;

}
} // else DEPRECATED
} else {
return callback(new Error("options.output is required"));
}

@@ -133,2 +119,20 @@ options.parse = options.parse || {};

options.resolve.loaders.push({test: /\.less$/, loader: "style!css!val/cacheable!less"});
if(!options.resolve.extensions)
options.resolve.extensions = ["", ".webpack.js", ".web.js", ".js"];
if(!options.resolve.postfixes)
options.resolve.postfixes = ["", "-webpack", "-web"];
if(!options.resolve.loaderExtensions)
options.resolve.loaderExtensions = [".webpack-web-loader.js", ".webpack-loader.js", ".web-loader.js", ".loader.js", "", ".js"];
if(!options.resolve.loaderPostfixes)
options.resolve.loaderPostfixes = ["-webpack-web-loader", "-webpack-loader", "-web-loader", "-loader", ""];
if(!options.resolve.modulesDirectorys)
options.resolve.modulesDirectorys = ["web_modules", "jam", "node_modules"];
if(!options.resolve.alias)
options.resolve.alias = {};
if(!options.resolve.postprocess)
options.resolve.postprocess = {};
if(!options.resolve.postprocess.normal)
options.resolve.postprocess.normal = [];
if(!options.resolve.postprocess.context)
options.resolve.postprocess.context = [];

@@ -155,2 +159,3 @@ options.preLoaders = options.preLoaders || [];

var runAgain = false;
var staticChanges = [];

@@ -170,2 +175,7 @@ // Start the timeout again

if(staticChanges.length > 0)
return callback(new Error(
"Files (" + staticChanges.join(", ") +
") changed. Webpack cannot recompile in this watch step."));
runAgain = false;

@@ -221,2 +231,12 @@ isRunning = true;

// on before a static dependency is read
options.events.on("static-dependency", function(filename) {
if(!filename) return;
watchers.push(fs.watch(filename, function() {
if(staticChanges.indexOf(filename) == -1)
staticChanges.push(filename);
change();
}));
});
// on user defines the bundle as invalid

@@ -264,239 +284,218 @@ options.events.on("invalid", function() {

var buffer = [];
if(options.output) { // if options.output set, we write to files
// collect which module is in which file
var fileModulesMap = {};
// collect which module is in which file
var fileModulesMap = {};
// collect which chunks exists
var chunksCount = 0;
// collect which chunks exists
var chunksCount = 0;
// all ids of the chunks, in desc order
var chunkIds = Object.keys(depTree.chunks);
chunkIds.sort(function(a,b) {
if(typeof depTree.chunks[b].realId !== "number") return 1;
if(typeof depTree.chunks[a].realId !== "number") return -1;
return depTree.chunks[b].realId - depTree.chunks[a].realId;
});
// all ids of the chunks, in desc order
var chunkIds = Object.keys(depTree.chunks);
chunkIds.sort(function(a,b) {
if(typeof depTree.chunks[b].realId !== "number") return 1;
if(typeof depTree.chunks[a].realId !== "number") return -1;
return depTree.chunks[b].realId - depTree.chunks[a].realId;
});
// the template used
var template = getTemplate(options, {chunks: chunkIds.length > 1});
// the template used
var template = getTemplate(options, {chunks: chunkIds.length > 1});
// hash as crypto.Hash instance
// for compution
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.publicPrefix));
hash.update(template);
hash.update("1");
} catch(e) {
// if this didn't work
// we do not use a hash
hash = null;
}
// hash as crypto.Hash instance
// for compution
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.publicPrefix));
hash.update(template);
hash.update("1");
} catch(e) {
// if this didn't work
// we do not use a hash
hash = null;
}
// for each chunk
chunkIds.forEach(function(chunkId) {
var chunk = depTree.chunks[chunkId];
// for each chunk
for(var i = 0; i < chunkIds.length; i++) {
var chunkId = chunkIds[i];
var chunk = depTree.chunks[chunkId];
// check is chunk is empty or a duplicate
if(chunk.empty) return;
if(chunk.equals !== undefined) return;
chunksCount++;
// check is chunk is empty or a duplicate
if(chunk.empty) continue;
if(chunk.equals !== undefined) continue;
chunksCount++;
// build filename
var filename = chunk.filename = chunk.realId === 0 ? options.output : chunk.realId + options.outputPostfix;
// build filename
var filename = chunk.filename = chunk.realId === 0 ? options.output : chunk.realId + options.outputPostfix;
// get content of chunk
var content = writeChunk(depTree, chunk, options);
if(hash) hash.update(content);
buffer = [];
if(chunk.realId === 0) { // initial chunk
if(hash)
hash = hash.digest("hex");
else
hash = "";
// get content of chunk
var content = writeChunk(depTree, chunk, options);
if(hash) hash.update(content);
buffer = [];
if(chunk.realId === 0) { // initial chunk
if(hash)
hash = hash.digest("hex");
else
hash = "";
// if it should be a libary, we prepend a variable name
if(options.libary) {
buffer.push("/******/var ");
buffer.push(options.libary);
buffer.push("=\n");
}
// if it should be a libary, we prepend a variable name
if(options.libary) {
buffer.push("/******/var ");
buffer.push(options.libary);
buffer.push("=\n");
}
// write the template
buffer.push(template);
// write the template
buffer.push(template);
// write extra info into object
buffer.push("/******/({");
if(chunkIds.length > 1) {
buffer.push("a:");
buffer.push(JSON.stringify(options.outputPostfix.replace(HASH_REGEXP, hash)));
buffer.push(",b:");
buffer.push(JSON.stringify(options.outputJsonpFunction));
buffer.push(",");
}
buffer.push("c:");
buffer.push(JSON.stringify(options.publicPrefix.replace(HASH_REGEXP, hash)));
buffer.push(",\n");
} else { // lazy loaded chunk
// write only jsonp function and chunk id as function call
buffer.push("/******/");
buffer.push(options.outputJsonpFunction);
buffer.push("(");
buffer.push(chunk.realId);
buffer.push(", {\n");
// write extra info into object
buffer.push("/******/({");
if(chunkIds.length > 1) {
buffer.push("a:");
buffer.push(JSON.stringify(options.outputPostfix.replace(HASH_REGEXP, hash)));
buffer.push(",b:");
buffer.push(JSON.stringify(options.outputJsonpFunction));
buffer.push(",");
}
// write content of chunk
buffer.push(content);
buffer.push("c:");
buffer.push(JSON.stringify(options.publicPrefix.replace(HASH_REGEXP, hash)));
buffer.push(",\n");
} else { // lazy loaded chunk
// write only jsonp function and chunk id as function call
buffer.push("/******/");
buffer.push(options.outputJsonpFunction);
buffer.push("(");
buffer.push(chunk.realId);
buffer.push(", {\n");
}
// write content of chunk
buffer.push(content);
// and close object
buffer.push("/******/})");
// and close object
buffer.push("/******/})");
// convert buffer to string
buffer = buffer.join("");
// convert buffer to string
buffer = buffer.join("");
// minimize if wished
try {
if(options.minimize) buffer = uglify(buffer, path.join(options.outputDirectory, filename));
} catch(e) {
callback(e);
return;
}
// minimize if wished
try {
if(options.minimize) buffer = uglify(buffer, path.join(options.outputDirectory, filename));
} catch(e) {
return callback(e);
}
// push it as "file write"
options.emitFile(filename, buffer, true);
});
options.events.emit("task-end", "prepare chunks");
// push it as "file write"
options.emitFile(filename, buffer, true);
}
options.events.emit("task-end", "prepare chunks");
if(options.noWrite) return writingFinished();
if(options.noWrite) return writingFinished();
options.events.emit("start-writing", hash);
options.events.emit("start-writing", hash);
// recursive create dir
function createDir(dir, callback) {
fileExists(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) {
// recursive create dir
function createDir(dir, callback) {
fileExists(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);
fs.mkdir(dir, function(err) {
if(err) return callback(err);
callback();
});
callback();
});
return;
}
callback();
});
}
});
}
// create output directory
var outDir = options.outputDirectory.replace(HASH_REGEXP, hash);
createDir(outDir, function(err) {
options.events.emit("task-end", "create ouput directory");
if(err) return callback(err);
writeFiles();
});
return;
}
callback();
});
}
});
}
// collect file sizes
var fileSizeMap = {};
// create output directory
var outDir = options.outputDirectory.replace(HASH_REGEXP, hash);
createDir(outDir, function(err) {
options.events.emit("task-end", "create ouput directory");
if(err) return callback(err);
writeFiles();
});
// do the writing of all generated files
function writeFiles() {
var remFiles = fileWrites.length;
fileWrites.forEach(function(writeAction) {
var writeActionFileName = writeAction[0].replace(HASH_REGEXP, hash)
options.events.emit("task", "write " + writeActionFileName);
fileSizeMap[path.basename(writeActionFileName)] = writeAction[1].length;
fs.writeFile(writeActionFileName, writeAction[1], "utf-8", function(err) {
options.events.emit("task-end", "write " + writeActionFileName);
if(err) throw err;
remFiles--;
if(remFiles === 0)
writingFinished();
});
// collect file sizes
var fileSizeMap = {};
// do the writing of all generated files
function writeFiles() {
var remFiles = fileWrites.length;
fileWrites.forEach(function(writeAction) {
var writeActionFileName = writeAction[0].replace(HASH_REGEXP, hash)
options.events.emit("task", "write " + writeActionFileName);
fileSizeMap[path.basename(writeActionFileName)] = writeAction[1].length;
fs.writeFile(writeActionFileName, writeAction[1], "utf-8", function(err) {
options.events.emit("task-end", "write " + writeActionFileName);
if(err) throw err;
remFiles--;
if(remFiles === 0)
writingFinished();
});
if(fileWrites.length == 0) writingFinished();
}
});
if(fileWrites.length == 0) writingFinished();
}
// after writing: generate statistics
function writingFinished() {
// Stats
buffer = {};
buffer.hash = hash;
buffer.chunkCount = chunksCount;
buffer.modulesCount = Object.keys(depTree.modules).length;
var sum = 0;
chunkIds.reverse().forEach(function(chunkId) {
var chunk = depTree.chunks[chunkId]
if(!chunk.filename) return;
var modulesArray = [];
for(var moduleId in chunk.modules) {
if(chunk.modules[moduleId] === "include") {
var modu = depTree.modules[moduleId];
modulesArray.push({
id: modu.realId,
size: modu.size,
filename: modu.filename,
dirname: modu.dirname,
fromCache: modu.fromCache,
toCache: modu.toCache,
reasons: modu.reasons});
sum++;
}
// after writing: generate statistics
function writingFinished() {
// Stats
buffer = {};
buffer.hash = hash;
buffer.chunkCount = chunksCount;
buffer.modulesCount = Object.keys(depTree.modules).length;
var sum = 0;
chunkIds.reverse().forEach(function(chunkId) {
var chunk = depTree.chunks[chunkId]
if(!chunk.filename) return;
var modulesArray = [];
for(var moduleId in chunk.modules) {
if(chunk.modules[moduleId] === "include") {
var modu = depTree.modules[moduleId];
modulesArray.push({
id: modu.realId,
size: modu.size,
filename: modu.filename,
dirname: modu.dirname,
fromCache: modu.fromCache,
toCache: modu.toCache,
reasons: modu.reasons});
sum++;
}
modulesArray.sort(function(a, b) {
return a.id - b.id;
});
fileModulesMap[path.basename(chunk.filename)] = modulesArray;
}
modulesArray.sort(function(a, b) {
return a.id - b.id;
});
buffer.modulesIncludingDuplicates = sum;
buffer.modulesPerChunk = Math.round(sum / chunksCount*10)/10; // DEPRECATED: useless info
sum = 0;
for(var moduleId in depTree.chunks.main.modules) {
if(depTree.chunks.main.modules[moduleId] === "include")
sum++;
}
buffer.modulesFirstChunk = sum;
buffer.fileSizes = fileSizeMap;
buffer.warnings = depTree.warnings;
buffer.errors = depTree.errors;
buffer.fileModules = fileModulesMap;
buffer.subStats = subStats;
buffer.time = new Date() - startTime;
options.events.emit("task-end", "statistics");
options.events.emit("bundle", buffer);
callback(null, buffer);
fileModulesMap[path.basename(chunk.filename)] = modulesArray;
});
buffer.modulesIncludingDuplicates = sum;
buffer.modulesPerChunk = Math.round(sum / chunksCount*10)/10; // DEPRECATED: useless info
sum = 0;
for(var moduleId in depTree.chunks.main.modules) {
if(depTree.chunks.main.modules[moduleId] === "include")
sum++;
}
} else { // if options.output not set, we write to stdout
// THIS IS DEPRECATED
if(options.libary) {
buffer.push("/******/var ");
buffer.push(options.libary);
buffer.push("=\n");
}
buffer.push(getTemplate(options, {chunks: false}));
buffer.push("/******/({\n");
buffer.push(writeChunk(depTree, options));
buffer.push("/******/})");
buffer = buffer.join("");
try {
if(options.minimize) buffer = uglify(buffer, "output");
options.events.emit("task-end", "statistics");
callback(null, buffer);
} catch(e) {
callback(e);
}
buffer.modulesFirstChunk = sum;
buffer.fileSizes = fileSizeMap;
buffer.warnings = depTree.warnings;
buffer.errors = depTree.errors;
buffer.fileModules = fileModulesMap;
buffer.subStats = subStats;
buffer.time = new Date() - startTime;
options.events.emit("task-end", "statistics");
options.events.emit("bundle", buffer);
callback(null, buffer);
}

@@ -503,0 +502,0 @@ });

@@ -71,2 +71,8 @@ /*

}
} else if(requireItem.requireFunction) {
replaces.push({
from: requireItem.expressionRange[0],
to: requireItem.expressionRange[1],
value: "require"
});
}

@@ -73,0 +79,0 @@ if(requireItem.amdNameRange) {

{
"name": "webpack",
"version": "0.5.10",
"version": "0.6.0",
"author": "Tobias Koppers @sokra",

@@ -11,3 +11,4 @@ "description": "Packs CommonJs/AMD 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.",

"sprintf": "0.1.x",
"enhanced-require": "0.1.x",
"enhanced-require": "0.2.x",
"enhanced-resolve": "0.2.x",
"raw-loader": "0.1.x",

@@ -18,3 +19,3 @@ "json-loader": "0.1.x",

"css-loader": "0.2.x",
"less-loader": "0.1.x",
"less-loader": "0.2.x",
"style-loader": "0.1.x",

@@ -33,2 +34,3 @@ "script-loader": "0.1.x",

"devDependencies": {
"worker-loader": "0.1.x",
"mocha": "*",

@@ -35,0 +37,0 @@ "should": "*",

@@ -9,5 +9,8 @@ /******/(function(document, undefined) {

/******/ var module = installedModules[moduleId] = {
/******/ exports: {}
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ };
/******/ modules[moduleId](module, module.exports, require);
/******/ module.loaded = true;
/******/ return module.exports;

@@ -14,0 +17,0 @@ /******/ }

@@ -8,5 +8,8 @@ /******/(function(modules) {

/******/ var module = installedModules[moduleId] = {
/******/ exports: {}
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ };
/******/ modules[moduleId](module, module.exports, require);
/******/ module.loaded = true;
/******/ return module.exports;

@@ -13,0 +16,0 @@ /******/ }

@@ -42,3 +42,3 @@ /*

var libary2 = cp.spawn("node", join(["../../bin/webpack.js", "--colors", "--libary", "libary2",
"--script-src-prefix", "js/", "--options", "libary2config.js", "node_modules/libary2", "js/libary2.js"], extraArgs));
"--public-prefix", "js/", "--options", "libary2config.js", "node_modules/libary2", "js/libary2.js"], extraArgsNoWatch));
bindOutput(libary2);
// Should not break it... should not include complete directory...
require = require("../../../require-polyfill")(require.valueOf());
require = require("enhanced-require")(module);
if(typeof define != "function") var define = require.define;

@@ -64,3 +65,2 @@ window.test(true, "index.js should be replaced with index.web.js");

window.test(require("." + "/" + singl + "uar").value === 2, "Context works in chunk, when splitted");
window.test(typeof module.id === "string", "module.id should be a string");
window.test(process.argv && process.argv.length > 1, "process.argv should be an array");

@@ -84,2 +84,4 @@ process.nextTick(function() {

});
window.test(typeof module.id === "number", "module.id should be a number");
window.test(module.id === require.resolve("./index.web.js"), "module.id should be a id of the module");

@@ -165,3 +167,3 @@ require.ensure([], function(require) {

var template = "tmpl";
var amdLoaded = 0;
var amdLoaded = "";
require(["./circular", "../templates/" + template, true ? "./circular" : "./circular"], function(circular, testTemplate, circular2) {

@@ -171,18 +173,30 @@ window.test(circular === 1, "AMD-style requires should work");

window.test(testTemplate === "test template", "AMD-style requires should work with context");
amdLoaded++;
amdLoaded+=1;
});
define("name", ["./circular"], function(circular) {
window.test(circular === 1, "AMD-style requires should work, in define");
amdLoaded++;
amdLoaded+=2;
});
define("name", [], function() {
amdLoaded++;
amdLoaded+=3;
});
define(["./circular"], function(circular) {
window.test(circular === 1, "AMD-style requires should work, in define without name");
amdLoaded++;
amdLoaded+=4;
});
define(function(require) {
define("blaa", function() {
amdLoaded+=5;
});
var obj = {};
define("blaaa", obj);
window.test(obj === module.exports, "AMD-style define exports a object");
var _test_require = require.valueOf();
var _test_exports = module.exports;
var _test_module = module;
define(function(require, exports, module) {
window.test(typeof require == "function", "AMD-style define CommonJs: require is function");
window.test(exports == _test_exports, "AMD-style define CommonJs: exports is correct");
window.test(module == _test_module, "AMD-style define CommonJs: module is correct");
window.test(require("./circular") === 1, "AMD-style requires should work, in define without name and requires");
amdLoaded++;
amdLoaded+=6;
});

@@ -193,7 +207,7 @@ require(["./circular"]);

window.test(require("./d") === "d", "AMD-style require should work, in chunk");
amdLoaded++;
amdLoaded+=7;
});
window.test(amdLoaded == 5, "AMD-style require should work (sync)");
window.test(amdLoaded == "123456", "AMD-style require should work (sync) "+amdLoaded);
setTimeout(function() {
window.test(amdLoaded == 6, "AMD-style require should work (async)");
window.test(amdLoaded == "1234567", "AMD-style require should work (async) " + amdLoaded);
}, 1500);

@@ -200,0 +214,0 @@

@@ -13,6 +13,10 @@ require("./common").globalCheck = false;

simple("assert");
simple("event-emitter-add-listeners");
simple("event-emitter-check-listener-leaks");
simple("event-emitter-max-listeners");
simple("event-emitter-modify-in-emit");
simple("event-emitter-num-args");
simple("event-emitter-once");
simple("event-emitter-remove-all-listeners");
simple("event-emitter-remove-listeners");
simple("global");

@@ -22,10 +26,11 @@ simple("next-tick-doesnt-hang");

simple("path");
simple("punycode");
simple("querystring");
simple("sys");
simple("timers");
simple("timers-zero-timeout");
simple("timers");
simple("url");
simple("util");
simple("util-format");
simple("util-inspect");
simple("util");

@@ -32,0 +37,0 @@ window.test(true, "Node.js simple tests should complete");

@@ -286,1 +286,11 @@ // Copyright Joyent, Inc. and other Node contributors.

// #2893
try {
assert.throws(function () {
assert.ifError(null);
});
} catch (e) {
threw = true;
assert.equal(e.message, 'Missing expected exception..');
}
assert.ok(threw);

@@ -42,6 +42,11 @@ // Copyright Joyent, Inc. and other Node contributors.

assert.deepEqual(e1.listeners('baz'), []);
// identity check, the array should not change
assert.equal(e1.listeners('foo'), fooListeners);
assert.equal(e1.listeners('bar'), barListeners);
assert.equal(e1.listeners('baz'), bazListeners);
// after calling removeAllListeners,
// the old listeners array should stay unchanged
assert.deepEqual(fooListeners, [listener]);
assert.deepEqual(barListeners, [listener]);
assert.deepEqual(bazListeners, [listener, listener]);
// after calling removeAllListeners,
// new listeners arrays are different from the old
assert.notEqual(e1.listeners('bar'), barListeners);
assert.notEqual(e1.listeners('baz'), bazListeners);

@@ -48,0 +53,0 @@ var e2 = new events.EventEmitter();

@@ -36,2 +36,3 @@ // Copyright Joyent, Inc. and other Node contributors.

},
'HTTP://www.example.com/' : {

@@ -46,2 +47,3 @@ 'href': 'http://www.example.com/',

},
'http://www.ExAmPlE.com/' : {

@@ -56,2 +58,3 @@ 'href': 'http://www.example.com/',

},
'http://user:pw@www.ExAmPlE.com/' : {

@@ -67,2 +70,3 @@ 'href': 'http://user:pw@www.example.com/',

},
'http://USER:PW@www.ExAmPlE.com/' : {

@@ -78,2 +82,3 @@ 'href': 'http://USER:PW@www.example.com/',

},
'http://user@www.example.com/' : {

@@ -89,2 +94,3 @@ 'href': 'http://user@www.example.com/',

},
'http://user%3Apw@www.example.com/' : {

@@ -100,4 +106,5 @@ 'href': 'http://user:pw@www.example.com/',

},
'http://x.com/path?that\'s#all, folks' : {
'href': 'http://x.com/path?that%27s#all,',
'href': 'http://x.com/path?that%27s#all,%20folks',
'protocol': 'http:',

@@ -110,5 +117,6 @@ 'slashes': true,

'pathname': '/path',
'hash': '#all,',
'hash': '#all,%20folks',
'path': '/path?that%27s'
},
'HTTP://X.COM/Y' : {

@@ -123,5 +131,6 @@ 'href': 'http://x.com/Y',

},
// an unexpected invalid char in the hostname.
'HtTp://x.y.cOm*a/b/c?d=e#f g<h>i' : {
'href': 'http://x.y.com/*a/b/c?d=e#f',
'href': 'http://x.y.com/*a/b/c?d=e#f%20g%3Ch%3Ei',
'protocol': 'http:',

@@ -134,8 +143,9 @@ 'slashes': true,

'query': 'd=e',
'hash': '#f',
'hash': '#f%20g%3Ch%3Ei',
'path': '/*a/b/c?d=e'
},
// make sure that we don't accidentally lcast the path parts.
'HtTp://x.y.cOm*A/b/c?d=e#f g<h>i' : {
'href': 'http://x.y.com/*A/b/c?d=e#f',
'href': 'http://x.y.com/*A/b/c?d=e#f%20g%3Ch%3Ei',
'protocol': 'http:',

@@ -148,5 +158,6 @@ 'slashes': true,

'query': 'd=e',
'hash': '#f',
'hash': '#f%20g%3Ch%3Ei',
'path': '/*A/b/c?d=e'
},
'http://x...y...#p': {

@@ -162,4 +173,5 @@ 'href': 'http://x...y.../#p',

},
'http://x/p/"quoted"': {
'href': 'http://x/p/',
'href': 'http://x/p/%22quoted%22',
'protocol': 'http:',

@@ -169,14 +181,12 @@ 'slashes': true,

'hostname': 'x',
'pathname': '/p/',
'path': '/p/'
'pathname': '/p/%22quoted%22',
'path': '/p/%22quoted%22'
},
'<http://goo.corn/bread> Is a URL!': {
'href': 'http://goo.corn/bread',
'protocol': 'http:',
'slashes': true,
'host': 'goo.corn',
'hostname': 'goo.corn',
'pathname': '/bread',
'path': '/bread'
'href': '%3Chttp://goo.corn/bread%3E%20Is%20a%20URL!',
'pathname': '%3Chttp://goo.corn/bread%3E%20Is%20a%20URL!',
'path': '%3Chttp://goo.corn/bread%3E%20Is%20a%20URL!'
},
'http://www.narwhaljs.org/blog/categories?id=news' : {

@@ -193,2 +203,3 @@ 'href': 'http://www.narwhaljs.org/blog/categories?id=news',

},
'http://mt0.google.com/vt/lyrs=m@114&hl=en&src=api&x=2&y=2&z=3&s=' : {

@@ -203,2 +214,3 @@ 'href': 'http://mt0.google.com/vt/lyrs=m@114&hl=en&src=api&x=2&y=2&z=3&s=',

},
'http://mt0.google.com/vt/lyrs=m@114???&hl=en&src=api&x=2&y=2&z=3&s=' : {

@@ -216,2 +228,3 @@ 'href': 'http://mt0.google.com/vt/lyrs=m@114???&hl=en&src=api' +

},
'http://user:pass@mt0.google.com/vt/lyrs=m@114???&hl=en&src=api&x=2&y=2&z=3&s=':

@@ -231,2 +244,3 @@ {

},
'file:///etc/passwd' : {

@@ -241,2 +255,3 @@ 'href': 'file:///etc/passwd',

},
'file://localhost/etc/passwd' : {

@@ -251,2 +266,3 @@ 'href': 'file://localhost/etc/passwd',

},
'file://foo/etc/passwd' : {

@@ -261,2 +277,3 @@ 'href': 'file://foo/etc/passwd',

},
'file:///etc/node/' : {

@@ -271,2 +288,3 @@ 'href': 'file:///etc/node/',

},
'file://localhost/etc/node/' : {

@@ -281,2 +299,3 @@ 'href': 'file://localhost/etc/node/',

},
'file://foo/etc/node/' : {

@@ -291,2 +310,3 @@ 'href': 'file://foo/etc/node/',

},
'http:/baz/../foo/bar' : {

@@ -298,2 +318,3 @@ 'href': 'http:/baz/../foo/bar',

},
'http://user:pass@example.com:8000/foo/bar?baz=quux#frag' : {

@@ -313,2 +334,3 @@ 'href': 'http://user:pass@example.com:8000/foo/bar?baz=quux#frag',

},
'//user:pass@example.com:8000/foo/bar?baz=quux#frag' : {

@@ -327,2 +349,3 @@ 'href': '//user:pass@example.com:8000/foo/bar?baz=quux#frag',

},
'/foo/bar?baz=quux#frag' : {

@@ -336,2 +359,3 @@ 'href': '/foo/bar?baz=quux#frag',

},
'http:/foo/bar?baz=quux#frag' : {

@@ -346,2 +370,3 @@ 'href': 'http:/foo/bar?baz=quux#frag',

},
'mailto:foo@bar.com?subject=hello' : {

@@ -357,2 +382,3 @@ 'href': 'mailto:foo@bar.com?subject=hello',

},
'javascript:alert(\'hello\');' : {

@@ -364,2 +390,3 @@ 'href': 'javascript:alert(\'hello\');',

},
'xmpp:isaacschlueter@jabber.org' : {

@@ -372,2 +399,3 @@ 'href': 'xmpp:isaacschlueter@jabber.org',

},
'http://atpass:foo%40bar@127.0.0.1:8080/path?search=foo#bar' : {

@@ -387,2 +415,3 @@ 'href' : 'http://atpass:foo%40bar@127.0.0.1:8080/path?search=foo#bar',

},
'svn+ssh://foo/bar': {

@@ -397,2 +426,3 @@ 'href': 'svn+ssh://foo/bar',

},
'dash-test://foo/bar': {

@@ -407,2 +437,3 @@ 'href': 'dash-test://foo/bar',

},
'dash-test:foo/bar': {

@@ -416,2 +447,3 @@ 'href': 'dash-test:foo/bar',

},
'dot.test://foo/bar': {

@@ -426,2 +458,3 @@ 'href': 'dot.test://foo/bar',

},
'dot.test:foo/bar': {

@@ -435,2 +468,3 @@ 'href': 'dot.test:foo/bar',

},
// IDNA tests

@@ -446,2 +480,3 @@ 'http://www.日本語.com/' : {

},
'http://example.Bücher.com/' : {

@@ -456,2 +491,3 @@ 'href': 'http://example.xn--bcher-kva.com/',

},
'http://www.Äffchen.com/' : {

@@ -466,4 +502,5 @@ 'href': 'http://www.xn--ffchen-9ta.com/',

},
'http://www.Äffchen.cOm*A/b/c?d=e#f g<h>i' : {
'href': 'http://www.xn--ffchen-9ta.com/*A/b/c?d=e#f',
'href': 'http://www.xn--ffchen-9ta.com/*A/b/c?d=e#f%20g%3Ch%3Ei',
'protocol': 'http:',

@@ -476,5 +513,6 @@ 'slashes': true,

'query': 'd=e',
'hash': '#f',
'hash': '#f%20g%3Ch%3Ei',
'path': '/*A/b/c?d=e'
},
'http://SÉLIER.COM/' : {

@@ -489,2 +527,3 @@ 'href': 'http://xn--slier-bsa.com/',

},
'http://ليهمابتكلموشعربي؟.ي؟/' : {

@@ -499,2 +538,3 @@ 'href': 'http://xn--egbpdaj6bu4bxfgehfvwxn.xn--egb9f/',

},
'http://➡.ws/➡' : {

@@ -509,2 +549,3 @@ 'href': 'http://xn--hgi.ws/➡',

},
'http://bucket_name.s3.amazonaws.com/image.jpg': {

@@ -520,2 +561,3 @@ protocol: 'http:',

},
'git+http://github.com/joyent/node.git': {

@@ -530,2 +572,3 @@ protocol: 'git+http:',

},
//if local1@domain1 is uses as a relative URL it may

@@ -539,2 +582,3 @@ //be parse into auth@hostname, but here there is no

},
//While this may seem counter-intuitive, a browser will parse

@@ -547,2 +591,3 @@ //<a href='www.google.com'> as a path.

},
// ipv6 support

@@ -554,2 +599,3 @@ '[fe80::1]': {

},
'coap://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]': {

@@ -564,2 +610,3 @@ 'protocol': 'coap:',

},
'coap://[1080:0:0:0:8:800:200C:417A]:61616/': {

@@ -575,2 +622,3 @@ 'protocol': 'coap:',

},
'http://user:password@[3ffe:2a00:100:7031::1]:8080': {

@@ -587,2 +635,3 @@ 'protocol': 'http:',

},
'coap://u:p@[::192.9.5.5]:61616/.well-known/r?n=Temperature': {

@@ -601,2 +650,3 @@ 'protocol': 'coap:',

},
// empty port

@@ -612,2 +662,3 @@ 'http://example.com:': {

},
'http://example.com:/a/b.html': {

@@ -622,2 +673,3 @@ 'protocol': 'http:',

},
'http://example.com:?a=b': {

@@ -634,2 +686,3 @@ 'protocol': 'http:',

},
'http://example.com:#abc': {

@@ -645,2 +698,3 @@ 'protocol': 'http:',

},
'http://[fe80::1]:/a/b?a=b#abc': {

@@ -662,5 +716,7 @@ 'protocol': 'http:',

var actual = url.parse(u),
spaced = url.parse(' \t ' + u + '\n\t');
expected = parseTests[u];
assert.deepEqual(actual, expected);
assert.deepEqual(spaced, expected);

@@ -766,6 +822,6 @@ var expected = parseTests[u].href,

'http://google.com" onload="alert(42)/' : {
'href': 'http://google.com/',
'href': 'http://google.com/%22%20onload=%22alert(42)/',
'protocol': 'http:',
'host': 'google.com',
'pathname': '/'
'pathname': '/%22%20onload=%22alert(42)/'
},

@@ -772,0 +828,0 @@ 'http://a.com/a/b/c?s#h' : {

@@ -7,59 +7,5 @@ /*

var path = require("path");
require = require("../require-polyfill")(require.valueOf());
require = require("enhanced-require")(module);
describe("polyfill", function() {
describe("require.context", function() {
var context = require.context("./fixtures")
it("should be able to require a file without extension", function() {
var a = context("./a");
should.exist(a);
a.should.be.a("function");
a().should.be.equal("This is a");
});
it("should be able to require a file with extension", function() {
var a = context("./a.js");
should.exist(a);
a.should.be.a("function");
a().should.be.equal("This is a");
});
it("should be able to require a file in a subdirectory", function() {
var complex1 = context("./lib/complex1");
should.exist(complex1);
complex1.should.be.equal("lib complex1");
});
it("should throw an exception if the module does not exists", function() {
(function() {
context("./notExists.js");
}).should.throw(/Cannot find module/);
});
});
describe("require.ensure", function() {
it("should be executed synchron", function() {
var executed = false;
var oldRequire = require;
require.ensure([], function(require) {
executed = true;
should.exist(require);
require.should.be.a("function");
require.should.be.equal(oldRequire);
});
executed.should.be.ok;
});
it("should work with modules list", function() {
require.ensure(["./fixtures/a"], function(require) {
var a = require("./fixtures/a");
should.exist(a);
a.should.be.a("function");
a().should.be.equal("This is a");
});
});
});
describe("loader", function() {

@@ -66,0 +12,0 @@ describe("raw", function() {

Sorry, the diff of this file is not supported yet

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