I'm trying to work with web workers and I need to be able to import dynamically classic scripts and also modules scripts. So I need to do something like this:
new Worker("worker1.js", { type: "module" });
In my worker :
importScripts('/scripts/classic.js');
import('/scripts/module.js').then((module) => {
// Something
});
The problem is that it seems impossible to use importScripts in a module worker since I get the following error: Failed to execute 'importScripts' on 'WorkerGlobalScope': Module scripts don't support importScripts()
Would there be a solution to do what I want or I am forced to choose between importing classic scripts or importing modules scripts ?