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