mirror of https://github.com/webpack/webpack.git
|
|
||
|---|---|---|
| .. | ||
| README.md | ||
| build.js | ||
| example.js | ||
| template.md | ||
| webpack.config.js | ||
| worker.js | ||
README.md
example.js
var Worker = require("worker!./worker");
var worker = new Worker;
worker.postMessage("b");
worker.onmessage = function(event) {
var templateB = event.data; // "This text was generated by template B"
}
worker.js
onmessage = function(event) {
var template = event.data;
require(["../require.context/templates/" + event.data], function(tmpl) {
postMessage(tmpl());
});
}
js/output.js
/******/ (function(modules) { // webpackBootstrap
/******/
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function 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, require);
/******/
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/ // The bundle contains no chunks. A empty chunk loading function.
/******/ require.e = function requireEnsure(_, callback) {
/******/ callback.call(null, this);
/******/ };
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ require.modules = modules;
/******/
/******/ // expose the module cache
/******/ require.cache = installedModules;
/******/
/******/ // __webpack_public_path__
/******/ require.p = "js/";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return require(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/*!********************!*\
!*** ./example.js ***!
\********************/
/***/ function(module, exports, require) {
var Worker = require(/*! worker!./worker */ 1);
var worker = new Worker;
worker.postMessage("b");
worker.onmessage = function(event) {
var templateB = event.data; // "This text was generated by template B"
}
/***/ },
/* 1 */
/*!*********************************************!*\
!*** (webpack)/~/worker-loader!./worker.js ***!
\*********************************************/
/***/ function(module, exports, require) {
module.exports = function() {
return new Worker(require.p + "hash.worker.js");
};
/***/ }
/******/ ])
js/[hash].worker.js
/******/ (function(modules) { // webpackBootstrap
/******/
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // object to store loaded chunks
/******/ // "1" means "already loaded"
/******/ var installedChunks = {
/******/ 0:1
/******/ };
/******/
/******/ // The require function
/******/ function 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, require);
/******/
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/ // This file contains only the entry chunk.
/******/ // The chunk loading function for additional chunks
/******/ require.e = function requireEnsure(chunkId, callback) {
/******/ // "1" is the signal for "already loaded"
/******/ if(!installedChunks[chunkId]) {
/******/ importScripts("" + chunkId + ".hash.worker.js");
/******/ }
/******/ callback.call(null, require);
/******/ };
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ require.modules = modules;
/******/
/******/ // expose the module cache
/******/ require.cache = installedModules;
/******/
/******/ // __webpack_public_path__
/******/ require.p = "";
/******/ this["webpackChunk"] = function webpackChunkCallback(chunkIds, moreModules) {
/******/ for(var moduleId in moreModules) {
/******/ modules[moduleId] = moreModules[moduleId];
/******/ }
/******/ while(chunkIds.length)
/******/ installedChunks[chunkIds.pop()] = 1;
/******/ };
/******/
/******/ // Load entry module and return exports
/******/ return require(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/*!*******************!*\
!*** ./worker.js ***!
\*******************/
/***/ function(module, exports, require) {
onmessage = function(event) {
var template = event.data;
require.e/* require */(1, function(require) { var __WEBPACK_AMD_REQUIRE_ARRAY__ = [require(/*! ../require.context/templates */ 4)("./" + event.data)]; (function(tmpl) {
postMessage(tmpl());
}.apply(null, __WEBPACK_AMD_REQUIRE_ARRAY__));});
}
/***/ }
/******/ ])
js/1.[hash].worker.hs
webpackChunk([1],[
/* 0 */,
/* 1 */
/*!*****************************************!*\
!*** ../require.context/templates/a.js ***!
\*****************************************/
/***/ function(module, exports, require) {
module.exports = function() {
return "This text was generated by template A";
}
/***/ },
/* 2 */
/*!*****************************************!*\
!*** ../require.context/templates/b.js ***!
\*****************************************/
/***/ function(module, exports, require) {
module.exports = function() {
return "This text was generated by template B";
}
/***/ },
/* 3 */
/*!*****************************************!*\
!*** ../require.context/templates/c.js ***!
\*****************************************/
/***/ function(module, exports, require) {
module.exports = function() {
return "This text was generated by template C";
}
/***/ },
/* 4 */
/*!*********************************************!*\
!*** ../require.context/templates ^\.\/.*$ ***!
\*********************************************/
/***/ function(module, exports, require) {
var map = {
"./a": 1,
"./a.js": 1,
"./b": 2,
"./b.js": 2,
"./c": 3,
"./c.js": 3
};
function webpackContext(req) {
return 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;
/***/ }
])
Info
Uncompressed
Hash: d3a484ec9964172dc379
Version: webpack 1.0.0-beta8
Time: 131ms
Asset Size Chunks Chunk Names
hash.worker.js 2697 [emitted]
1.hash.worker.js 1593 [emitted]
output.js 2244 0 [emitted] main
chunk {0} output.js (main) 302 [rendered]
> main [0] ./example.js
[0] ./example.js 206 {0} [built]
[1] (webpack)/~/worker-loader!./worker.js 96 {0} [not cacheable] [built]
cjs require worker!./worker [0] ./example.js 1:13-39
Child worker:
Hash: f8be7dd704b535b316bd
Version: webpack 1.0.0-beta8
Asset Size Chunks Chunk Names
hash.worker.js 2697 0 [emitted] main
1.hash.worker.js 1593 1 [emitted]
chunk {0} hash.worker.js (main) 168 [rendered]
> main [0] ./worker.js
[0] ./worker.js 168 {0} [built]
chunk {1} 1.hash.worker.js 463 {0} [rendered]
> [0] ./worker.js 3:1-5:3
[1] ../require.context/templates/a.js 82 {1} [built]
context element ./a.js [4] ../require.context/templates ^\.\/.*$
context element ./a [4] ../require.context/templates ^\.\/.*$
[2] ../require.context/templates/b.js 82 {1} [built]
context element ./b.js [4] ../require.context/templates ^\.\/.*$
context element ./b [4] ../require.context/templates ^\.\/.*$
[3] ../require.context/templates/c.js 82 {1} [built]
context element ./c.js [4] ../require.context/templates ^\.\/.*$
context element ./c [4] ../require.context/templates ^\.\/.*$
[4] ../require.context/templates ^\.\/.*$ 217 {1} [built]
amd require context ../require.context/templates [0] ./worker.js 3:1-5:3
Minimized (uglify-js, no zip)
Hash: e028e5c3f2a9ee017ccf
Version: webpack 1.0.0-beta8
Time: 245ms
Asset Size Chunks Chunk Names
hash.worker.js 523 [emitted]
1.hash.worker.js 528 [emitted]
output.js 418 0 [emitted] main
chunk {0} output.js (main) 302 [rendered]
> main [0] ./example.js
[0] ./example.js 206 {0} [built]
[1] (webpack)/~/worker-loader!./worker.js 96 {0} [not cacheable] [built]
cjs require worker!./worker [0] ./example.js 1:13-39
WARNING in output.js from UglifyJs
Side effects in initialization of unused variable templateB [./example.js:5,0]
Child worker:
Hash: 5a60a9d218768e784433
Version: webpack 1.0.0-beta8
Asset Size Chunks Chunk Names
hash.worker.js 523 0 [emitted] main
1.hash.worker.js 528 1 [emitted]
chunk {0} hash.worker.js (main) 168 [rendered]
> main [0] ./worker.js
[0] ./worker.js 168 {0} [built]
chunk {1} 1.hash.worker.js 463 {0} [rendered]
> [0] ./worker.js 3:1-5:3
[1] ../require.context/templates/a.js 82 {1} [built]
context element ./a.js [4] ../require.context/templates ^\.\/.*$
context element ./a [4] ../require.context/templates ^\.\/.*$
[2] ../require.context/templates/b.js 82 {1} [built]
context element ./b.js [4] ../require.context/templates ^\.\/.*$
context element ./b [4] ../require.context/templates ^\.\/.*$
[3] ../require.context/templates/c.js 82 {1} [built]
context element ./c.js [4] ../require.context/templates ^\.\/.*$
context element ./c [4] ../require.context/templates ^\.\/.*$
[4] ../require.context/templates ^\.\/.*$ 217 {1} [built]
amd require context ../require.context/templates [0] ./worker.js 3:1-5:3
WARNING in hash.worker.js from UglifyJs
Side effects in initialization of unused variable template [./worker.js:2,0]