Skip to content

Prefer worker condition for web-workers #7439

@stevemk14ebr

Description

@stevemk14ebr

Clear and concise description of the problem

Please refer to the webpack issue here: webpack/webpack#14681. In short, when resolving a module that is used within a webworker, try fields worker or webworker before browser. This helps libraries seperate browser DOM api code from code that also runs in the browser, but does not have DOM api access. To do this now, users must configure like so:

  resolve: {
	  conditions: ['worker', 'webworker']
  }

I suggest this be done automatically.

For libraries such as this that need to choose a different conditional export based upon usage.
wooorm/parse-entities#19

Suggested solution

First try worker or webworker fields if the module is imported from a webworker.

Alternative

No response

Additional context

No response

Validations

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions