parallel-plugin-worker.mjs 1.2 KB

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