Skip to content

[Bug]: Web worker code produced by rspack will include undefined(undefined) if there are any Module Federation runtime plugins and optimization.usedExports is true. #12605

@dexbol

Description

@dexbol

System Info

System:
OS: macOS 26.2
CPU: (8) arm64 Apple M1
Memory: 96.47 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 24.8.0 - /opt/homebrew/bin/node
Yarn: 1.22.22 - /opt/homebrew/bin/yarn
npm: 11.6.0 - /opt/homebrew/bin/npm
pnpm: 10.22.0 - /opt/homebrew/bin/pnpm
Browsers:
Chrome: 143.0.7499.170
Chrome Canary: 145.0.7610.0
Firefox: 146.0.1
Safari: 26.2
npmPackages:
@rspack/cli: ^1.7 => 1.7.0
@rspack/core: ^1.7 => 1.7.0

Details

Image

Reproduce link

https://github.com/dexbol/test-rspack-module-federation/tree/tree-shaking

Reproduce Steps

  1. Run npm run build.
  2. Open dist/the-worker.js
  3. Search undefined(undefined)

undefined(undefined) will cause the error:

Failed to execute 'importScripts' on 'WorkerGlobalScope':

Metadata

Metadata

Assignees

Labels

pending triageThe issue/PR is currently untouched.

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions