UNPKG

@wii/fastify-webpack

Version:

fastify plugin for webpack

24 lines (20 loc) 742 B
"use strict"; require("core-js/modules/es.promise.js"); // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore const hot = import.meta.webpackHot || module.hot; const eventSource = new EventSource('/__fastify_webpack_hot'); eventSource.addEventListener('sync', async event => { const syncEvent = JSON.parse(event.data); // console.log(syncEvent); console.log('[fastify-webpack] bundle updated %s', syncEvent.hash); if ((hot === null || hot === void 0 ? void 0 : hot.status()) === 'idle') { try { await hot.check(true); } catch (error) { console.error(error); console.error('[fastify-webpack] could not complete check, full reload page'); window.location.reload(); } } });