/
githubmirror
/
webpack
Обзор
Документация
Войти
/
githubmirror
/
webpack
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
examples/module-worker/chat-worker.js
20 строк
442 B
Tobias Koppers
improve module support for WebWorkers
28 июн 2021, 13:30
28 июн 2021, 13:30
0a64c16
Код
Авторство
О чём код?
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; } }; } };