-
-
Notifications
You must be signed in to change notification settings - Fork 373
Fix worker runtime chunk regressing web worker builds #4116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
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: 8bdbc3d The changes in this PR will be included in the next version bump. This PR includes changesets to release 36 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
- Run nx format:write to fix formatting issues in new worker wrapper files - This resolves the checkout-install failure in CI
- Restore enhanced test configCases node_modules mocks (react, package.json, etc.) - Restore docs troubleshooting pages and esbuild app scripts - Fixes CI checkout-install React resolution failures and Netlify docs checks
…pts on TS dev URL
… satisfy shared fallback
…d dev TS importScripts failure
…works in dev/e2e; remove Cypress skip
This pull request enhances support for Web Worker and other dynamic entrypoints in the module federation runtime, ensuring that async entry runtime helpers are available when cloning runtimes. It introduces new logic in the runtime plugin to correctly handle dedicated runtimes for async entrypoints, adds thorough testing for these scenarios, and demonstrates the feature with a new worker-based integration test and demo. The changes also include improvements to the runtime module code generation and relevant updates to demo and test files.
Enhancements to async entrypoint and Web Worker runtime support:
FederationRuntimePlugin
to ensure that async entrypoints (such as Web Workers) receive dedicated runtime chunks, cloning necessary runtime modules and requirements from shared runtime chunks. This prevents missing runtime helpers in dynamically loaded contexts. [1] [2] [3]RemoteRuntimeModule
to initialize federation globals and options more robustly, and to conditionally invoke remote runtime helpers only if available, improving safety and compatibility for dynamic runtimes. [1] [2]Testing and verification:
Demo and Cypress integration:
WorkerDemo
React component and corresponding Cypress test to verify correct worker behavior in the browser. [1] [2] [3] [4] [5] [6]Configuration and documentation:
.changeset
entry describing the patch and updated the demo app's webpack configuration to ensure compatibility with the new runtime logic. [1] [2]These changes collectively improve the reliability and flexibility of module federation in environments with dynamic entrypoints such as Web Workers.
fixes #4085