webpack
Version:
Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jade, coffee, css, less, ... and your custom stuff.
422 lines (366 loc) • 11 kB
JavaScript
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/*!**********************************!*\
!*** ./loaders/context/index.js ***!
\**********************************/
/***/ function(module, exports, __webpack_require__) {
it("should be able to use a context with a loader", function() {
var abc = "abc", scr = "script.coffee";
__webpack_require__(/*! ../_resources */ 1)("./" + scr).should.be.eql("coffee test");
__webpack_require__(/*! raw!../_resources */ 4)("./" + abc + ".txt").should.be.eql("abc");
});
/***/ },
/* 1 */
/*!*************************************!*\
!*** ./loaders/_resources ^\.\/.*$ ***!
\*************************************/
/***/ function(module, exports, __webpack_require__) {
var map = {
"./abc.txt": 2,
"./included.jade": 6,
"./parent.jade": 7,
"./script.coffee": 3,
"./template.jade": 8
};
function webpackContext(req) {
return __webpack_require__(webpackContextResolve(req));
};
function webpackContextResolve(req) {
return map[req] || (function() { throw new Error("Cannot find module '" + req + "'.") }());
};
webpackContext.keys = function webpackContextKeys() {
return Object.keys(map);
};
webpackContext.resolve = webpackContextResolve;
module.exports = webpackContext;
webpackContext.id = 1;
/***/ },
/* 2 */
/*!************************************!*\
!*** ./loaders/_resources/abc.txt ***!
\************************************/
/***/ function(module, exports, __webpack_require__) {
abc
/***/ },
/* 3 */
/*!******************************************!*\
!*** ./loaders/_resources/script.coffee ***!
\******************************************/
/***/ function(module, exports, __webpack_require__) {
var condition, obj;
condition = true;
obj = {
text: "coffee test"
};
if (condition != null) {
module.exports = obj.text;
}
/***/ },
/* 4 */
/*!*****************************************************************!*\
!*** ./loaders/_resources (webpack)/~/raw-loader!^\.\/.*\.txt$ ***!
\*****************************************************************/
/***/ function(module, exports, __webpack_require__) {
var map = {
"./abc.txt": 5
};
function webpackContext(req) {
return __webpack_require__(webpackContextResolve(req));
};
function webpackContextResolve(req) {
return map[req] || (function() { throw new Error("Cannot find module '" + req + "'.") }());
};
webpackContext.keys = function webpackContextKeys() {
return Object.keys(map);
};
webpackContext.resolve = webpackContextResolve;
module.exports = webpackContext;
webpackContext.id = 4;
/***/ },
/* 5 */
/*!***********************************************************!*\
!*** (webpack)/~/raw-loader!./loaders/_resources/abc.txt ***!
\***********************************************************/
/***/ function(module, exports, __webpack_require__) {
module.exports = "abc"
/***/ },
/* 6 */
/*!******************************************!*\
!*** ./loaders/_resources/included.jade ***!
\******************************************/
/***/ function(module, exports, __webpack_require__) {
var jade = __webpack_require__(/*! (webpack)/~/jade/lib/runtime.js */ 11);
module.exports = function template(locals) {
var buf = [];
var jade_mixins = {};
var jade_interp;
buf.push("<h1>included</h1>");;return buf.join("");
}
/***/ },
/* 7 */
/*!****************************************!*\
!*** ./loaders/_resources/parent.jade ***!
\****************************************/
/***/ function(module, exports, __webpack_require__) {
var jade = __webpack_require__(/*! (webpack)/~/jade/lib/runtime.js */ 11);
module.exports = function template(locals) {
var buf = [];
var jade_mixins = {};
var jade_interp;
buf.push("<p></p>" + (null == (jade_interp = __webpack_require__(/*! ./loaders/_resources/included.jade */ 6).call(this, locals)) ? "" : jade_interp));;return buf.join("");
}
/***/ },
/* 8 */
/*!******************************************!*\
!*** ./loaders/_resources/template.jade ***!
\******************************************/
/***/ function(module, exports, __webpack_require__) {
var jade = __webpack_require__(/*! (webpack)/~/jade/lib/runtime.js */ 11);
module.exports = function template(locals) {
var buf = [];
var jade_mixins = {};
var jade_interp;
var locals_ = (locals || {}),abc = locals_.abc,self = locals_.self;
buf.push("<p>" + (jade.escape(null == (jade_interp = typeof abc === "undefined" ? "self" + self.abc : abc) ? "" : jade_interp)) + "</p>" + (null == (jade_interp = __webpack_require__(/*! ./loaders/_resources/included.jade */ 6).call(this, locals)) ? "" : jade_interp));;return buf.join("");
}
/***/ },
/* 9 */,
/* 10 */,
/* 11 */
/*!***************************************!*\
!*** (webpack)/~/jade/lib/runtime.js ***!
\***************************************/
/***/ function(module, exports, __webpack_require__) {
'use strict';
/**
* Merge two attribute objects giving precedence
* to values in object `b`. Classes are special-cased
* allowing for arrays and merging/joining appropriately
* resulting in a string.
*
* @param {Object} a
* @param {Object} b
* @return {Object} a
* @api private
*/
exports.merge = function merge(a, b) {
if (arguments.length === 1) {
var attrs = a[0];
for (var i = 1; i < a.length; i++) {
attrs = merge(attrs, a[i]);
}
return attrs;
}
var ac = a['class'];
var bc = b['class'];
if (ac || bc) {
ac = ac || [];
bc = bc || [];
if (!Array.isArray(ac)) ac = [ac];
if (!Array.isArray(bc)) bc = [bc];
a['class'] = ac.concat(bc).filter(nulls);
}
for (var key in b) {
if (key != 'class') {
a[key] = b[key];
}
}
return a;
};
/**
* Filter null `val`s.
*
* @param {*} val
* @return {Boolean}
* @api private
*/
function nulls(val) {
return val != null && val !== '';
}
/**
* join array as classes.
*
* @param {*} val
* @return {String}
*/
exports.joinClasses = joinClasses;
function joinClasses(val) {
return Array.isArray(val) ? val.map(joinClasses).filter(nulls).join(' ') : val;
}
/**
* Render the given classes.
*
* @param {Array} classes
* @param {Array.<Boolean>} escaped
* @return {String}
*/
exports.cls = function cls(classes, escaped) {
var buf = [];
for (var i = 0; i < classes.length; i++) {
if (escaped && escaped[i]) {
buf.push(exports.escape(joinClasses([classes[i]])));
} else {
buf.push(joinClasses(classes[i]));
}
}
var text = joinClasses(buf);
if (text.length) {
return ' class="' + text + '"';
} else {
return '';
}
};
/**
* Render the given attribute.
*
* @param {String} key
* @param {String} val
* @param {Boolean} escaped
* @param {Boolean} terse
* @return {String}
*/
exports.attr = function attr(key, val, escaped, terse) {
if ('boolean' == typeof val || null == val) {
if (val) {
return ' ' + (terse ? key : key + '="' + key + '"');
} else {
return '';
}
} else if (0 == key.indexOf('data') && 'string' != typeof val) {
return ' ' + key + "='" + JSON.stringify(val).replace(/'/g, ''') + "'";
} else if (escaped) {
return ' ' + key + '="' + exports.escape(val) + '"';
} else {
return ' ' + key + '="' + val + '"';
}
};
/**
* Render the given attributes object.
*
* @param {Object} obj
* @param {Object} escaped
* @return {String}
*/
exports.attrs = function attrs(obj, terse){
var buf = [];
var keys = Object.keys(obj);
if (keys.length) {
for (var i = 0; i < keys.length; ++i) {
var key = keys[i]
, val = obj[key];
if ('class' == key) {
if (val = joinClasses(val)) {
buf.push(' ' + key + '="' + val + '"');
}
} else {
buf.push(exports.attr(key, val, false, terse));
}
}
}
return buf.join('');
};
/**
* Escape the given string of `html`.
*
* @param {String} html
* @return {String}
* @api private
*/
exports.escape = function escape(html){
var result = String(html)
.replace(/&/g, '&')
.replace(/</g, '<')
.replace(/>/g, '>')
.replace(/"/g, '"');
if (result === '' + html) return html;
else return result;
};
/**
* Re-throw the given `err` in context to the
* the jade in `filename` at the given `lineno`.
*
* @param {Error} err
* @param {String} filename
* @param {String} lineno
* @api private
*/
exports.rethrow = function rethrow(err, filename, lineno, str){
if (!(err instanceof Error)) throw err;
if ((typeof window != 'undefined' || !filename) && !str) {
err.message += ' on line ' + lineno;
throw err;
}
try {
str = str || __webpack_require__(/*! fs */ 12).readFileSync(filename, 'utf8')
} catch (ex) {
rethrow(err, null, lineno)
}
var context = 3
, lines = str.split('\n')
, start = Math.max(lineno - context, 0)
, end = Math.min(lines.length, lineno + context);
// Error context
var context = lines.slice(start, end).map(function(line, i){
var curr = i + start + 1;
return (curr == lineno ? ' > ' : ' ')
+ curr
+ '| '
+ line;
}).join('\n');
// Alter exception message
err.path = filename;
err.message = (filename || 'Jade') + ':' + lineno
+ '\n' + context + '\n\n' + err.message;
throw err;
};
/***/ },
/* 12 */
/*!*********************!*\
!*** external "fs" ***!
\*********************/
/***/ function(module, exports, __webpack_require__) {
module.exports = require("fs");
/***/ }
/******/ ])