Skip to content

feat(dts-plugin): add TypeScript 7 support#4878

Open
2heal1 wants to merge 8 commits into
mainfrom
feat/ts7
Open

feat(dts-plugin): add TypeScript 7 support#4878
2heal1 wants to merge 8 commits into
mainfrom
feat/ts7

Conversation

@2heal1

@2heal1 2heal1 commented Jul 9, 2026

Copy link
Copy Markdown
Member

Description

This PR adds TypeScript 7 support to federated type generation while preserving compatibility with TypeScript 4.9, 5, and 6.

TypeScript 7 no longer exposes the package root used by the existing dts-plugin implementation. As a result, directly importing or requiring typescript fails with ERR_PACKAGE_PATH_NOT_EXPORTED.

Instead of only widening the TypeScript peer dependency range, this PR introduces a version-aware compilation path.

DTS plugin changes

  • Resolve the TypeScript installation from the consumer project's context, including a configured dts.cwd.
  • Detect the installed TypeScript version and resolve its local tsc executable.
  • Keep the existing TypeScript compiler API flow for TypeScript 4.9–6.
  • For TypeScript 7, use the project-local tsc CLI:
    • --showConfig to read the effective TypeScript configuration.
    • --listFilesOnly to collect exposed entries and their source dependencies.
    • --project to generate declaration files.
  • Invoke the project's resolved TypeScript compiler directly instead of relying on a globally resolved tsc.
  • Preserve custom compilerInstance commands such as vue-tsc.
  • Remove the internal compile-time dependency on TypeScript's exported CompilerOptions types.
  • Normalize config paths, rootDir, output paths, project references, and symlinked source paths.
  • Convert legacy node / node10 module resolution to bundler when generating a TypeScript 7-compatible configuration.

Repository compatibility updates

  • Extend the relevant TypeScript peer dependency ranges with ^7.0.0 while retaining support for TypeScript 4.9, 5, and 6.
  • Use TypeScript 7.0.2 in the affected packages, examples, and test projects.
  • Keep the repository-level compiler on TypeScript 6 where existing tooling still depends on the legacy TypeScript API.
  • Use an explicit TypeScript 6 compiler alias for Modern.js configuration loading and type checking where required, while validating the application code with TypeScript 7.
  • Update tsconfig path and module-resolution settings that are no longer accepted by TypeScript 7.
  • Fix source, test, build, and declaration-generation issues exposed by TypeScript 7.
  • Update affected generated declarations and the lockfile.
  • Pin the release workflow to a Node.js 20-compatible npm version for OIDC publishing.

Tests

  • Add TypeScript 6 and TypeScript 7 test scenarios for:
    • reading and normalizing tsconfig;
    • project references;
    • exposed-file resolution;
    • dependent-source-file discovery;
    • custom type output directories.
  • Add an integration test that generates federated declarations using TypeScript 7.
  • Verify that declaration generation includes the exposed entry and its dependencies without emitting unrelated source files.
  • Keep coverage for custom compiler commands such as vue-tsc.

Metro scope

The explicit TypeScript 7 upgrade for Metro-related packages is intentionally not included in this PR.

When the Metro TypeScript upgrade was enabled, the Metro iOS CI path failed during CocoaPods project generation. The Metro-specific TypeScript migration will therefore need a separate follow-up after the Metro/Rock/React Native integration issue is understood.

Related Issue

Closes #4854

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 9, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 28cac38

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/dts-plugin Patch
@module-federation/enhanced Patch
@module-federation/modern-js Patch
@module-federation/modern-js-v3 Patch
@module-federation/playground Patch
@module-federation/rspack Patch
@module-federation/cli Patch
@module-federation/manifest Patch
@module-federation/metro 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
@module-federation/metro-plugin-rnc-cli Patch
@module-federation/metro-plugin-rnef Patch
@module-federation/metro-plugin-rock Patch
node-dynamic-remote-new-version Patch
node-dynamic-remote Patch
remote5 Patch
remote6 Patch
website-new Patch
@module-federation/runtime Patch
@module-federation/webpack-bundler-runtime Patch
@module-federation/sdk Patch
@module-federation/runtime-tools Patch
@module-federation/managers 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/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 9, 2026

Copy link
Copy Markdown
Contributor

🚀 Preview Environment Ready!

Name Status URL
website-new ✅ Active https://nestor-lopez-28382-website-new-core-module-federa-7c3fc42... ↗

Details:

  • Latest Commit: 28cac38
  • Updated at: 7/10/2026, 7:04:03 AM
@pkg-pr-new

pkg-pr-new Bot commented Jul 9, 2026

Copy link
Copy Markdown

Open in StackBlitz

@module-federation/devtools

pnpm add https://pkg.pr.new/@module-federation/devtools@28cac38

@module-federation/cli

