App source (main/preload/worker/renderer) -> ESM; app is now type: module; __dirname via import.meta.url; worker spawned with type module. Preload is built as CJS (electron-vite output format) because the sandboxed renderer does not support ESM preload; main loads ../preload/index.js. Removed dead imports (nativeImage, readline) and the obsolete scripts/dev.js. Tests: 4 app tests require->import; app-main-settings rewritten with node:test mock.module + dynamic import (replacing CJS Module._load mocking); test script adds --experimental-test-module-mocks. electron-vite build clean, 119/119, and npm run dev verified: app launches, preload bridges IPC, data loads.
18 lines
393 B
JavaScript
18 lines
393 B
JavaScript
import { parentPort } from 'node:worker_threads';
|
|
import { buildIndex } from './indexer.js';
|
|
|
|
parentPort.on('message', ({ id, args }) => {
|
|
try {
|
|
const result = buildIndex(args || {});
|
|
parentPort.postMessage({ id, result });
|
|
} catch (error) {
|
|
parentPort.postMessage({
|
|
id,
|
|
error: {
|
|
message: error.message,
|
|
stack: error.stack,
|
|
},
|
|
});
|
|
}
|
|
});
|