Skip to content

Webpack 5: Library build with WebWrokers does not work with applications that are dependent on it #12719

Closed
@tsarapke

Description

@tsarapke

Bug report

What is the current behavior?

We have a core library based on React, that used among several applications that built on top of react-scripts.
Our library contain various heavy computations that used among our applications.
Adding new Worker construction in library, produces additional chunk in build result (what is quite expected). But when using component from a library that uses this WebWorker does not load worker script (a chunk from library). The WebWorker chunk does not exist in project build.

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

  1. Download project: https://github.com/tsarapke/proj.git. It use a library with WebWorker: https://github.com/tsarapke/lib
  2. yarn install
  3. yarn start

image

What is the expected behavior?

Project build should contain WebWorker chunk from a library.
In accordance with provided example - it should print 'Hello World' in console when WebWorker post message.

Other relevant information:
webpack version: webpack version: 5.22.0
Node.js version: v14.15.5
Operating System: Win10
Additional tools: Yarn

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