Skip to content

perf: slim deps - #4897

Merged
2heal1 merged 3 commits into
mainfrom
perf/replace-lru-cache-upath
Jul 14, 2026
Merged

2heal1 merged 3 commits into
mainfrom
perf/replace-lru-cache-upath

Conversation

@2heal1

@2heal1 2heal1 commented Jul 14, 2026 •

Copy link
Copy Markdown
Member

Description

This PR reduces package size and dependency installation cost by replacing several general-purpose dependencies with small internal implementations.

Key changes:

  • Replace lru-cache with a lightweight size-limited cache.
  • Replace upath, semver, node-schedule, empathic, and exsolve.
  • Remove unused @modern-js/utils.
  • Remove react-error-boundary and provide a small internal error boundary.
  • Remove node-fetch from the Modern.js integrations and set their minimum Node.js version to 18.
  • Preserve the existing public entry points and expected behavior.
  • Add tests for cache eviction, version detection, scheduling, package lookup, module resolution, and error recovery.

Bundle size impact

The latest GitHub bundle-size report for commit 8352c8e compares this PR against the current main branch. Both sides are built separately, minified, and measured with gzip.

Area Current size Change
Total built output 35.67 MB -579,389 B (-1.5%)
Total ESM gzip 102.0 kB -21,448 B (-17.0%)
Total web bundle gzip 229.7 kB -23,840 B (-9.2%)
Total Node bundle gzip 232.3 kB -24,010 B (-9.2%)
bridge-react built output 266.3 kB -109,377 B (-28.6%)
bridge-react web bundle 12.1 kB -6,069 B (-32.9%)
bridge-react Node bundle 13.1 kB -6,056 B (-31.1%)
bridge-react-webpack-plugin built output 13.0 kB -99,910 B (-88.3%)
bridge-react-webpack-plugin web and Node bundles 995 B -6,876 B (-87.4%)
third-party-dts-extractor built output 19.8 kB -41,256 B (-67.1%)
Playground web and Node bundles 37.1 kB -11,017 B (-22.5%)

Small output increases were accepted where replacing an external dependency requires local code:

  • dts-plugin: +43 B gzip (+0.3%). Its main benefit is removing node-schedule from the installed dependency tree.
  • managers: +64 B gzip (+2.7%) while removing empathic.
  • sdk: +4.9 kB raw output (+3.8%) for the shared lightweight cache implementation.

Validation

  • All 43 packages built successfully.
  • All 76 affected test tasks passed.
  • Targeted package checks passed: 28/28.
  • Formatting, linting, lockfile, publishing compatibility, and changeset checks passed.
  • The latest GitHub bundle-size workflow completed successfully.

The Metro, application, Next.js, router, and DevTools end-to-end jobs were not run locally because this PR does not change those areas. GitHub-only checks are left to CI.

Related Issue

N/A

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have updated the documentation.

@changeset-bot

changeset-bot Bot commented Jul 14, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0b49496

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

This PR includes changesets to release 47 packages
Name Type
@module-federation/bridge-react Patch
@module-federation/modern-js Patch
@module-federation/modern-js-v3 Patch
@module-federation/enhanced Patch
@module-federation/bridge-react-webpack-plugin Patch
@module-federation/dts-plugin Patch
@module-federation/managers Patch
@module-federation/third-party-dts-extractor Patch
@module-federation/playground Patch
remote5 Patch
remote6 Patch
shared-tree-shaking-with-server-host Patch
shared-tree-shaking-with-server-provider 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
@module-federation/rspack Patch
@module-federation/cli Patch
@module-federation/manifest Patch
@module-federation/metro Patch
node-dynamic-remote-new-version Patch
node-dynamic-remote Patch
website-new Patch
@module-federation/metro-plugin-rnc-cli Patch
@module-federation/metro-plugin-rnef Patch
@module-federation/metro-plugin-rock Patch
@module-federation/runtime Patch
@module-federation/webpack-bundler-runtime Patch
@module-federation/sdk Patch
@module-federation/runtime-tools Patch
@module-federation/devtools Patch
@module-federation/bridge-vue3 Patch
@module-federation/bridge-shared Patch
@module-federation/retry-plugin 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/treeshake-server Patch
@module-federation/treeshake-frontend Patch
@module-federation/esbuild Patch
@module-federation/observability-plugin 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

@github-actions

github-actions Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

🚀 Preview Environment Ready!

Name Status URL
website-new ✅ Active https://nestor-lopez-29427-website-new-core-module-federa-919764d... ↗

Details:

  • Latest Commit: 0b49496
  • Updated at: 7/14/2026, 8:39:29 AM

@pkg-pr-new

pkg-pr-new Bot commented Jul 14, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@module-federation/devtools

pnpm add https://pkg.pr.new/@module-federation/devtools@0b49496

@module-federation/cli

pnpm add https://pkg.pr.new/@module-federation/cli@0b49496

create-module-federation

pnpm add https://pkg.pr.new/create-module-federation@0b49496

@module-federation/dts-plugin

pnpm add https://pkg.pr.new/@module-federation/dts-plugin@0b49496

