Skip to content

feat(metro-core): support dts-plugin#4449

Open
Nsttt wants to merge 5 commits intomodule-federation:mainfrom
Nsttt:feat/metro-dts-plugin
Open

feat(metro-core): support dts-plugin#4449
Nsttt wants to merge 5 commits intomodule-federation:mainfrom
Nsttt:feat/metro-dts-plugin

Conversation

@Nsttt
Copy link
Contributor

@Nsttt Nsttt commented Feb 15, 2026

Adds federated d.ts generation support to Metro remotes.

Status update (rebased):

What changed:

  • Adds dts support to Metro config typing (boolean | PluginDtsOptions)
  • bundle-mf-remote runs dts generation and writes produced files into:
    • dist/<platform>/@mf-types.zip
    • dist/<platform>/@mf-types.d.ts (when produced)
  • dist/<platform>/mf-manifest.json gets metaData.types.{zip,api} only when files exist
  • Hardened generation path:
    • dts: true defaults to consumeTypes: false
    • verifies generated files exist before writing manifest type entries
    • warns and leaves metaData.types empty if no types were produced
  • Added changeset for @module-federation/metro
  • Docs updated (en/zh)

Validation:

  • pnpm nx run-many -t test,build -p metro-core --skip-nx-cache

@changeset-bot
Copy link

changeset-bot bot commented Feb 15, 2026

🦋 Changeset detected

Latest commit: 14092be

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

This PR includes changesets to release 43 packages
Name Type
@module-federation/metro Patch
@module-federation/metro-plugin-rnc-cli Patch
@module-federation/metro-plugin-rnef Patch
@module-federation/runtime Patch
@module-federation/enhanced 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/modern-js-v3 Patch
@module-federation/retry-plugin Patch
@module-federation/data-prefetch Patch
@module-federation/rsbuild-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/cli Patch
@module-federation/rspress-plugin Patch
@module-federation/treeshake-server Patch
@module-federation/treeshake-frontend Patch
@module-federation/modern-js Patch
@module-federation/nextjs-mf Patch
@module-federation/node Patch
@module-federation/storybook-addon Patch
shared-tree-shaking-no-server-host Patch
shared-tree-shaking-no-server-provider Patch
@module-federation/esbuild Patch
@module-federation/utilities Patch
remote5 Patch
remote6 Patch
shared-tree-shaking-with-server-host Patch
shared-tree-shaking-with-server-provider Patch
website-new 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

@netlify
Copy link

netlify bot commented Feb 15, 2026

Deploy Preview for module-federation-docs ready!

Name Link
🔨 Latest commit 14092be
🔍 Latest deploy log https://app.netlify.com/projects/module-federation-docs/deploys/69934050d0952d00087983e5
😎 Deploy Preview https://deploy-preview-4449--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.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 15, 2026

Open in StackBlitz

@module-federation/devtools

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/devtools@4449

@module-federation/cli

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/cli@4449

create-module-federation

pnpm add https://pkg.pr.new/module-federation/core/create-module-federation@4449

@module-federation/data-prefetch

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/data-prefetch@4449

@module-federation/dts-plugin

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/dts-plugin@4449

@module-federation/enhanced

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/enhanced@4449

@module-federation/error-codes

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/error-codes@4449

@module-federation/managers

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/managers@4449

@module-federation/manifest

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/manifest@4449

@module-federation/metro

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/metro@4449

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

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

@module-federation/metro-plugin-rnef

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

@module-federation/modern-js-v3

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

@module-federation/retry-plugin

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/retry-plugin@4449

@module-federation/rsbuild-plugin

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/rsbuild-plugin@4449

@module-federation/rspack

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/rspack@4449

@module-federation/rspress-plugin

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/rspress-plugin@4449

@module-federation/runtime

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

@module-federation/runtime-core

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

@module-federation/runtime-tools

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/runtime-tools@4449

@module-federation/sdk

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/sdk@4449

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

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

@module-federation/treeshake-frontend

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/treeshake-frontend@4449

@module-federation/treeshake-server

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/treeshake-server@4449

@module-federation/webpack-bundler-runtime

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

@module-federation/bridge-react

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/bridge-react@4449

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

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

@module-federation/bridge-shared

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/bridge-shared@4449

@module-federation/bridge-vue3

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/bridge-vue3@4449

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

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

commit: 14092be

@github-actions
Copy link
Contributor

github-actions bot commented Feb 15, 2026

Bundle Size Report

1 package(s) changed, 40 unchanged.

Package Total dist Delta ESM gzip Delta
metro-core 229.2 kB +10.6 kB (+4.9%) 147 B no change

Total dist: 6.90 MB (+10.6 kB (+0.2%))
Total ESM gzip: 138.6 kB (no change)

