Is your feature request related to a problem? Please describe.
Based on the current documentation listed here, it doesn't seem possible to specify a transferList on the Worker constructor. This prohibits passing transferList items such as MessagePort. Attempts to pass a MessagePort within the Workers workerData currently results in the following error.
TypeError: MessagePort was found in message but not listed in transferList
Describe the solution you'd like
Given the current error, and if its technically feasible to do so...being able to supply a transferList on the Worker constructor would be helpful in initializing the Worker immediately with a MessagePort rather than sending the MessagePort on a subsequent postMessage(...). Perhaps something like the following could be allowed.
const channel = new MessageChannel()
const workerData = { port: channel.port1 }
const transferList = [channel.port1]
const worker = new Worker('./worker.js', { workerData, transferList })
Describe alternatives you've considered
It is entirely possible to work around this by sending a MessagePort in a subsequent postMessage(..., transferList). However it doing so involves async initialization of the Worker which is less desirable than initializing immediately on the Worker constructor.
can I work on this one?
Most helpful comment
can I work on this one?