pnpm add https://pkg.pr.new/@module-federation/cli@28cac38

create-module-federation

pnpm add https://pkg.pr.new/create-module-federation@28cac38

@module-federation/dts-plugin

pnpm add https://pkg.pr.new/@module-federation/dts-plugin@28cac38

@module-federation/enhanced

pnpm add https://pkg.pr.new/@module-federation/enhanced@28cac38

@module-federation/error-codes

pnpm add https://pkg.pr.new/@module-federation/error-codes@28cac38

@module-federation/esbuild

pnpm add https://pkg.pr.new/@module-federation/esbuild@28cac38

@module-federation/managers

pnpm add https://pkg.pr.new/@module-federation/managers@28cac38

@module-federation/manifest

pnpm add https://pkg.pr.new/@module-federation/manifest@28cac38

@module-federation/metro

pnpm add https://pkg.pr.new/@module-federation/metro@28cac38

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

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

@module-federation/metro-plugin-rnef

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

@module-federation/metro-plugin-rock

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

@module-federation/modern-js

pnpm add https://pkg.pr.new/@module-federation/modern-js@28cac38

@module-federation/modern-js-v3

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

@module-federation/native-federation-tests

pnpm add https://pkg.pr.new/@module-federation/native-federation-tests@28cac38

@module-federation/native-federation-typescript

pnpm add https://pkg.pr.new/@module-federation/native-federation-typescript@28cac38

@module-federation/nextjs-mf

pnpm add https://pkg.pr.new/@module-federation/nextjs-mf@28cac38

@module-federation/node

pnpm add https://pkg.pr.new/@module-federation/node@28cac38

@module-federation/observability-plugin

pnpm add https://pkg.pr.new/@module-federation/observability-plugin@28cac38

@module-federation/playground

pnpm add https://pkg.pr.new/@module-federation/playground@28cac38

@module-federation/retry-plugin

pnpm add https://pkg.pr.new/@module-federation/retry-plugin@28cac38

@module-federation/rsbuild-plugin

pnpm add https://pkg.pr.new/@module-federation/rsbuild-plugin@28cac38

@module-federation/rspack

pnpm add https://pkg.pr.new/@module-federation/rspack@28cac38

@module-federation/rspress-plugin

pnpm add https://pkg.pr.new/@module-federation/rspress-plugin@28cac38

@module-federation/runtime

pnpm add https://pkg.pr.new/@module-federation/runtime@28cac38

@module-federation/runtime-core

pnpm add https://pkg.pr.new/@module-federation/runtime-core@28cac38

@module-federation/runtime-tools

pnpm add https://pkg.pr.new/@module-federation/runtime-tools@28cac38

@module-federation/sdk

pnpm add https://pkg.pr.new/@module-federation/sdk@28cac38

@module-federation/storybook-addon

pnpm add https://pkg.pr.new/@module-federation/storybook-addon@28cac38

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

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

@module-federation/treeshake-frontend

pnpm add https://pkg.pr.new/@module-federation/treeshake-frontend@28cac38

@module-federation/treeshake-server

pnpm add https://pkg.pr.new/@module-federation/treeshake-server@28cac38

@module-federation/typescript

pnpm add https://pkg.pr.new/@module-federation/typescript@28cac38

@module-federation/utilities

pnpm add https://pkg.pr.new/@module-federation/utilities@28cac38

@module-federation/webpack-bundler-runtime

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

@module-federation/bridge-react

pnpm add https://pkg.pr.new/@module-federation/bridge-react@28cac38

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

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

@module-federation/bridge-shared

pnpm add https://pkg.pr.new/@module-federation/bridge-shared@28cac38

@module-federation/bridge-vue3

pnpm add https://pkg.pr.new/@module-federation/bridge-vue3@28cac38

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

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

commit: 28cac38

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Bundle Size Report

19 package(s) changed, 23 unchanged.

Package dist + ESM entry

