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
|
|
|
|
|
/******/(function(modules) {
|
|
|
|
|
/******/ var installedModules = {};
|
|
|
|
|
/******/ function require(moduleId) {
|
|
|
|
|
/******/ if(typeof moduleId !== "number") throw new Error("Cannot find module '"+moduleId+"'");
|
|
|
|
|
/******/ if(installedModules[moduleId])
|
|
|
|
|
/******/ return installedModules[moduleId].exports;
|
|
|
|
|
/******/ var module = installedModules[moduleId] = {
|
|
|
|
|
/******/ exports: {},
|
|
|
|
|
/******/ id: moduleId,
|
|
|
|
|
/******/ loaded: false
|
|
|
|
|
/******/ };
|
|
|
|
|
/******/ modules[moduleId](module, module.exports, require);
|
|
|
|
|
/******/ module.loaded = true;
|
|
|
|
|
/******/ return module.exports;
|
|
|
|
|
/******/ }
|
|
|
|
|
/******/ require.e = function(chunkId, callback) {
|
|
|
|
|
/******/ callback(require);
|
|
|
|
|
/******/ };
|
|
|
|
|
/******/ require.modules = modules;
|
|
|
|
|
/******/ require.cache = installedModules;
|
|
|
|
|
/******/ return require(0);
|
|
|
|
|
/******/})
|
|
|
|
|
/******/({c:"",
|
|
|
|
|
/******/0: function(module, exports, require) {
|
|
|
|
|
|
|
|
|
|
/*** .\example.js ***/
|
|
|
|
|
|
|
|
|
|
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: function(module, exports, require) {
|
|
|
|
|
|
|
|
|
|
/*** (webpack)\~\worker-loader!.\worker.js ***/
|
|
|
|
|
|
|
|
|
|
module.exports = function() {
|
|
|
|
|
return new Worker((require.modules.c||'') + "hash.worker.js");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/******/},
|
|
|
|
|
/******/
|
|
|
|
|
/******/})
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
# js/[hash].worker.js
|
|
|
|
|
|
|
|
|
|
``` javascript
|
|
|
|
|
/******/(function(modules) {
|
|
|
|
|
/******/ var installedModules = {}, installedChunks = {0:1};
|
|
|
|
|
/******/ function require(moduleId) {
|
|
|
|
|
/******/ if(typeof moduleId !== "number") throw new Error("Cannot find module '"+moduleId+"'");
|
|
|
|
|
/******/ if(installedModules[moduleId])
|
|
|
|
|
/******/ return installedModules[moduleId].exports;
|
|
|
|
|
/******/ var module = installedModules[moduleId] = {
|
|
|
|
|
/******/ exports: {},
|
|
|
|
|
/******/ id: moduleId,
|
|
|
|
|
/******/ loaded: false
|
|
|
|
|
/******/ };
|
|
|
|
|
/******/ modules[moduleId](module, module.exports, require);
|
|
|
|
|
/******/ module.loaded = true;
|
|
|
|
|
/******/ return module.exports;
|
|
|
|
|
/******/ }
|
|
|
|
|
/******/ require.e = function(chunkId, callback) {
|
|
|
|
|
/******/ if(installedChunks[chunkId] === 1) return callback(require);
|
|
|
|
|
/******/ importScripts(chunkId+modules.a);
|
|
|
|
|
/******/ callback(require);
|
|
|
|
|
/******/ };
|
|
|
|
|
/******/ require.modules = modules;
|
|
|
|
|
/******/ require.cache = installedModules;
|
|
|
|
|
/******/ this[modules.b] = function(chunkId, moreModules) {
|
|
|
|
|
/******/ for(var moduleId in moreModules)
|
|
|
|
|
/******/ modules[moduleId] = moreModules[moduleId];
|
|
|
|
|
/******/ installedChunks[chunkId] = 1;
|
|
|
|
|
/******/ };
|
|
|
|
|
/******/ return require(0);
|
|
|
|
|
/******/})
|
|
|
|
|
/******/({a:".hash.worker.js",b:"webpackJsonp",c:"",
|
|
|
|
|
/******/0: function(module, exports, require) {
|
|
|
|
|
|
|
|
|
|
/*** .\worker.js ***/
|
|
|
|
|
|
|
|
|
|
/******/ /* WEBPACK FREE VAR INJECTION */ (function(require) {
|
|
|
|
|
onmessage = function(event) {
|
|
|
|
|
var template = event.data;
|
|
|
|
|
require(1, function() { return [require(/* ../require.context/templates */2)("./" + event.data)]}, function(tmpl) {
|
|
|
|
|
postMessage(tmpl());
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-09 06:12:10 +08:00
|
|
|
/******/ /* WEBPACK FREE VAR INJECTION */ }(require(/* __webpack_amd_require */1)))
|
2012-08-23 08:05:07 +08:00
|
|
|
|
|
|
|
|
/******/},
|
|
|
|
|
/******/
|
|
|
|
|
/******/1: function(module, exports, require) {
|
|
|
|
|
|
|
|
|
|
/*** (webpack)\buildin\__webpack_amd_require.js ***/
|
|
|
|
|
|
2012-10-09 06:12:10 +08:00
|
|
|
var req = require.valueOf();
|
|
|
|
|
function amdRequire(chunk, requiresFn, fn) {
|
|
|
|
|
if(!requiresFn) {
|
|
|
|
|
// commonjs
|
|
|
|
|
return req(chunk);
|
2012-08-23 08:05:07 +08:00
|
|
|
}
|
2012-10-09 06:12:10 +08:00
|
|
|
req.e(chunk, function() {
|
|
|
|
|
var modules = requiresFn();
|
|
|
|
|
if(fn)
|
|
|
|
|
return fn.apply(null, modules);
|
|
|
|
|
});
|
2012-08-23 08:05:07 +08:00
|
|
|
}
|
2012-10-09 06:12:10 +08:00
|
|
|
for(var name in req)
|
|
|
|
|
amdRequire[name] = req[name];
|
|
|
|
|
amdRequire.amd = {};
|
|
|
|
|
amdRequire.config = function() {/* config is ignored, use webpack options */};
|
|
|
|
|
module.exports = amdRequire;
|
|
|
|
|
|
2012-08-23 08:05:07 +08:00
|
|
|
|
|
|
|
|
/******/},
|
|
|
|
|
/******/
|
|
|
|
|
/******/})
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
# Info
|
|
|
|
|
|
|
|
|
|
## Uncompressed
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
Hash: 9a3fb6bf1155fd1c85b5a003f0e9fe77
|
2012-10-09 23:17:38 +08:00
|
|
|
Compile Time: 68ms
|
2012-08-23 08:05:07 +08:00
|
|
|
Chunks: 1
|
|
|
|
|
Modules: 2
|
|
|
|
|
Modules including duplicates: 2
|
|
|
|
|
Modules first chunk: 2
|
2012-10-09 06:12:10 +08:00
|
|
|
main output.js: 1354 chars/bytes
|
|
|
|
|
1.hash.worker.js: 1105 chars/bytes
|
|
|
|
|
hash.worker.js: 2239 chars/bytes
|
2012-08-23 08:05:07 +08:00
|
|
|
|
|
|
|
|
<id> <size> <filename>
|
|
|
|
|
<reason> from <filename>
|
|
|
|
|
output.js
|
|
|
|
|
0 211 .\example.js
|
|
|
|
|
main
|
|
|
|
|
1 96 (webpack)\~\worker-loader!.\worker.js
|
|
|
|
|
require (1x) from .\example.js
|
|
|
|
|
Embedded Stats
|
|
|
|
|
.\worker.js
|
2012-10-09 06:12:10 +08:00
|
|
|
Hash: 6ce2177a70a0741653c759ba5e3e684f
|
2012-10-09 23:17:38 +08:00
|
|
|
Compile Time: 26ms
|
2012-08-23 08:05:07 +08:00
|
|
|
Chunks: 2
|
|
|
|
|
Modules: 6
|
|
|
|
|
Modules including duplicates: 6
|
|
|
|
|
Modules first chunk: 2
|
|
|
|
|
|
|
|
|
|
<id> <size> <filename>
|
|
|
|
|
<reason> from <filename>
|
|
|
|
|
hash.worker.js
|
|
|
|
|
0 211 .\worker.js
|
|
|
|
|
main
|
2012-10-09 06:12:10 +08:00
|
|
|
1 437 (webpack)\buildin\__webpack_amd_require.js
|
2012-08-23 08:05:07 +08:00
|
|
|
require (1x) from .\worker.js
|
|
|
|
|
1.hash.worker.js
|
|
|
|
|
2 300 [context] (webpack)\examples\require.context\templates
|
|
|
|
|
async context from .\worker.js
|
|
|
|
|
3 82 (webpack)\examples\require.context\templates\a.js
|
|
|
|
|
async context from .\worker.js
|
|
|
|
|
4 82 (webpack)\examples\require.context\templates\b.js
|
|
|
|
|
async context from .\worker.js
|
|
|
|
|
5 82 (webpack)\examples\require.context\templates\c.js
|
|
|
|
|
async context from .\worker.js
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Minimized (uglify-js, no zip)
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
Hash: 7c6135cf8b61087ca531a96e890b8f01
|
2012-10-09 23:24:06 +08:00
|
|
|
Compile Time: 175ms
|
2012-08-23 08:05:07 +08:00
|
|
|
Chunks: 1
|
|
|
|
|
Modules: 2
|
|
|
|
|
Modules including duplicates: 2
|
|
|
|
|
Modules first chunk: 2
|
2012-10-09 06:12:10 +08:00
|
|
|
main output.js: 477 chars/bytes
|
|
|
|
|
1.hash.worker.js: 473 chars/bytes
|
|
|
|
|
hash.worker.js: 781 chars/bytes
|
2012-08-23 08:05:07 +08:00
|
|
|
|
|
|
|
|
<id> <size> <filename>
|
|
|
|
|
<reason> from <filename>
|
|
|
|
|
output.js
|
|
|
|
|
0 106 .\example.js
|
|
|
|
|
main
|
|
|
|
|
1 86 (webpack)\~\worker-loader!.\worker.js
|
|
|
|
|
require (1x) from .\example.js
|
|
|
|
|
Embedded Stats
|
|
|
|
|
.\worker.js
|
2012-10-09 06:12:10 +08:00
|
|
|
Hash: 32b01b30a4148ab0f233c37f6b7dcbc9
|
2012-10-09 23:24:06 +08:00
|
|
|
Compile Time: 115ms
|
2012-08-23 08:05:07 +08:00
|
|
|
Chunks: 2
|
|
|
|
|
Modules: 6
|
|
|
|
|
Modules including duplicates: 6
|
|
|
|
|
Modules first chunk: 2
|
|
|
|
|
|
|
|
|
|
<id> <size> <filename>
|
|
|
|
|
<reason> from <filename>
|
|
|
|
|
hash.worker.js
|
|
|
|
|
0 120 .\worker.js
|
|
|
|
|
main
|
2012-10-09 06:12:10 +08:00
|
|
|
1 253 (webpack)\buildin\__webpack_amd_require.js
|
2012-08-23 08:05:07 +08:00
|
|
|
require (1x) from .\worker.js
|
|
|
|
|
1.hash.worker.js
|
|
|
|
|
2 228 [context] (webpack)\examples\require.context\templates
|
|
|
|
|
async context from .\worker.js
|
|
|
|
|
3 72 (webpack)\examples\require.context\templates\a.js
|
|
|
|
|
async context from .\worker.js
|
|
|
|
|
4 72 (webpack)\examples\require.context\templates\b.js
|
|
|
|
|
async context from .\worker.js
|
|
|
|
|
5 72 (webpack)\examples\require.context\templates\c.js
|
|
|
|
|
async context from .\worker.js
|
|
|
|
|
```
|