@jbroma
Copy link
Member

jbroma commented Feb 16, 2026

@Nsttt nice work! Let's wait a bit until #4446 is merged so we can utilize the configuration changes there (unified with config shown in the docs)

@Nsttt Nsttt force-pushed the feat/metro-dts-plugin branch from 5234c59 to fc52189 Compare February 16, 2026 13:31
@Nsttt
Copy link
Contributor Author

Nsttt commented Feb 16, 2026

@jbroma rebased now that #4446 is merged and aligned this PR to the unified Metro config shape from main.

Also validated locally after rebase:

  • pnpm nx run-many -t test,build -p metro-core --skip-nx-cache

DTS generation behavior in this branch:

  • outputs (when produced): dist/<platform>/@mf-types.zip, dist/<platform>/@mf-types.d.ts
  • manifest writes metaData.types.{zip,api} only if files actually exist
  • if no types are produced, we warn and keep metaData.types empty.

@Nsttt Nsttt marked this pull request as ready for review February 16, 2026 13:45
Copilot AI review requested due to automatic review settings February 16, 2026 13:45
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds optional federated TypeScript declaration (d.ts) generation support for Metro remotes, integrating @module-federation/dts-plugin into the bundle-mf-remote flow and documenting the new configuration.

Changes:

  • Extend Metro federation config typing/normalization to support dts: boolean | PluginDtsOptions (defaulting to false).
  • Run d.ts generation during bundle-mf-remote and conditionally populate mf-manifest.json with metaData.types.{zip,api} when outputs exist.
  • Add dependency/changeset and update Metro plugin docs (EN/ZH).

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pnpm-lock.yaml Adds workspace link for @module-federation/dts-plugin and lock updates.
packages/metro-core/src/types.ts Adds dts to Metro federation config typing and normalized config.
packages/metro-core/src/plugin/validate-options.ts Allows dts as a supported top-level option (no longer warned as unsupported).
packages/metro-core/src/plugin/normalize-options.ts Defaults dts to false; fixes plugin path normalization to preserve bare package specifiers.
packages/metro-core/src/commands/bundle-remote/index.ts Generates types via dts-plugin, verifies outputs, and writes manifest metaData.types only when present.
packages/metro-core/package.json Adds @module-federation/dts-plugin dependency.
packages/metro-core/tests/plugin/normalize-options.spec.ts Adds tests for dts default/enablement and no type-hints plugin injection.
apps/website-new/docs/zh/guide/build-plugins/plugins-metro.mdx Documents dts: true usage and config typing (ZH).
apps/website-new/docs/en/guide/build-plugins/plugins-metro.mdx Documents dts: true usage and config typing (EN).
.changeset/sweet-cats-smile.md Publishes a patch changeset for @module-federation/metro.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (1)

packages/metro-core/src/plugin/validate-options.ts:17

  • Now that dts is a supported top-level option (removed from unsupportedTopLevelOptions), validateOptions should explicitly validate its runtime type (boolean | object | undefined). Otherwise invalid values like dts: 1 will pass validation but later crash bundle-mf-remote when @module-federation/dts-plugin calls normalizeOptions and throws a generic error. Add a small validator that throws a ConfigError with a clear message when dts is not boolean/undefined/plain-object.
const unsupportedTopLevelOptions: (keyof ModuleFederationConfig)[] = [
  'library',
  'remoteType',
  'runtime',
  'shareScope',
  'getPublicPath',
  'implementation',
  'manifest',
  'dev',
  'dataPrefetch',
  'virtualRuntimeEntry',
  'experiments',
  'bridge',

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

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

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: fc52189fb2

ℹ️ 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 9 to 13
/**
* Federated types (d.ts) support. When enabled, Metro bundle commands can
* generate `@mf-types.zip` and `@mf-types.d.ts` for consumption by hosts.
*/
dts?: boolean | moduleFederationPlugin.PluginDtsOptions;
Copy link
Member

Choose a reason for hiding this comment

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

no need to redeclare it here, it should be inherited from the SDK type

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, removed in 9c9e3c644.

ModuleFederationConfig now only inherits dts from moduleFederationPlugin.ModuleFederationPluginOptions (no local redeclaration).

Copy link
Member

Choose a reason for hiding this comment

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

hmmm if this is inside bundle-remote then DTS works only when running bundle remote, is this the desired behavior?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, intentional for now.

DTS generation here targets remote container build artifacts (@mf-types.zip, @mf-types.d.ts, and mf-manifest.json type metadata), so it is bound to bundle-mf-remote. I made that explicit in 9c9e3c644 by renaming the helper to maybeGenerateFederatedRemoteTypes and adding an intent comment at the call site.

@Nsttt Nsttt requested a review from jbroma February 16, 2026 16:21
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.

2 participants