core icon indicating copy to clipboard operation
core copied to clipboard

Enhance Web Worker federation runtime support

Open ScriptedAlchemy opened this issue 6 months ago • 18 comments

Summary

  • ensure async entrypoints such as Web Workers receive dedicated runtime chunks with the required federation helpers
  • harden remote runtime initialization so dynamically created runtimes do not crash when helpers are missing
  • document the worker demo updates and sync related tests, samples, and release notes

Verification

  • gh pr checks (2025-10-21)
  • reporter confirmed the canary build from this branch resolves issue #4085 on 2025-10-20

Resolves #4085.

ScriptedAlchemy avatar Oct 04 '25 06:10 ScriptedAlchemy

🦋 Changeset detected

Latest commit: 823e3016206500337f165a851d9760a7d4a2ef89

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 41 packages
Name Type
@module-federation/enhanced Patch
@module-federation/modern-js-v3 Patch
@module-federation/modern-js Patch
@module-federation/nextjs-mf Patch
@module-federation/node Patch
@module-federation/rsbuild-plugin Patch
@module-federation/rspress-plugin Patch
@module-federation/storybook-addon Patch
shared-tree-shaking-no-server-host Patch
shared-tree-shaking-no-server-provider Patch
shared-tree-shaking-with-server-host Patch
shared-tree-shaking-with-server-provider Patch
remote5 Patch
remote6 Patch
website-new Patch
@module-federation/runtime Patch
@module-federation/rspack Patch
@module-federation/webpack-bundler-runtime Patch
@module-federation/sdk Patch
@module-federation/runtime-tools Patch
@module-federation/managers Patch
@module-federation/manifest Patch
@module-federation/dts-plugin Patch
@module-federation/third-party-dts-extractor Patch
@module-federation/devtools Patch
@module-federation/bridge-react Patch
@module-federation/bridge-vue3 Patch
@module-federation/bridge-shared Patch
@module-federation/bridge-react-webpack-plugin Patch
@module-federation/retry-plugin Patch
@module-federation/data-prefetch Patch
@module-federation/error-codes Patch
@module-federation/inject-external-runtime-core-plugin Patch
@module-federation/runtime-core Patch
create-module-federation Patch
@module-federation/cli Patch
@module-federation/metro Patch
@module-federation/metro-plugin-rnef Patch
@module-federation/metro-plugin-rnc-cli Patch
@module-federation/esbuild Patch
@module-federation/utilities Patch

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

changeset-bot[bot] avatar Oct 04 '25 06:10 changeset-bot[bot]

Deploy Preview for module-federation-docs ready!

Name Link
Latest commit 823e3016206500337f165a851d9760a7d4a2ef89
Latest deploy log https://app.netlify.com/projects/module-federation-docs/deploys/6986e7c23b9155000851bd2e
Deploy Preview https://deploy-preview-4116--module-federation-docs.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

netlify[bot] avatar Oct 04 '25 06:10 netlify[bot]

@codex harshly review the changes here. not completly happy with the solutions applied here. do lots of research and give review comments

ScriptedAlchemy avatar Oct 05 '25 02:10 ScriptedAlchemy

Summary

  • Added REVIEW.md capturing three blocking concerns: the async runtime detection still ignores manually shared runtimes, runtime naming becomes non-deterministic for anonymous workers, and the remote loader now silently no-ops without the bundler runtime. REVIEW.mdL5-L12
  • Noted the remaining duplication TODO in the worker runtime test suite so it doesn’t get locked in as the expected behaviour. REVIEW.mdL14-L16

Testing

  • ⚠️ not run (review-only change)

View task →

@codex harshly review pr

ScriptedAlchemy avatar Oct 05 '25 02:10 ScriptedAlchemy

Summary

  • Added REVIEW.md outlining three blocking regressions introduced by the worker runtime changes (manual shared runtimes still break, anonymous runtime naming is non-deterministic, and remote loading now silently no-ops without the bundler runtime) plus a reminder to address the duplicated worker test fixture. REVIEW.mdL1-L17

Testing

  • ⚠️ not run (documentation-only change)

View task →

@ScriptedAlchemy this will fix any references to modules via new URL(..., import.meta.url) syntax?

I'm asked because we use custom Worker constructor :/

ogonkov avatar Oct 06 '25 16:10 ogonkov

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

ScriptedAlchemy avatar Oct 06 '25 22:10 ScriptedAlchemy

@ogonkov i updated the pr to include what i think is your use case. can you check

ScriptedAlchemy avatar Oct 07 '25 22:10 ScriptedAlchemy

@codex include changesets for this

ScriptedAlchemy avatar Oct 07 '25 22:10 ScriptedAlchemy

@codex review pr

ScriptedAlchemy avatar Oct 07 '25 22:10 ScriptedAlchemy

Codex Review: Didn't find any major issues. Nice work!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting

  • @codex fix this CI failure
  • @codex address that feedback

Summary

Testing

  • ⚠️ NODE_OPTIONS=--experimental-vm-modules pnpm --filter @module-federation/enhanced exec jest packages/enhanced/test/unit/container/runtime/FederationRuntimePlugin.ensureAsyncEntrypoints.test.ts packages/enhanced/test/compiler-unit/container/FederationRuntimePluginAsyncEntrypoint.test.ts --runInBand (fails because isolated Jest execution cannot resolve @module-federation/sdk/normalize-webpack-path)

View task →

@ScriptedAlchemy i preparing new demo

ogonkov avatar Oct 08 '25 16:10 ogonkov

@ScriptedAlchemy can you publish some test package from this branch? I will try it in out project

ogonkov avatar Oct 09 '25 09:10 ogonkov

@codex review pr deeply

ScriptedAlchemy avatar Oct 17 '25 01:10 ScriptedAlchemy

Codex Review: Didn't find any major issues. :+1:

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting

  • @codex fix this CI failure
  • @codex address that feedback

@ScriptedAlchemy we've tried test package in production for some time, it seems work well, do you have plans to finish this PR?

ogonkov avatar Dec 09 '25 08:12 ogonkov

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: - It looks like it solves the core issue (#4085) and has been tested successfully in production (as mentioned by @ogonkov). - The REVIEW.md file lists a few blocking items (async runtime detection, runtime naming, remote loader behavior). - The Codex review didn't flag major issues.

Could you share: - What’s needed to resolve the remaining REVIEW.md items? - Is there a rough timeline or milestone for merging this? - Can we help with testing, documentation, or specific changes to move this forward?

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!

IO-an avatar Jan 28 '26 08:01 IO-an

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.

mfyodorov avatar Feb 02 '26 17:02 mfyodorov

Bundle Size Report

4 package(s) changed, 32 unchanged.

Package Total dist Delta ESM gzip Delta
webpack-bundler-runtime 76.5 kB +2.5 kB (+3.3%) 5.9 kB +49 B (+0.8%)
enhanced 1.29 MB +937 B (+0.1%) 744 B no change
managers 39.3 kB +482 B (+1.2%) 3.4 kB +28 B (+0.8%)
runtime 15.6 kB +196 B (+1.2%) 769 B +11 B (+1.5%)

Total dist: 4.96 MB (+4.0 kB (+0.1%)) Total ESM gzip: 154.7 kB (+88 B (+0.1%))

github-actions[bot] avatar Feb 06 '26 00:02 github-actions[bot]