Skip to content

Self-reference dependency has unused export name when imported inside of a web worker #18315

@pgoldberg

Description

@pgoldberg

Bug report

What is the current behavior?

When a web worker imports a CommonJS module with a self reference dependency, webpack throws Error: Self-reference dependency has unused export name: This should not happen.

This happens when usedExports is set to "global".

I think this is related:
#12646 / #12648

It seems like that fix works when usedExports is not set to "global", but it doesn't work when usedExports: "global" is set.

If the current behavior is a bug, please provide the steps to reproduce.

Repro: https://github.com/pgoldberg/webpack-self-reference-dependency-worker-bug

What is the expected behavior?

Webpack should not throw an error

Other relevant information:
webpack version: 5.91.0
Node.js version: any
Operating System: any
Additional tools:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Priority - High

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions