andywer / threads-plugin

📦 Makes your threads.js code build with webpack out of the box.
Apache License 2.0
28 stars 6 forks source link

webpack electron react issues #36

Open ghost opened 3 years ago

ghost commented 3 years ago
expose() called in the master thread.

I believe the issue is since its compiling my electron main file and the worker file all in one file it's yelling at me since its all on the master thread or am i incorrect?

main.ts

async function test() {
  const auth = await spawn(new Worker("./workers/worker.ts", { type: 'module' }))
  const hashed = await auth.hashPassword("Super secret password", "1234")

  console.log("Hashed password:", hashed)
  await Thread.terminate(auth)
}

test().catch(console.error)

worker.ts

import { expose } from "threads/worker";

export const newtest = () => { console.log('creating file') }

const hashPassword = (testm, ag) => {
  return 'yes running'
}

expose(hashPassword)
andywer commented 3 years ago

Hey @MrSirDev. How do you mean "since its compiling my electron main file and the worker file all in one file"? What does your build process look like?