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 __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] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ // Flag the module as loaded
/******/ module.l = 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;
/******/ // identity function for calling harmory imports with the correct context
/******/ __webpack_require__.i = function(value) { return value; };
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "js/";
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 1);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/*!*********************************************!*\
!*** (webpack)/~/worker-loader!./worker.js ***!
\*********************************************/
/***/ function(module, exports, __webpack_require__) {
module.exports = function() {
return new Worker(__webpack_require__.p + "hash.worker.js");
};
/***/ },
/* 1 */
/*!********************!*\
!*** ./example.js ***!
\********************/
/***/ function(module, exports, __webpack_require__) {
var Worker = __webpack_require__(/*! worker!./worker */ 0);
var worker = new Worker;
worker.postMessage("b");
worker.onmessage = function(event) {
var templateB = event.data; // "This text was generated by template B"
}
/***/ }
/******/ ]);
js/[hash].worker.js
/******/ (function(modules) { // webpackBootstrap
/******/ this["webpackChunk"] = function webpackChunkCallback(chunkIds, moreModules) {
/******/ for(var moduleId in moreModules) {
/******/ modules[moduleId] = moreModules[moduleId];
/******/ }
/******/ while(chunkIds.length)
/******/ installedChunks[chunkIds.pop()] = 1;
/******/ };
/******/ // The module cache
/******/ var installedModules = {};
/******/ // object to store loaded chunks
/******/ // "1" means "already loaded"
/******/ var installedChunks = {
/******/ 1: 1
/******/ };
/******/ // 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] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/ // This file contains only the entry chunk.
/******/ // The chunk loading function for additional chunks
/******/ __webpack_require__.e = function requireEnsure(chunkId) {
/******/ // "1" is the signal for "already loaded"
/******/ if(!installedChunks[chunkId]) {
/******/ importScripts("" + chunkId + ".hash.worker.js");
/******/ }
/******/ return Promise.resolve();
/******/ };
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/ // identity function for calling harmory imports with the correct context
/******/ __webpack_require__.i = function(value) { return value; };
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "js/";
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 1);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */,
/* 1 */
/*!*******************!*\
!*** ./worker.js ***!
\*******************/
/***/ function(module, exports, __webpack_require__) {
onmessage = function(event) {
var template = event.data;
__webpack_require__.e/* require */(0).catch(function(err) { __webpack_require__.oe(err); }).then(function() { var __WEBPACK_AMD_REQUIRE_ARRAY__ = [__webpack_require__(/*! ../require.context/templates */ 0)("./" + event.data)]; (function(tmpl) {
postMessage(tmpl());
}.apply(null, __WEBPACK_AMD_REQUIRE_ARRAY__));});
}
/***/ }
/******/ ]);
js/0.[hash].worker.js
webpackChunk([0],[
/* 0 */
/*!*********************************************!*\
!*** ../require.context/templates ^\.\/.*$ ***!
\*********************************************/
/***/ function(module, exports, __webpack_require__) {
var map = {
"./a": 2,
"./a.js": 2,
"./b": 3,
"./b.js": 3,
"./c": 4,
"./c.js": 4
};
function webpackContext(req) {
return __webpack_require__(webpackContextResolve(req));
};
function webpackContextResolve(req) {
var id = map[req];
if(!(id + 1)) // check for number
throw new Error("Cannot find module '" + req + "'.");
return id;
};
webpackContext.keys = function webpackContextKeys() {
return Object.keys(map);
};
webpackContext.resolve = webpackContextResolve;
module.exports = webpackContext;
webpackContext.id = 0;
/***/ },
/* 1 */,
/* 2 */
/*!*****************************************!*\
!*** ../require.context/templates/a.js ***!
\*****************************************/
/***/ function(module, exports) {
module.exports = function() {
return "This text was generated by template A";
}
/***/ },
/* 3 */
/*!*****************************************!*\
!*** ../require.context/templates/b.js ***!
\*****************************************/
/***/ function(module, exports) {
module.exports = function() {
return "This text was generated by template B";
}
/***/ },
/* 4 */
/*!*****************************************!*\
!*** ../require.context/templates/c.js ***!
\*****************************************/
/***/ function(module, exports) {
module.exports = function() {
return "This text was generated by template C";
}
/***/ }
]);
Info
Uncompressed
Hash: 2db16cd1ac2addf34b0e
Version: webpack 2.1.0-beta.11
Time: 121ms
Asset Size Chunks Chunk Names
0.hash.worker.js 1.65 kB [emitted]
hash.worker.js 2.9 kB [emitted]
output.js 2.21 kB 0 [emitted] main
chunk {0} output.js (main) 302 bytes [rendered]
> main [1] ./example.js
[0] (webpack)/~/worker-loader!./worker.js 96 bytes {0} [built]
cjs require worker!./worker [1] ./example.js 1:13-39
[1] ./example.js 206 bytes {0} [built]
Child worker:
Asset Size Chunks Chunk Names
0.hash.worker.js 1.65 kB 0 [emitted]
hash.worker.js 2.9 kB 1 [emitted] main
chunk {0} 0.hash.worker.js 463 bytes {1} [rendered]
> [1] ./worker.js 3:1-5:3
[0] ../require.context/templates ^\.\/.*$ 217 bytes {0} [built]
amd require context ../require.context/templates [1] ./worker.js 3:1-5:3
[2] ../require.context/templates/a.js 82 bytes {0} [optional] [built]
context element ./a [0] ../require.context/templates ^\.\/.*$
context element ./a.js [0] ../require.context/templates ^\.\/.*$
[3] ../require.context/templates/b.js 82 bytes {0} [optional] [built]
context element ./b [0] ../require.context/templates ^\.\/.*$
context element ./b.js [0] ../require.context/templates ^\.\/.*$
[4] ../require.context/templates/c.js 82 bytes {0} [optional] [built]
context element ./c [0] ../require.context/templates ^\.\/.*$
context element ./c.js [0] ../require.context/templates ^\.\/.*$
chunk {1} hash.worker.js (main) 168 bytes [rendered]
> main [1] ./worker.js
[1] ./worker.js 168 bytes {1} [built]
Minimized (uglify-js, no zip)
Hash: 2db16cd1ac2addf34b0e
Version: webpack 2.1.0-beta.11
Time: 208ms
Asset Size Chunks Chunk Names
0.hash.worker.js 544 bytes [emitted]
hash.worker.js 580 bytes [emitted]
output.js 390 bytes 0 [emitted] main
chunk {0} output.js (main) 302 bytes [rendered]
> main [1] ./example.js
[0] (webpack)/~/worker-loader!./worker.js 96 bytes {0} [built]
cjs require worker!./worker [1] ./example.js 1:13-39
[1] ./example.js 206 bytes {0} [built]
Child worker:
Asset Size Chunks Chunk Names
0.hash.worker.js 544 bytes 0 [emitted]
hash.worker.js 580 bytes 1 [emitted] main
chunk {0} 0.hash.worker.js 463 bytes {1} [rendered]
> [1] ./worker.js 3:1-5:3
[0] ../require.context/templates ^\.\/.*$ 217 bytes {0} [built]
amd require context ../require.context/templates [1] ./worker.js 3:1-5:3
[2] ../require.context/templates/a.js 82 bytes {0} [optional] [built]
context element ./a [0] ../require.context/templates ^\.\/.*$
context element ./a.js [0] ../require.context/templates ^\.\/.*$
[3] ../require.context/templates/b.js 82 bytes {0} [optional] [built]
context element ./b [0] ../require.context/templates ^\.\/.*$
context element ./b.js [0] ../require.context/templates ^\.\/.*$
[4] ../require.context/templates/c.js 82 bytes {0} [optional] [built]
context element ./c [0] ../require.context/templates ^\.\/.*$
context element ./c.js [0] ../require.context/templates ^\.\/.*$
chunk {1} hash.worker.js (main) 168 bytes [rendered]
> main [1] ./worker.js
[1] ./worker.js 168 bytes {1} [built]