Skip to content

Odd interaction between sideEffects:false and a Worker #12646

@RReverser

Description

@RReverser

Bug report

Check out this Glitch example with a simplified repro: https://glitch.com/edit/#!/grass-northern-xenon

Here, I'm using a Worker that shares some code with the main thread, but I'm also using sideEffects: false in package.json.

(In the original code the latter is auto-generated by 3rd-party tooling, but it's not important)

What is the current behavior?

The main thread is bundled correctly, but the import in the Worker resolves to undefined and throws when optimizations are enabled.

This doesn't happen when I change sideEffects to true. Maybe this makes it somehow expected behaviour, but it seems odd that Worker code is still correctly included (after all, the only purpose of Workers is to perform side-effects), it's just the import that doesn't resolve.

What is the expected behavior?

The import in Worker should resolve to actual function foo.

Other relevant information:
webpack version: 5.21.2

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions