/** * 子线程 * @author yutent * @date 2023/06/14 16:15:39 */ import { parentPort, workerData } from 'node:worker_threads' import { compileFiles } from './compile.js' const { options, verbose, dist, imports } = workerData options.isCustomElement = Function('return ' + options.isCustomElement)() parentPort.once('message', job => { let [currentPage, { page, files }] = job.entries().next().value console.log( currentPage ? `正在生成 ${currentPage}.html ...` : '\n正在解析公共依赖 ...' ) compileFiles(currentPage, page, files, options, { verbose, dist, imports }) parentPort.postMessage('ok') })