Package Total dist (raw) Delta ESM gzip Delta
@module-federation/bridge-react 373.1 kB -11139 B (-2.8%) 1.3 kB no change
@module-federation/bridge-react-webpack-plugin 110.6 kB +728 B (+0.6%) 11.9 kB no change
@module-federation/bridge-shared 1.1 kB +5 B (+0.5%) 137 B no change
@module-federation/bridge-vue3 177.4 kB +3.8 kB (+2.2%) 25.7 kB no change
@module-federation/devtools 1.00 MB +358.2 kB (+53.7%) 4.0 kB no change
@module-federation/dts-plugin 329.9 kB +15.8 kB (+5.0%) 4.7 kB no change
@module-federation/enhanced 811.6 kB +1.0 kB (+0.1%) 672 B no change
@module-federation/manifest 130.9 kB -18 B (-0.0%) 106 B no change
@module-federation/modern-js 194.4 kB -51 B (-0.0%) 1.2 kB no change
@module-federation/modern-js-v3 190.6 kB -51 B (-0.0%) 876 B no change
@module-federation/nextjs-mf 156.6 kB +28.8 kB (+22.6%) 160 B no change
@module-federation/node 193.2 kB -216 B (-0.1%) 217 B no change
@module-federation/playground 29.08 MB +155.1 kB (+0.5%) 51.9 kB +48 B (+0.1%)
@module-federation/rspack 55.6 kB -55 B (-0.1%) 161 B no change
@module-federation/runtime-core 287.7 kB -8 B (-0.0%) 477 B no change
@module-federation/runtime-tools 7.8 kB +65 B (+0.8%) 142 B no change
@module-federation/third-party-dts-extractor 60.1 kB +199 B (+0.3%) 1.9 kB no change
@module-federation/treeshake-server 774.2 kB +184 B (+0.0%) 124 B no change
@module-federation/webpack-bundler-runtime 67.2 kB -31771 B (-31.6%) 405 B no change

Bundle targets

Package Web bundle (gzip) Delta Node bundle (gzip) Delta
@module-federation/bridge-react n/a n/a n/a n/a
@module-federation/bridge-react-webpack-plugin n/a n/a n/a n/a
@module-federation/bridge-shared n/a n/a n/a n/a
@module-federation/bridge-vue3 n/a n/a n/a n/a
@module-federation/devtools n/a n/a n/a n/a
@module-federation/dts-plugin n/a n/a n/a n/a
@module-federation/enhanced n/a n/a n/a n/a
@module-federation/manifest n/a n/a n/a n/a
@module-federation/modern-js n/a n/a n/a n/a
@module-federation/modern-js-v3 n/a n/a n/a n/a
@module-federation/nextjs-mf n/a n/a n/a n/a
@module-federation/node n/a n/a n/a n/a
@module-federation/playground n/a n/a n/a n/a
@module-federation/rspack n/a n/a n/a n/a
@module-federation/runtime-core n/a n/a n/a n/a
@module-federation/runtime-tools n/a n/a n/a n/a
@module-federation/third-party-dts-extractor n/a n/a n/a n/a
@module-federation/treeshake-server n/a n/a n/a n/a
@module-federation/webpack-bundler-runtime n/a n/a n/a n/a

Consumer scenarios

Scenario Web output (gzip) Delta Node output (gzip) Delta Gap (node-web) Delta
Enhanced remoteEntry 21.4 kB -13 B (-0.1%) 23.0 kB -17 B (-0.1%) +1.6 kB -4 B

