The following works without issues:
// main.js
const MyWorker = require('worker!./my-worker');
// my-worker.js
const myModule = require('my-module');
self.onmessage = e => { /* do stuff */ };
However as soon as you start introducing dynamic requires, webpack compilation will enter an infinite loop and eventually run out of memory:
// main.js
const MyWorker = require('worker!./my-worker');
// my-worker.js
self.onmessage = e => {
const myModule = require(e.data.modulePath);
/* do stuff */
};
Am I missing sth obvious, or is it a legitimate bug?
+1 Same issue here. Any developments?