22 lines
652 B
JavaScript
22 lines
652 B
JavaScript
/**
|
|
* 子线程
|
|
* @author yutent<yutent.io@gmail.com>
|
|
* @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')
|
|
})
|