Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/master/implementation.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,13 @@ function initWorkerThreadsWorker(): ImplementationExport {
} else if (resolvedScriptPath.match(/\.tsx?$/i) && detectTsNode()) {
super(createTsNodeModule(resolvedScriptPath), { ...options, eval: true })
} else if (resolvedScriptPath.match(/\.asar[\/\\]/)) {
// See <https://github.com/andywer/threads-plugin/issues/17>
super(resolvedScriptPath.replace(/\.asar([\/\\])/, ".asar.unpacked$1"), options)
const electronPath =
options?.electronAsarUnpacked === false
? resolvedScriptPath
// See <https://github.com/andywer/threads-plugin/issues/17>
: resolvedScriptPath.replace(/\.asar([\/\\])/, ".asar.unpacked$1")

super(electronPath, options)
} else {
super(resolvedScriptPath, options)
}
Expand Down
4 changes: 4 additions & 0 deletions src/types/master.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ export interface ThreadsWorkerOptions extends WorkerOptions {
/** Data passed on to node.js worker_threads. */
workerData?: any

/** If Electron workers should use the asar.unpacked path. Default to true.
* See <https://github.com/andywer/threads-plugin/issues/17> */
electronAsarUnpacked?: boolean

/** Whether to apply CORS protection workaround. Defaults to true. */
CORSWorkaround?: boolean
}
Expand Down