andywer / threads-plugin

📦 Makes your threads.js code build with webpack out of the box.
Apache License 2.0
28 stars 6 forks source link

Allow thread plugin not to compile node_modules in node application #19

Closed chingyawhao closed 4 years ago

chingyawhao commented 4 years ago

I was looking for a solution to allow me to use webpack-node-externals for threads too Some of the dependencies I used cannot be compiled by webpack

andywer commented 4 years ago

What would be required to make that work? I guess we should allow webpack plugins to be passed to new ThreadsPlugin(), so that they will be applied when bundling the workers (as a webpack child compiler is created to compile the workers, it's not the same instance that compiles the main thread source files).

chingyawhao commented 4 years ago

I'm able to achieve what I wanted using webpack2-externals-plugin and passing it to ThreadsPlugin

new ThreadsPlugin({
  plugins: [
    new ExternalsPlugin({
      type: 'commonjs',
      include: __dirname + '/node_modules',
    })
  ]
})