Enhance Web Worker federation runtime support#4116
Enhance Web Worker federation runtime support#4116ScriptedAlchemy wants to merge 96 commits intomainfrom
Conversation
- reassign non-initial entrypoints to their own runtime when runtimeChunk is single or object form - add worker demo and cypress assertion covering the web worker bootstrap
🦋 Changeset detectedLatest commit: 823e301 The changes in this PR will be included in the next version bump. This PR includes changesets to release 41 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Deploy Preview for module-federation-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
@codex harshly review the changes here. not completly happy with the solutions applied here. do lots of research and give review comments |
|
Summary
Testing
|
|
@codex harshly review pr |
|
Summary
Testing
|
|
@ScriptedAlchemy this will fix any references to modules via I'm asked because we use custom Worker constructor :/ |
|
Any chance you can send a PR or branch and modify one of our apps in /apps to replicate your needs so I can run against that app within this monorepo |
- Add comprehensive test for webpack worker compilation with Module Federation - Test verifies worker syntax new Worker(new URL()) compiles correctly - Validates federated modules (React, ComponentA) are accessible in worker context - Tests both CommonJS (async-node) and ESM (node14) module outputs - Provides URL to test scope via moduleScope for Node.js targets - All 10 tests pass successfully (5 tests × 2 builds)
Added beforeEach hook to reset React version to '0.1.2' before running worker tests. This prevents test contamination from other container tests (like 1-container-full) that set React version to '3.2.1' and cause the worker test to fail with unexpected version mismatches. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
… cross-context relocation Enhanced runtime chunk detection and federation runtime injection to properly support worker threads. Added safeguards to prevent runtime module relocation between different execution contexts (main thread vs workers). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
…ker demo - Enable runtimeChunk in webpack config to ensure bundler runtime is available - Update WorkerDemo to use WorkerWrapper instead of module worker - This fixes the 'bundler runtime is required to load remote chunk' error in workers
|
@codex review pr deeply |
|
Codex Review: Didn't find any major issues. 👍 ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting |
Remove RUNTIME_INIT_FIX.md as it's internal documentation that shouldn't be in the codebase. The changeset documentation is sufficient for release notes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Adds defensive checks for bundlerRuntime existence before calling remotes() in RemoteRuntimeModule. This prevents TypeError when HMR chunks (like react-refresh-webpack-plugin vendors) are loaded that don't have the federation runtime injected. Fixes blob-based worker HMR scenario reported in issue #4085 where bundlerRuntime.remotes would be undefined in dynamically loaded chunks. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Removes the id-token: write permission requirement that was causing workflow validation errors due to permission restrictions in called workflows. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
@ScriptedAlchemy we've tried test package in production for some time, it seems work well, do you have plans to finish this PR? |
|
Hi @ScriptedAlchemy, I'm reaching out to ask about the status and next steps for merging this PR. Our project relies on the Web Worker fixes in this PR, so we're eager to see it land in main. From my read of the PR and comments: Could you share: It would be great to prioritize this, as it unblocks projects using federation with Web Workers. Let us know how we can help. Thanks for your work on this! |
|
This feature is important for us too. If there’s anything we can do to help move it forward (testing, reviews, changes), we’d be happy to assist. |
# Conflicts: # packages/enhanced/jest.config.ts # packages/enhanced/jest.embed.ts # packages/enhanced/test/compiler-unit/container/HoistContainerReferencesPlugin.test.ts
Bundle Size Report4 package(s) changed, 32 unchanged.
Total dist: 4.96 MB (+4.0 kB (+0.1%)) |
# Conflicts: # pnpm-lock.yaml
# Conflicts: # pnpm-lock.yaml
raven-actions/actionlint@v2 runs npm install internally which fails on pnpm workspace repos due to workspace:* protocol. Switch to direct binary download which has no npm dependency. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
Verification
Resolves #4085.