| 
									
										
										
										
											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(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].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: | 
					
						
							|  |  |  | /*!*************************************************************************************************************!*\ | 
					
						
							|  |  |  |   !*** C:/Documents and Settings/kopperts/My Documents/repos/webpack-development/~/worker-loader!./worker.js ***! | 
					
						
							|  |  |  |   \*************************************************************************************************************/ | 
					
						
							|  |  |  | /***/ function(module, exports, require) { | 
					
						
							| 
									
										
										
										
											2012-08-23 08:05:07 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 	module.exports = function() { | 
					
						
							|  |  |  | 		return new Worker(require.modules.c + "ee96caf8cd75d7dfea98abc0dabcc23d.worker.js"); | 
					
						
							|  |  |  | 	}; | 
					
						
							| 
									
										
										
										
											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 | 
					
						
							|  |  |  | /******/(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) { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-07 19:49:01 +08:00
										 |  |  | /**! .\worker.js !**/ | 
					
						
							| 
									
										
										
										
											2012-08-23 08:05:07 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | /******/ /* WEBPACK FREE VAR INJECTION */ (function(require) { | 
					
						
							|  |  |  | onmessage = function(event) { | 
					
						
							|  |  |  | 	var template = event.data; | 
					
						
							| 
									
										
										
										
											2012-11-07 19:49:01 +08:00
										 |  |  | 	require(1, function() { return [require(/*! ../require.context/templates */3)("./" + event.data)]}, function(tmpl) { | 
					
						
							| 
									
										
										
										
											2012-08-23 08:05:07 +08:00
										 |  |  | 		postMessage(tmpl()); | 
					
						
							|  |  |  | 	}); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-07 19:49:01 +08:00
										 |  |  | /******/ /* WEBPACK FREE VAR INJECTION */ }(require(/*! __webpack_amd_require */1))) | 
					
						
							| 
									
										
										
										
											2012-08-23 08:05:07 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | /******/}, | 
					
						
							|  |  |  | /******/ | 
					
						
							|  |  |  | /******/1: function(module, exports, require) { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-07 19:49:01 +08:00
										 |  |  | /**! (webpack)\buildin\__webpack_amd_require.js !**/ | 
					
						
							| 
									
										
										
										
											2012-08-23 08:05:07 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											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]; | 
					
						
							| 
									
										
										
										
											2012-11-07 19:49:01 +08:00
										 |  |  | amdRequire.amd = require(/*! ./__webpack_options_amd.loader.js!./__webpack_options_amd.loader.js */2); | 
					
						
							| 
									
										
										
										
											2012-10-09 06:12:10 +08:00
										 |  |  | amdRequire.config = function() {/* config is ignored, use webpack options */}; | 
					
						
							|  |  |  | module.exports = amdRequire; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-23 08:05:07 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | /******/}, | 
					
						
							|  |  |  | /******/ | 
					
						
							| 
									
										
										
										
											2012-10-26 21:07:50 +08:00
										 |  |  | /******/2: function(module, exports, require) { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-07 19:49:01 +08:00
										 |  |  | /**! (webpack)\buildin\__webpack_options_amd.loader.js!(webpack)\buildin\__webpack_options_amd.loader.js !**/ | 
					
						
							| 
									
										
										
										
											2012-10-26 21:07:50 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* empty to return {} */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /******/} | 
					
						
							| 
									
										
										
										
											2012-08-23 08:05:07 +08:00
										 |  |  | /******/}) | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # Info
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ## Uncompressed
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ``` | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | Hash: 1cc98da1fc32c4cce0b59747baf7d03e | 
					
						
							|  |  |  | Time: 72ms | 
					
						
							|  |  |  |                                          Asset  Size  Chunks  Chunk Names | 
					
						
							|  |  |  |     ee96caf8cd75d7dfea98abc0dabcc23d.worker.js  1701                      | 
					
						
							|  |  |  | [i].ee96caf8cd75d7dfea98abc0dabcc23d.worker.js  1424                      | 
					
						
							|  |  |  |                                      output.js  1774       0  main        | 
					
						
							|  |  |  | chunk    {0} output.js (main) 325 | 
					
						
							|  |  |  |     [0] ./example.js 201 [built] {0} | 
					
						
							|  |  |  |     [1] C:/Documents and Settings/kopperts/My Documents/repos/webpack-development/~/worker-loader!./worker.js 124 [not cacheable] [built] {0} | 
					
						
							|  |  |  |         cjs require worker!./worker [0] ./example.js 1:13-39 | 
					
						
							|  |  |  | Child worker: | 
					
						
							|  |  |  |     Hash: ee96caf8cd75d7dfea98abc0dabcc23d | 
					
						
							|  |  |  |                                              Asset  Size  Chunks  Chunk Names | 
					
						
							|  |  |  |         ee96caf8cd75d7dfea98abc0dabcc23d.worker.js  1701       0  main        | 
					
						
							|  |  |  |     [i].ee96caf8cd75d7dfea98abc0dabcc23d.worker.js  1424       1              | 
					
						
							|  |  |  |     chunk    {0} ee96caf8cd75d7dfea98abc0dabcc23d.worker.js (main) 162 | 
					
						
							|  |  |  |     chunk    {1} [i].ee96caf8cd75d7dfea98abc0dabcc23d.worker.js 457 {0}  | 
					
						
							| 
									
										
										
										
											2012-08-23 08:05:07 +08:00
										 |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ## Minimized (uglify-js, no zip)
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ``` | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | Hash: 1cc98da1fc32c4cce0b59747baf7d03e | 
					
						
							|  |  |  | Time: 168ms | 
					
						
							|  |  |  |                                          Asset  Size  Chunks  Chunk Names | 
					
						
							|  |  |  |     ee96caf8cd75d7dfea98abc0dabcc23d.worker.js   586                      | 
					
						
							|  |  |  | [i].ee96caf8cd75d7dfea98abc0dabcc23d.worker.js   492                      | 
					
						
							|  |  |  |                                      output.js   510       0  main        | 
					
						
							|  |  |  | chunk    {0} output.js (main) 325 | 
					
						
							|  |  |  |     [0] ./example.js 201 [built] {0} | 
					
						
							|  |  |  |     [1] C:/Documents and Settings/kopperts/My Documents/repos/webpack-development/~/worker-loader!./worker.js 124 [not cacheable] [built] {0} | 
					
						
							|  |  |  |         cjs require worker!./worker [0] ./example.js 1:13-39 | 
					
						
							|  |  |  | Child worker: | 
					
						
							|  |  |  |     Hash: ee96caf8cd75d7dfea98abc0dabcc23d | 
					
						
							|  |  |  |                                              Asset  Size  Chunks  Chunk Names | 
					
						
							|  |  |  |         ee96caf8cd75d7dfea98abc0dabcc23d.worker.js   586       0  main        | 
					
						
							|  |  |  |     [i].ee96caf8cd75d7dfea98abc0dabcc23d.worker.js   492       1              | 
					
						
							|  |  |  |     chunk    {0} ee96caf8cd75d7dfea98abc0dabcc23d.worker.js (main) 162 | 
					
						
							|  |  |  |     chunk    {1} [i].ee96caf8cd75d7dfea98abc0dabcc23d.worker.js 457 {0}  | 
					
						
							| 
									
										
										
										
											2012-08-23 08:05:07 +08:00
										 |  |  | ``` |