mirror of https://github.com/webpack/webpack.git
				
				
				
			
		
			
				
	
	
		
			21 lines
		
	
	
		
			442 B
		
	
	
	
		
			JavaScript
		
	
	
	
			
		
		
	
	
			21 lines
		
	
	
		
			442 B
		
	
	
	
		
			JavaScript
		
	
	
	
onconnect = function (e) {
 | 
						|
	for (const port of e.ports) {
 | 
						|
		port.onmessage = async event => {
 | 
						|
			const msg = event.data;
 | 
						|
			switch (msg.type) {
 | 
						|
				case "message":
 | 
						|
					const { add } = await import("./chat-module");
 | 
						|
					add(msg.content, msg.from);
 | 
						|
				// fallthrough
 | 
						|
				case "history":
 | 
						|
					const { history } = await import("./chat-module");
 | 
						|
					port.postMessage({
 | 
						|
						type: "history",
 | 
						|
						history
 | 
						|
					});
 | 
						|
					break;
 | 
						|
			}
 | 
						|
		};
 | 
						|
	}
 | 
						|
};
 |