Total dist (raw): 36.21 MB (+521.5 kB (+1.4%))
Total ESM gzip: 122.9 kB (+48 B (+0.0%))
Total web bundle (gzip): 0 B (no change)
Total node bundle (gzip): 0 B (no change)
Tracked ./bundler entry gzip: 556 B (no change)
Tracked ./bundler web bundle (gzip): 0 B (no change)
Tracked ./bundler node bundle (gzip): 0 B (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.

Bundle errors

  • @module-federation/bridge-react: web: build is not a function; node: build is not a function
  • @module-federation/bridge-react-webpack-plugin: web: build is not a function; node: build is not a function
  • @module-federation/bridge-shared: web: build is not a function; node: build is not a function
  • @module-federation/bridge-vue3: web: build is not a function; node: build is not a function
  • @module-federation/cli: web: build is not a function; node: build is not a function
  • @module-federation/core: web: build is not a function; node: build is not a function
  • @module-federation/devtools: web: build is not a function; node: build is not a function
  • @module-federation/dts-plugin: web: build is not a function; node: build is not a function
  • @module-federation/enhanced: web: build is not a function; node: build is not a function
  • @module-federation/error-codes: web: build is not a function; node: build is not a function
  • @module-federation/esbuild: web: build is not a function; node: build is not a function
  • @module-federation/inject-external-runtime-core-plugin: web: build is not a function; node: build is not a function
  • @module-federation/managers: web: build is not a function; node: build is not a function
  • @module-federation/manifest: web: build is not a function; node: build is not a function
  • @module-federation/metro: web: build is not a function; node: build is not a function
  • @module-federation/metro-plugin-rnc-cli: web: build is not a function; node: build is not a function
  • @module-federation/metro-plugin-rnef: web: build is not a function; node: build is not a function
  • @module-federation/metro-plugin-rock: web: build is not a function; node: build is not a function
  • @module-federation/modern-js: web: build is not a function; node: build is not a function
  • @module-federation/modern-js-v3: web: build is not a function; node: build is not a function
  • @module-federation/native-federation-tests: web: build is not a function; node: build is not a function
  • @module-federation/native-federation-typescript: web: build is not a function; node: build is not a function
  • @module-federation/nextjs-mf: web: build is not a function; node: build is not a function
  • @module-federation/node: web: build is not a function; node: build is not a function
  • @module-federation/observability-plugin: web: build is not a function; node: build is not a function
  • @module-federation/playground: web: build is not a function; node: build is not a function
  • @module-federation/retry-plugin: web: build is not a function; node: build is not a function
  • @module-federation/rsbuild-plugin: web: build is not a function; node: build is not a function
  • @module-federation/rspack: web: build is not a function; node: build is not a function
  • @module-federation/rspress-plugin: web: build is not a function; node: build is not a function
  • @module-federation/runtime: web: build is not a function; node: build is not a function
  • @module-federation/runtime ./bundler: web: build is not a function; node: build is not a function
  • @module-federation/runtime-core: web: build is not a function; node: build is not a function
  • @module-federation/runtime-tools: web: build is not a function; node: build is not a function
  • @module-federation/runtime-tools ./bundler: web: build is not a function; node: build is not a function
  • @module-federation/sdk: web: build is not a function; node: build is not a function
  • @module-federation/storybook-addon: web: build is not a function; node: build is not a function
  • @module-federation/third-party-dts-extractor: web: build is not a function; node: build is not a function
  • @module-federation/treeshake-server: web: build is not a function; node: build is not a function
  • @module-federation/utilities: web: build is not a function; node: build is not a function
  • @module-federation/webpack-bundler-runtime: web: build is not a function; node: build is not a function
  • @module-federation/webpack-bundler-runtime ./bundler: web: build is not a function; node: build is not a function
  • create-module-federation: web: build is not a function; node: build is not a function

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c866d8199e

ℹ️ 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 address that feedback".

Comment on lines +271 to +278
const stdout = execFileSync(
process.execPath,
[
typeScriptPackageInfo.tscBinPath,
'--showConfig',
'--project',
resolvedTsConfigPath,
],

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Run TypeScript 7's tsc binary directly

When the resolved package is TypeScript 7, tscBinPath points at the new Go-native tsc executable, but this code invokes it as node <bin/tsc>. In any project that actually has typescript@7 installed, retrieveRemoteConfig will fail before generating types because Node tries to parse the native binary instead of executing tsc (the TypeScript 7 announcement documents running it as npx tsc, not via node). The same process.execPath wrapping is repeated for --listFilesOnly and compilation, so TS7 support remains broken until the binary is executed directly or through the package-manager shim.

Useful? React with 👍 / 👎.

@AlaDouagi

Copy link
Copy Markdown

Hello @2heal1, right now these MF sub-packages have TypeScript v6/7 peer dependency issues. Can you please include TypeScript v6/7 peer deps specifications for them too here in this PR?

"@module-federation/native-federation-tests": "^0.6.4",
"@module-federation/native-federation-typescript": "^0.6.4",

Thanks!

@2heal1

2heal1 commented Jul 9, 2026

Copy link
Copy Markdown
Member Author

Hello @2heal1, right now these MF sub-packages have TypeScript v6/7 peer dependency issues. Can you please include TypeScript v6/7 peer deps specifications for them too here in this PR?

"@module-federation/native-federation-tests": "^0.6.4",
"@module-federation/native-federation-typescript": "^0.6.4",

Thanks!

@AlaDouagi Thanks for pointing this out. These two packages aren’t maintained by me, so they’re outside the scope of this PR. This PR only updates the packages I maintain for TypeScript 7 compatibility. It would be best to open an issue or PR in the corresponding repositories if TypeScript 7 peer dependency support is needed there.

@2heal1 2heal1 changed the title feat(dts-plugin): support ts 7 WIP: feat(dts-plugin): support ts 7 Jul 9, 2026
@2heal1 2heal1 changed the title WIP: feat(dts-plugin): support ts 7 feat(dts-plugin): add TypeScript 7 support Jul 10, 2026
@2heal1

2heal1 commented Jul 10, 2026

Copy link
Copy Markdown
Member Author

@Nsttt Would you mind helping upgrade the Metro packages to support TypeScript 7 in a separate PR?

I intentionally left the Metro changes out of this PR because enabling the TypeScript 7 upgrade caused the Metro CI to fail:
https://github.com/module-federation/core/actions/runs/29070042937/job/86290938905?pr=4878

Thanks!

@Nsttt

Nsttt commented Jul 10, 2026

Copy link
Copy Markdown
Member

@Nsttt Would you mind helping upgrade the Metro packages to support TypeScript 7 in a separate PR?

I intentionally left the Metro changes out of this PR because enabling the TypeScript 7 upgrade caused the Metro CI to fail: module-federation/core/actions/runs/29070042937/job/86290938905?pr=4878

Thanks!

Yeah, will do

@Nsttt Nsttt mentioned this pull request Jul 10, 2026
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

3 participants