@module-federation/enhanced

pnpm add https://pkg.pr.new/@module-federation/enhanced@0b49496

@module-federation/error-codes

pnpm add https://pkg.pr.new/@module-federation/error-codes@0b49496

@module-federation/esbuild

pnpm add https://pkg.pr.new/@module-federation/esbuild@0b49496

@module-federation/managers

pnpm add https://pkg.pr.new/@module-federation/managers@0b49496

@module-federation/manifest

pnpm add https://pkg.pr.new/@module-federation/manifest@0b49496

@module-federation/metro

pnpm add https://pkg.pr.new/@module-federation/metro@0b49496

@module-federation/metro-plugin-rnc-cli

pnpm add https://pkg.pr.new/@module-federation/metro-plugin-rnc-cli@0b49496

@module-federation/metro-plugin-rnef

pnpm add https://pkg.pr.new/@module-federation/metro-plugin-rnef@0b49496

@module-federation/metro-plugin-rock

pnpm add https://pkg.pr.new/@module-federation/metro-plugin-rock@0b49496

@module-federation/modern-js

pnpm add https://pkg.pr.new/@module-federation/modern-js@0b49496

@module-federation/modern-js-v3

pnpm add https://pkg.pr.new/@module-federation/modern-js-v3@0b49496

@module-federation/native-federation-tests

pnpm add https://pkg.pr.new/@module-federation/native-federation-tests@0b49496

@module-federation/native-federation-typescript

pnpm add https://pkg.pr.new/@module-federation/native-federation-typescript@0b49496

@module-federation/nextjs-mf

pnpm add https://pkg.pr.new/@module-federation/nextjs-mf@0b49496

@module-federation/node

pnpm add https://pkg.pr.new/@module-federation/node@0b49496

@module-federation/observability-plugin

pnpm add https://pkg.pr.new/@module-federation/observability-plugin@0b49496

@module-federation/playground

pnpm add https://pkg.pr.new/@module-federation/playground@0b49496

@module-federation/retry-plugin

pnpm add https://pkg.pr.new/@module-federation/retry-plugin@0b49496

@module-federation/rsbuild-plugin

pnpm add https://pkg.pr.new/@module-federation/rsbuild-plugin@0b49496

@module-federation/rspack

pnpm add https://pkg.pr.new/@module-federation/rspack@0b49496

@module-federation/rspress-plugin

pnpm add https://pkg.pr.new/@module-federation/rspress-plugin@0b49496

@module-federation/runtime

pnpm add https://pkg.pr.new/@module-federation/runtime@0b49496

@module-federation/runtime-core

pnpm add https://pkg.pr.new/@module-federation/runtime-core@0b49496

@module-federation/runtime-tools

pnpm add https://pkg.pr.new/@module-federation/runtime-tools@0b49496

@module-federation/sdk

pnpm add https://pkg.pr.new/@module-federation/sdk@0b49496

@module-federation/storybook-addon

pnpm add https://pkg.pr.new/@module-federation/storybook-addon@0b49496

@module-federation/third-party-dts-extractor

pnpm add https://pkg.pr.new/@module-federation/third-party-dts-extractor@0b49496

@module-federation/treeshake-frontend

pnpm add https://pkg.pr.new/@module-federation/treeshake-frontend@0b49496

@module-federation/treeshake-server

pnpm add https://pkg.pr.new/@module-federation/treeshake-server@0b49496

@module-federation/typescript

pnpm add https://pkg.pr.new/@module-federation/typescript@0b49496

@module-federation/utilities

pnpm add https://pkg.pr.new/@module-federation/utilities@0b49496

@module-federation/webpack-bundler-runtime

pnpm add https://pkg.pr.new/@module-federation/webpack-bundler-runtime@0b49496

@module-federation/bridge-react

pnpm add https://pkg.pr.new/@module-federation/bridge-react@0b49496

@module-federation/bridge-react-webpack-plugin

pnpm add https://pkg.pr.new/@module-federation/bridge-react-webpack-plugin@0b49496

@module-federation/bridge-shared

pnpm add https://pkg.pr.new/@module-federation/bridge-shared@0b49496

@module-federation/bridge-vue3

pnpm add https://pkg.pr.new/@module-federation/bridge-vue3@0b49496

@module-federation/inject-external-runtime-core-plugin

pnpm add https://pkg.pr.new/@module-federation/inject-external-runtime-core-plugin@0b49496

commit: 0b49496

@github-actions

github-actions Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Bundle Size Report

14 package(s) changed, 28 unchanged.

Package dist + ESM entry

