How to include a worker/process file with webpack

Viewed 721

I have a file that creates child processes, the code is similar to this:

var cp = require('child_process');

function process () {
  return cp.fork('./worker');
}

module.exports(process);

But ./worker doesn't seem to be included in the bundle. Which causes the following error when running the process function:

Error: Cannot find module 'C:\Users\USER\Documents\GitHub\PROJECT\worker'
    at Function.Module._resolveFilename (module.js:485:15)
    at Function.Module._load (module.js:437:25)
    at Function.Module.runMain (module.js:605:10)
    at startup (bootstrap_node.js:158:16)
    at bootstrap_node.js:575:3
module.js:487
    throw err;
    ^

How can I make sure worker files are bundled as well? I want my whole project in óne file.

1 Answers
Related