2012-08-23 08:05:07 +08:00
|
|
|
|
|
|
|
|
# example.js
|
|
|
|
|
|
|
|
|
|
``` javascript
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
``` javascript
|
|
|
|
|
onmessage = function(event) {
|
|
|
|
|
var template = event.data;
|
|
|
|
|
require(["../require.context/templates/" + event.data], function(tmpl) {
|
|
|
|
|
postMessage(tmpl());
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
# js/output.js
|
|
|
|
|
|
|
|
|
|
``` javascript
|
2013-01-31 01:49:25 +08:00
|
|
|
/******/ (function webpackBootstrap(modules) {
|
|
|
|
|
/******/ var installedModules = {};
|
|
|
|
|
/******/ function require(moduleId) {
|
|
|
|
|
/******/ if(installedModules[moduleId])
|
|
|
|
|
/******/ return installedModules[moduleId].exports;
|
|
|
|
|
/******/ var module = installedModules[moduleId] = {
|
|
|
|
|
/******/ exports: {},
|
|
|
|
|
/******/ id: moduleId,
|
|
|
|
|
/******/ loaded: false
|
|
|
|
|
/******/ };
|
|
|
|
|
/******/ modules[moduleId].call(null, module, module.exports, require);
|
|
|
|
|
/******/ module.loaded = true;
|
|
|
|
|
/******/ return module.exports;
|
|
|
|
|
/******/ }
|
|
|
|
|
/******/ require.e = function requireEnsure(chunkId, callback) {
|
|
|
|
|
/******/ callback.call(null, require);
|
|
|
|
|
/******/ };
|
|
|
|
|
/******/ require.modules = modules;
|
|
|
|
|
/******/ require.cache = installedModules;
|
|
|
|
|
/******/ return require(0);
|
|
|
|
|
/******/ })({
|
|
|
|
|
/******/ c: "",
|
|
|
|
|
|
|
|
|
|
/***/ 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"
|
|
|
|
|
}
|
2012-08-23 08:05:07 +08:00
|
|
|
|
2013-01-31 01:49:25 +08:00
|
|
|
/***/ },
|
2012-08-23 08:05:07 +08:00
|
|
|
|
2013-01-31 01:49:25 +08:00
|
|
|
/***/ 1:
|
2013-02-13 18:58:13 +08:00
|
|
|
/*!*********************************************!*\
|
|
|
|
|
!*** (webpack)/~/worker-loader!./worker.js ***!
|
|
|
|
|
\*********************************************/
|
2013-01-31 01:49:25 +08:00
|
|
|
/***/ function(module, exports, require) {
|
2012-08-23 08:05:07 +08:00
|
|
|
|
2013-01-31 01:49:25 +08:00
|
|
|
module.exports = function() {
|
2013-01-31 10:25:20 +08:00
|
|
|
return new Worker(require.modules.c + "hash.worker.js");
|
2013-01-31 01:49:25 +08:00
|
|
|
};
|
2012-08-23 08:05:07 +08:00
|
|
|
|
2013-01-31 01:49:25 +08:00
|
|
|
/***/ }
|
|
|
|
|
/******/ })
|
2012-08-23 08:05:07 +08:00
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
# js/[hash].worker.js
|
|
|
|
|
|
|
|
|
|
``` javascript
|
2013-01-31 10:25:20 +08:00
|
|
|
/******/ (function webpackBootstrap(modules) {
|
|
|
|
|
/******/ var installedModules = {};
|
|
|
|
|
/******/ function require(moduleId) {
|
|
|
|
|
/******/ if(installedModules[moduleId])
|
|
|
|
|
/******/ return installedModules[moduleId].exports;
|
|
|
|
|
/******/ var module = installedModules[moduleId] = {
|
|
|
|
|
/******/ exports: {},
|
|
|
|
|
/******/ id: moduleId,
|
|
|
|
|
/******/ loaded: false
|
|
|
|
|
/******/ };
|
|
|
|
|
/******/ modules[moduleId].call(null, module, module.exports, require);
|
|
|
|
|
/******/ module.loaded = true;
|
|
|
|
|
/******/ return module.exports;
|
|
|
|
|
/******/ }
|
|
|
|
|
/******/ require.e = function requireEnsure(chunkId, callback) {
|
|
|
|
|
/******/ if(installedChunks[chunkId] === 1) return callback.call(null, require);
|
|
|
|
|
/******/ importScripts(""+chunkId+".bundle.js");
|
|
|
|
|
/******/ callback.call(null, require);
|
|
|
|
|
/******/ };
|
|
|
|
|
/******/ require.modules = modules;
|
|
|
|
|
/******/ require.cache = installedModules;
|
|
|
|
|
/******/ var installedChunks = {0:1};
|
2013-02-24 09:27:11 +08:00
|
|
|
/******/ this["webpackChunk"] = function webpackChunkCallback(chunkIds, moreModules) {
|
2013-01-31 10:25:20 +08:00
|
|
|
/******/ for(var moduleId in moreModules)
|
|
|
|
|
/******/ modules[moduleId] = moreModules[moduleId];
|
2013-02-24 09:27:11 +08:00
|
|
|
/******/ for(var i = 0; i < chunkIds.length; i++)
|
|
|
|
|
/******/ installedChunks[chunkIds[i]] = 1;
|
2013-01-31 10:25:20 +08:00
|
|
|
/******/ };
|
|
|
|
|
/******/ return require(0);
|
|
|
|
|
/******/ })({
|
|
|
|
|
/******/ c: "",
|
2012-08-23 08:05:07 +08:00
|
|
|
|
2013-01-31 10:25:20 +08:00
|
|
|
/***/ 0:
|
|
|
|
|
/*!*******************!*\
|
|
|
|
|
!*** ./worker.js ***!
|
|
|
|
|
\*******************/
|
|
|
|
|
/***/ function(module, exports, require) {
|
2012-08-23 08:05:07 +08:00
|
|
|
|
2013-01-31 10:25:20 +08:00
|
|
|
onmessage = function(event) {
|
|
|
|
|
var template = event.data;
|
|
|
|
|
require.e/* require */(1, function(require) { var __WEBPACK_AMD_REQUIRE_ARRAY__ = [require(/*! ../require.context/templates */ 1)("./" + event.data)]; (function(tmpl) {
|
|
|
|
|
postMessage(tmpl());
|
|
|
|
|
}.apply(null, __WEBPACK_AMD_REQUIRE_ARRAY__));});
|
2012-08-23 08:05:07 +08:00
|
|
|
}
|
2013-01-31 10:25:20 +08:00
|
|
|
|
2012-10-09 06:12:10 +08:00
|
|
|
|
2013-01-31 10:25:20 +08:00
|
|
|
/***/ }
|
|
|
|
|
/******/ })
|
2012-08-23 08:05:07 +08:00
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
# Info
|
|
|
|
|
|
|
|
|
|
## Uncompressed
|
|
|
|
|
|
|
|
|
|
```
|
2013-02-24 09:27:11 +08:00
|
|
|
Hash: c7ce795e4c2122d3f175fa426dbb3130
|
|
|
|
|
Time: 72ms
|
2013-01-31 10:25:20 +08:00
|
|
|
Asset Size Chunks Chunk Names
|
2013-02-24 09:27:11 +08:00
|
|
|
hash.worker.js 1711
|
|
|
|
|
1.hash.worker.js 1589
|
2013-02-21 03:50:53 +08:00
|
|
|
output.js 1456 0 main
|
|
|
|
|
chunk {0} output.js (main) 302
|
|
|
|
|
[0] ./example.js 206 [built] {0}
|
2013-02-13 18:58:13 +08:00
|
|
|
[1] (webpack)/~/worker-loader!./worker.js 96 [not cacheable] [built] {0}
|
2013-01-31 01:49:25 +08:00
|
|
|
cjs require worker!./worker [0] ./example.js 1:13-39
|
|
|
|
|
Child worker:
|
2013-02-24 09:27:11 +08:00
|
|
|
Hash: ac1f44dac199ee427792d65ff79c83c3
|
2013-01-31 10:25:20 +08:00
|
|
|
Asset Size Chunks Chunk Names
|
2013-02-24 09:27:11 +08:00
|
|
|
hash.worker.js 1711 0 main
|
|
|
|
|
1.hash.worker.js 1589 1
|
2013-02-21 03:50:53 +08:00
|
|
|
chunk {0} hash.worker.js (main) 168
|
|
|
|
|
[0] ./worker.js 168 [built] {0}
|
|
|
|
|
chunk {1} 1.hash.worker.js 463 {0}
|
|
|
|
|
[1] ../require.context/templates ^\.\/.*$ 217 [built] {1}
|
2013-02-13 18:58:13 +08:00
|
|
|
amd require context ../require.context/templates [0] ./worker.js 3:1-5:3
|
2013-02-21 03:50:53 +08:00
|
|
|
[2] ../require.context/templates/a.js 82 [built] {1}
|
|
|
|
|
context element ./a [1] ../require.context/templates ^\.\/.*$
|
|
|
|
|
context element ./a.js [1] ../require.context/templates ^\.\/.*$
|
|
|
|
|
[3] ../require.context/templates/b.js 82 [built] {1}
|
|
|
|
|
context element ./b [1] ../require.context/templates ^\.\/.*$
|
|
|
|
|
context element ./b.js [1] ../require.context/templates ^\.\/.*$
|
|
|
|
|
[4] ../require.context/templates/c.js 82 [built] {1}
|
|
|
|
|
context element ./c [1] ../require.context/templates ^\.\/.*$
|
|
|
|
|
context element ./c.js [1] ../require.context/templates ^\.\/.*$
|
2012-08-23 08:05:07 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Minimized (uglify-js, no zip)
|
|
|
|
|
|
|
|
|
|
```
|
2013-02-24 09:27:11 +08:00
|
|
|
Hash: c7ce795e4c2122d3f175fa426dbb3130
|
|
|
|
|
Time: 218ms
|
2013-01-31 10:25:20 +08:00
|
|
|
Asset Size Chunks Chunk Names
|
2013-02-24 09:27:11 +08:00
|
|
|
hash.worker.js 561
|
|
|
|
|
1.hash.worker.js 531
|
2013-02-21 03:50:53 +08:00
|
|
|
output.js 418 0 main
|
|
|
|
|
chunk {0} output.js (main) 302
|
|
|
|
|
[0] ./example.js 206 [built] {0}
|
2013-02-13 18:58:13 +08:00
|
|
|
[1] (webpack)/~/worker-loader!./worker.js 96 [not cacheable] [built] {0}
|
2013-01-31 01:49:25 +08:00
|
|
|
cjs require worker!./worker [0] ./example.js 1:13-39
|
|
|
|
|
Child worker:
|
2013-02-24 09:27:11 +08:00
|
|
|
Hash: ac1f44dac199ee427792d65ff79c83c3
|
2013-01-31 10:25:20 +08:00
|
|
|
Asset Size Chunks Chunk Names
|
2013-02-24 09:27:11 +08:00
|
|
|
hash.worker.js 561 0 main
|
|
|
|
|
1.hash.worker.js 531 1
|
2013-02-21 03:50:53 +08:00
|
|
|
chunk {0} hash.worker.js (main) 168
|
|
|
|
|
[0] ./worker.js 168 [built] {0}
|
|
|
|
|
chunk {1} 1.hash.worker.js 463 {0}
|
|
|
|
|
[1] ../require.context/templates ^\.\/.*$ 217 [built] {1}
|
2013-02-13 18:58:13 +08:00
|
|
|
amd require context ../require.context/templates [0] ./worker.js 3:1-5:3
|
2013-02-21 03:50:53 +08:00
|
|
|
[2] ../require.context/templates/a.js 82 [built] {1}
|
|
|
|
|
context element ./a [1] ../require.context/templates ^\.\/.*$
|
|
|
|
|
context element ./a.js [1] ../require.context/templates ^\.\/.*$
|
|
|
|
|
[3] ../require.context/templates/b.js 82 [built] {1}
|
|
|
|
|
context element ./b [1] ../require.context/templates ^\.\/.*$
|
|
|
|
|
context element ./b.js [1] ../require.context/templates ^\.\/.*$
|
|
|
|
|
[4] ../require.context/templates/c.js 82 [built] {1}
|
|
|
|
|
context element ./c [1] ../require.context/templates ^\.\/.*$
|
|
|
|
|
context element ./c.js [1] ../require.context/templates ^\.\/.*$
|
2012-08-23 08:05:07 +08:00
|
|
|
```
|