Package Total dist (raw) Delta ESM gzip Delta
@module-federation/bridge-react 268.4 kB -107129 B (-28.0%) 1.3 kB -3 B (-0.2%)
@module-federation/bridge-react-webpack-plugin 13.0 kB -99910 B (-88.3%) 1.6 kB -10631 B (-87.0%)
@module-federation/dts-plugin 332.3 kB +873 B (+0.3%) 4.7 kB +2 B (+0.0%)
@module-federation/enhanced 812.8 kB +1.2 kB (+0.1%) 672 B no change
@module-federation/managers 70.7 kB +4.0 kB (+6.0%) 244 B no change
@module-federation/modern-js 197.7 kB -46 B (-0.0%) 1.2 kB no change
@module-federation/modern-js-v3 191.0 kB -37 B (-0.0%) 876 B no change
@module-federation/playground 28.76 MB -335993 B (-1.1%) 41.5 kB -10682 B (-20.1%)
@module-federation/third-party-dts-extractor 19.8 kB -41256 B (-67.1%) 2.0 kB +64 B (+3.3%)

Bundle targets

Package Web bundle (gzip) Delta Node bundle (gzip) Delta
@module-federation/bridge-react 12.2 kB -6029 B (-32.6%) 13.1 kB -6018 B (-30.9%)
@module-federation/bridge-react-webpack-plugin 995 B -6876 B (-87.4%) 995 B -6876 B (-87.4%)
@module-federation/cli 2.3 kB -10 B (-0.4%) 2.4 kB -33 B (-1.3%)
@module-federation/core 1.0 kB -4 B (-0.4%) 1.0 kB -34 B (-3.1%)
@module-federation/devtools 30.3 kB -1 B (-0.0%) 30.3 kB -25 B (-0.1%)
@module-federation/dts-plugin 15.3 kB +43 B (+0.3%) 15.3 kB +43 B (+0.3%)
@module-federation/enhanced 2.7 kB +4 B (+0.1%) 2.8 kB -45 B (-1.6%)
@module-federation/managers 2.4 kB +64 B (+2.7%) 2.4 kB +64 B (+2.7%)
@module-federation/metro-plugin-rnc-cli 416 B +2 B (+0.5%) 435 B -27 B (-5.8%)
@module-federation/node 9.2 kB +2 B (+0.0%) 9.2 kB -29 B (-0.3%)
@module-federation/playground 37.2 kB -10830 B (-22.1%) 37.2 kB -10830 B (-22.1%)
@module-federation/third-party-dts-extractor 1.3 kB +14 B (+1.1%) 1.3 kB +14 B (+1.1%)

Consumer scenarios

Scenario Web output (gzip) Delta Node output (gzip) Delta Gap (node-web) Delta
Enhanced remoteEntry 21.4 kB -18 B (-0.1%) 23.0 kB -23 B (-0.1%) +1.6 kB -5 B

Total dist (raw): 35.67 MB (-578242 B (-1.5%))
Total ESM gzip: 102.2 kB (-21250 B (-16.9%))
Total web bundle (gzip): 229.9 kB (-23621 B (-9.1%))
Total node bundle (gzip): 232.5 kB (-23796 B (-9.1%))
Tracked ./bundler entry gzip: 556 B (no change)
Tracked ./bundler web bundle (gzip): 4.7 kB (no change)
Tracked ./bundler node bundle (gzip): 4.7 kB (no change)

Bundle sizes are generated with rslib (Rspack). Package-root metrics preserve the historical report. Tracked subpath exports such as ./bundler are measured separately so ENV_TARGET-driven tree-shaking is visible. Bare imports are externalized to keep package-level sizes consistent, and assets are emitted as resources.

@2heal1
2heal1 force-pushed the perf/replace-lru-cache-upath branch from 92f019b to 8352c8e Compare July 14, 2026 07:42
@2heal1
2heal1 merged commit 6ee67dc into main Jul 14, 2026
25 checks passed
@2heal1
2heal1 deleted the perf/replace-lru-cache-upath branch July 14, 2026 10:57
@2heal1 2heal1 mentioned this pull request Jul 15, 2026
tonoizer added a commit to tonoizer/module-federation-doctor that referenced this pull request Aug 9, 2026
## Summary

- Update the Modern.js compatibility documentation to record that the
historical `@module-federation/bridge-react/size-limited-cache` export
gap was fixed upstream in [Module Federation Core PR
#4897](module-federation/core#4897).
- Keep Modern.js explicitly `partial`: the repository smoke covers the
Doctor adapter and Rspack-under-the-hood, not a full
`@modern-js/app-tools` core-demo soak.
- Keep #130 as the tracking issue for the final external soak instead of
claiming unsupported evidence; #130 remains open until that verification
exists.
- Align the Modern.js smoke README with the current #130 tracker.

Refs #130

## Verification

- `corepack pnpm docs:build`
- `corepack pnpm exec vitest run test/unit/plugin-modern.test.ts` — 4
passed
- `corepack pnpm --filter @mfdoctor-example/modern-smoke build`
- `git diff --check`

## Scope notes

- The published `@module-federation/bridge-react@2.8.2` package exports
`./size-limited-cache`.
- A full Core `@modern-js/app-tools` re-soak is still external evidence.
The local Windows Core checkout cannot provide that proof because its
workspace build path requires Unix `cp` tooling and the initial install
reaches the excluded DevTools/WSL setup; no Doctor adapter defect was
reproduced.
- This PR leaves #130 open pending the external verification and does
not touch the DevTools work tracked separately.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant