parallel-plugin-worker.mjs 1.1 KB

12345678910111213141516171819202122232425262728
  1. import { n as __toESM, t as require_binding } from "./shared/binding-s-V_wTpj.mjs";
  2. import { n as PluginContextData, r as bindingifyPlugin } from "./shared/bindingify-input-options-DYpBf1OG.mjs";
  3. import { parentPort, workerData } from "node:worker_threads";
  4. //#region src/parallel-plugin-worker.ts
  5. var import_binding = /* @__PURE__ */ __toESM(require_binding(), 1);
  6. const { registryId, pluginInfos, threadNumber } = workerData;
  7. (async () => {
  8. try {
  9. (0, import_binding.registerPlugins)(registryId, await Promise.all(pluginInfos.map(async (pluginInfo) => {
  10. const definePluginImpl = (await import(pluginInfo.fileUrl)).default;
  11. const plugin = await definePluginImpl(pluginInfo.options, { threadNumber });
  12. return {
  13. index: pluginInfo.index,
  14. plugin: bindingifyPlugin(plugin, {}, {}, new PluginContextData(() => {}, {}, [], []), [], () => {}, "info", false)
  15. };
  16. })));
  17. parentPort.postMessage({ type: "success" });
  18. } catch (error) {
  19. parentPort.postMessage({
  20. type: "error",
  21. error
  22. });
  23. } finally {
  24. parentPort.unref();
  25. }
  26. })();
  27. //#endregion
  28. export {};