{"action":"closed","issue":{"url":"https://api.github.com/repos/webpack-contrib/worker-loader/issues/26","repository_url":"https://api.github.com/repos/webpack-contrib/worker-loader","labels_url":"https://api.github.com/repos/webpack-contrib/worker-loader/issues/26/labels{/name}","comments_url":"https://api.github.com/repos/webpack-contrib/worker-loader/issues/26/comments","events_url":"https://api.github.com/repos/webpack-contrib/worker-loader/issues/26/events","html_url":"https://github.com/webpack-contrib/worker-loader/issues/26","id":161940782,"number":26,"title":"Loading workers doesn't work at all without inline mode","user":{"login":"Zacqary","id":1445834,"avatar_url":"https://avatars0.githubusercontent.com/u/1445834?v=4","gravatar_id":"","url":"https://api.github.com/users/Zacqary","html_url":"https://github.com/Zacqary","followers_url":"https://api.github.com/users/Zacqary/followers","following_url":"https://api.github.com/users/Zacqary/following{/other_user}","gists_url":"https://api.github.com/users/Zacqary/gists{/gist_id}","starred_url":"https://api.github.com/users/Zacqary/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zacqary/subscriptions","organizations_url":"https://api.github.com/users/Zacqary/orgs","repos_url":"https://api.github.com/users/Zacqary/repos","events_url":"https://api.github.com/users/Zacqary/events{/privacy}","received_events_url":"https://api.github.com/users/Zacqary/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-06-23T14:44:29Z","updated_at":"2017-10-12T11:51:48Z","closed_at":"2017-10-12T11:51:48Z","author_association":"NONE","body":"I've only been able to get the Worker Loader to work in inline mode. Compiling worker files separately results in the worker immediately triggering its `onerror` event — except `event.message` is undefined. No code inside the worker's .js file appears to be executed. I've even tried commenting out the entirety of a worker file save for a single `console.log` statement, and this doesn't execute either.\n\nMy Webpack config includes:\n\n```\npostLoaders: [{\n    test: /\\.worker\\.js$/,\n    loader: \"worker-loader?inline=true\"\n}],\n```\n\nwhen it works. Changing `loader` to `\"worker-loader\"` causes the failure.\n\nI'm using these helper functions to interact with workers:\n\n``` javascript\n//callWorker.js\n\n// Returns a promise that resolves after a web worker sends its next message\nexport function nextWorkerMessage(worker, terminate = false) {\n    return new Promise((resolve, reject) => {\n        worker.onmessage = ({data}) => {\n            worker.onmessage = null;\n            worker.onerror = null;\n            if (terminate) worker.terminate();\n            resolve(data);\n        };\n        worker.onerror = ({message}) => {\n            worker.onmessage = null;\n            worker.onerror = null;\n            worker.terminate();\n            reject(message);\n        };\n    });\n}\n\n// Create a new web worker from a constructor, then pass the args in a\n// postMessage. Returns a promise that resolves after its next message, and\n// then terminates the worker.\nexport default function callWorker(workerConstructor, ...args) {\n    let worker = new workerConstructor();\n    const promise = nextWorkerMessage(worker, true);\n    const message = [...args];\n    // If there are multiple args, pass them as an array. If there's\n    // only one, pass it by itself\n    if (message.length > 1) {\n        worker.postMessage([...args]);\n    } else {\n        worker.postMessage(args[0]);\n    }\n    return promise;\n}\n```\n\nAnd then in my app, something like this:\n\n``` javascript\nimport callWorker from \"callWorker\";\nimport MyWorker from \"myWorker.worker.js\"; // Webpack is configured to load this with worker-loader\n\nasync function mainFn() {\n    const result = await callWorker(MyWorker, \"Send this message\");\n}\n```\n\nAll of this works fine in inline mode, but disabling inline mode causes it to fail. I've even tried directly importing `MyWorker` in the same file where `callWorker` is defined to see if that cleared things up, but it didn't.\n\nI'm not really sure how to go about debugging this further.\n"}}
{"actor":{"display_login":"michael-ciniawsky"}}