Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails when a depedency (module) requires a webpack "external" module #22

Open
Place1 opened this issue Feb 14, 2018 · 3 comments
Open
Labels
help wanted Extra attention is needed question Further information is requested

Comments

@Place1
Copy link

Place1 commented Feb 14, 2018

Awesome library! I've just found an edge case when workerizing a module that depends on a webpack external.

In my webpack config i have:

module.exports = {
  // ...
  externals: {
    'config': JSON.stringify(config),
  },
  // ...
}

and in my worker module I have:

import * as config from 'config';

I'm using typescript in case that matters.

Here's the compilation error from webpack:

Module not found: Error: Can't resolve 'config' in '/directory/src'
 @ ./src/MyWorker.ts 1:0-33
@developit
Copy link
Owner

This is likely an issue with Webpack not passing externals to child Compiler instances.

@zhaoyao91
Copy link

is there any solution for this case? in electron, worker should have the same externals with the renderer

@developit
Copy link
Owner

If someone wants to open a PR that copies compiler.options.external to the ChildCompiler instance that should fix the Webpack error here.

Personally I'm not sure externals in the Worker compiler actually make sense: any values declared as external are unlikely to be available in the Worker context. Generally they're values defined by other scripts on the main thread, and those aren't automatically run in a Worker too.

Perhaps I'm not thinking about this correctly though, if anyone has a bit more detail on what they're wanting this for I'm all ears!

@developit developit added help wanted Extra attention is needed question Further information is requested labels Feb 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants