
//ignore for WEBPACK build:
if(typeof WEBPACK_BUILD === 'undefined'  || !WEBPACK_BUILD){

	// global.WEBPACK_BUILD = true;
	var worker_threads = require('worker_threads');
	var parentPort = worker_threads.parentPort;
	global.self = this;
	self.isMainThread = worker_threads.isMainThread;

	// var destroyed = false;
	// parentPort.on('exit', function(){
	// 	log('## [worker_threads::onexit] ')
	// 	destroyed = true;
	// });
	// parentPort.on('error', function(err){
	// 	log('## [worker_threads::onerr] ', err);
	// });
	//
	// var log = function(){
	// 	try{
	// 		console.log.apply(console, arguments);
	// 	} catch(_err){}
	// }

	Object.defineProperty(global.self, 'onmessage', {
		set: function(func){
			parentPort.on('message', function(data){
				// if(!destroyed) log('## [worker_threads::onmessage] ', data);
				func.call(global, {data: data});
			});
		}
	});
	self.postMessage = function(data){
		// if(!destroyed) log('## [worker_threads::postMessage] ', data);
		parentPort.postMessage(data);
	};

	var path = require('path');

	global.importScripts = function(){
		var p;
		for(var i=0, size = arguments.length; i < size; ++i){
			p = arguments[i];
			if(!path.isAbsolute(p) && !/^[^/]+:\/\//.test(p)){
				p = path.join(__dirname, p);
			}
			require(p);
		}
	}

}

@@ -92,42 +92,8 @@
 %0D%0A%0D%0A
-%09// global.WEBPACK_BUILD = true;%0D%0A
 %09var
@@ -692,24 +692,342 @@
 ion(func)%7B%0D%0A
+%09%09%09//simulate setting onmessage callback:%0D%0A%09%09%09if(parentPort.removeAllListeners)%7B%0D%0A%09%09%09%09//onmessage hook is %22singleton%22 -%3E remove any previously registered listeners%0D%0A%09%09%09%09parentPort.removeAllListeners('message');%0D%0A%09%09%09%7D%0D%0A%09%09%09//only register, if TRUTHY (i.e. interpret FALSY as %22unregister listener/hook%22):%0D%0A%09%09%09if(func)%7B%0D%0A%09
 %09%09%09parentPor
@@ -1055,24 +1055,25 @@
 ion(data)%7B%0D%0A
+%09
 %09%09%09%09// if(!d
@@ -1133,16 +1133,17 @@
 );%0D%0A%09%09%09%09
+%09
 func.cal
@@ -1171,21 +1171,28 @@
 %7D);%0D%0A%09%09%09
+%09
 %7D);%0D%0A
+%09%09%09%7D%0D%0A
 %09%09%7D%0D%0A%09%7D)

FIX implement remove-listener for onmessage-hook implementation