Skip to content

fix(dts-plugin): normalize manifest type URLs on Windows#4774

Merged
ScriptedAlchemy merged 4 commits into
mainfrom
fix/dts-plugin-windows-url-join
May 29, 2026
Merged

fix(dts-plugin): normalize manifest type URLs on Windows#4774
ScriptedAlchemy merged 4 commits into
mainfrom
fix/dts-plugin-windows-url-join

Conversation

@ScriptedAlchemy
Copy link
Copy Markdown
Member

@ScriptedAlchemy ScriptedAlchemy commented May 28, 2026

Summary

This PR fixes two independent Windows bugs that together caused dts-plugin to fail downloading type archives from localhost:

Bug 1: Windows backslashes corrupting HTTP URLs

DTSManager.requestRemoteManifest() used path.join(publicPath, manifestJson.metaData.types.zip) to construct the ZIP/API download URLs. On Windows, path.join uses backslashes (\), which corrupts HTTP URLs:

path.win32.join('http://localhost:4173/', '@mf-types.zip')
// => 'http:\localhost:4173\@mf-types.zip'

Passing this to new URL() throws Invalid URL.

Fix: Use new URL(relativePath, normalizedBaseUrl).href instead. This correctly preserves forward slashes in URLs regardless of the host OS.

Bug 2: IPv4-only forcing breaks Windows localhost connections

The dts-plugin defaulted family: 4, which forces undici's fetch() to use IPv4 only. On Windows, localhost resolves to ::1 (IPv6) by default, while Vite's dev server binds to ::1:4173. The client then tries to connect to 127.0.0.1:4173 (IPv4) and gets ECONNREFUSED because the server is not listening on the IPv4 loopback.

Fix: Change the default family from 4 to 0 (auto-select). With family: 0, createDispatcherFromFamily() returns undefined (no custom Agent), so fetch() uses the OS resolver's default behavior — connecting to whichever address the hostname actually resolves to (IPv4, IPv6, or both).

This matches Node.js's own DNS default (family: 0) and the behavior of most HTTP clients.

Type/schema alignment

  • SDK types: family?: 4 | 6family?: 0 | 4 | 6
  • Enhanced runtime schema: enum: [4, 6]enum: [0, 4, 6]
  • English and Chinese docs updated to document 0 as the default

Test Plan

  • pnpm --filter @module-federation/dts-plugin exec vitest run src/core/lib/DTSManager.general.spec.ts src/core/configurations/hostPlugin.test.ts --config vite.config.mts
  • pnpm --filter @module-federation/dts-plugin run build
  • pnpm --filter @module-federation/sdk run build
  • pnpm --filter @module-federation/enhanced run build
  • pnpm exec prettier --check apps/website-new/docs/en/configure/dts.mdx apps/website-new/docs/zh/configure/dts.mdx packages/dts-plugin/src/core/configurations/hostPlugin.test.ts packages/dts-plugin/src/core/configurations/hostPlugin.ts packages/dts-plugin/src/core/lib/DTSManager.general.spec.ts packages/dts-plugin/src/core/lib/DTSManager.ts packages/dts-plugin/src/core/lib/utils.ts packages/sdk/src/types/plugins/ModuleFederationPlugin.ts .changeset/warm-dts-windows-paths.md
  • git diff --check

Known Validation Gap

  • pnpm --filter @module-federation/dts-plugin run test still fails in pre-existing unrelated typeScriptCompiler.test.ts / DtsWorker.spec.ts TYPE-001 cases (118 passed, 9 failed locally)

Closes #4415

Fix consumeTypes manifest type URL resolution by switching to URL-based joins.
Default the host family option to 0 for auto-selection.
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 28, 2026

🦋 Changeset detected

Latest commit: d7d0d91

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

This PR includes changesets to release 46 packages
Name Type
@module-federation/dts-plugin Patch
@module-federation/sdk Patch
@module-federation/cli Patch
@module-federation/enhanced Patch
@module-federation/manifest Patch
@module-federation/metro Patch
@module-federation/rspack Patch
@module-federation/devtools Patch
@module-federation/esbuild Patch
@module-federation/managers Patch
@module-federation/modern-js-v3 Patch
@module-federation/modern-js Patch
@module-federation/nextjs-mf Patch
@module-federation/node Patch
@module-federation/observability-plugin Patch
@module-federation/retry-plugin Patch
@module-federation/rsbuild-plugin Patch
@module-federation/rspress-plugin Patch
@module-federation/runtime-core Patch
@module-federation/runtime Patch
@module-federation/storybook-addon Patch
@module-federation/utilities Patch
@module-federation/webpack-bundler-runtime Patch
@module-federation/bridge-react-webpack-plugin Patch
@module-federation/bridge-react Patch
@module-federation/bridge-vue3 Patch
shared-tree-shaking-no-server-host Patch
shared-tree-shaking-no-server-provider Patch
@module-federation/metro-plugin-rnc-cli Patch
@module-federation/metro-plugin-rnef Patch
@module-federation/metro-plugin-rock Patch
shared-tree-shaking-with-server-host Patch
shared-tree-shaking-with-server-provider Patch
node-dynamic-remote-new-version Patch
node-dynamic-remote Patch
remote5 Patch
remote6 Patch
website-new Patch
@module-federation/runtime-tools Patch
@module-federation/inject-external-runtime-core-plugin Patch
@module-federation/third-party-dts-extractor Patch
@module-federation/bridge-shared Patch
@module-federation/error-codes Patch
create-module-federation Patch
@module-federation/treeshake-server Patch
@module-federation/treeshake-frontend 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
Copy Markdown

netlify Bot commented May 28, 2026

Deploy Preview for module-federation-docs ready!

Name Link
🔨 Latest commit d7d0d91
🔍 Latest deploy log https://app.netlify.com/projects/module-federation-docs/deploys/6a18fe5174454000080c80e8
😎 Deploy Preview https://deploy-preview-4774--module-federation-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

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

Copy link
Copy Markdown

@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: 02ce4f3ee9

ℹ️ 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 thread packages/sdk/src/types/plugins/ModuleFederationPlugin.ts
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 28, 2026

Open in StackBlitz

@module-federation/devtools

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

@module-federation/cli

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

create-module-federation

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

@module-federation/dts-plugin

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

@module-federation/enhanced

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

@module-federation/error-codes

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

@module-federation/esbuild

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

@module-federation/managers

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

@module-federation/manifest

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

@module-federation/metro

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

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

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

@module-federation/metro-plugin-rnef

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

@module-federation/metro-plugin-rock

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

@module-federation/modern-js

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

@module-federation/modern-js-v3

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

@module-federation/native-federation-tests

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

@module-federation/native-federation-typescript

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

@module-federation/nextjs-mf

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

@module-federation/node

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

@module-federation/observability-plugin

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

@module-federation/retry-plugin

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

@module-federation/rsbuild-plugin

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

@module-federation/rspack

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

@module-federation/rspress-plugin

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

@module-federation/runtime

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

@module-federation/runtime-core

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

@module-federation/runtime-tools

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

@module-federation/sdk

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

@module-federation/storybook-addon

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

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

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

@module-federation/treeshake-frontend

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

@module-federation/treeshake-server

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

@module-federation/typescript

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

@module-federation/utilities

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

@module-federation/webpack-bundler-runtime

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

@module-federation/bridge-react

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

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

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

@module-federation/bridge-shared

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

@module-federation/bridge-vue3

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

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

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

commit: d7d0d91

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 28, 2026

Bundle Size Report

14 package(s) changed, 27 unchanged.

Package dist + ESM entry

Package Total dist (raw) Delta ESM gzip Delta
@module-federation/cli 26.3 kB no change 786 B no change
@module-federation/core 39.1 kB no change 173 B no change
@module-federation/devtools 664.0 kB no change 4.0 kB no change
@module-federation/dts-plugin 311.3 kB +190 B (+0.1%) 4.6 kB -2 B (-0.0%)
@module-federation/enhanced 808.0 kB +90 B (+0.0%) 672 B no change
@module-federation/managers 69.8 kB no change 334 B no change
@module-federation/manifest 136.1 kB no change 182 B no change
@module-federation/metro-plugin-rnc-cli 0 B no change 314 B no change
@module-federation/node 193.4 kB no change 217 B no change
@module-federation/runtime 20.0 kB +13 B (+0.1%) 715 B no change
@module-federation/runtime-core 287.4 kB -8 B (-0.0%) 477 B no change
@module-federation/sdk 121.3 kB +4 B (+0.0%) 785 B no change
@module-federation/storybook-addon 78.6 kB no change 100 B no change
@module-federation/utilities 110.6 kB no change 328 B no change

Bundle targets

Package Web bundle (gzip) Delta Node bundle (gzip) Delta
@module-federation/cli 2.3 kB -35 B (-1.5%) 2.3 kB -35 B (-1.5%)
@module-federation/core 1.1 kB -34 B (-3.0%) 1.0 kB -32 B (-3.0%)
@module-federation/devtools 30.2 kB -29 B (-0.1%) 30.2 kB -29 B (-0.1%)
@module-federation/dts-plugin 14.3 kB +17 B (+0.1%) 14.3 kB +17 B (+0.1%)
@module-federation/enhanced 2.6 kB -47 B (-1.7%) 2.6 kB -47 B (-1.7%)
@module-federation/managers 2.4 kB -29 B (-1.2%) 2.4 kB -29 B (-1.2%)
@module-federation/manifest 6.1 kB -42 B (-0.7%) 6.1 kB -42 B (-0.7%)
@module-federation/metro-plugin-rnc-cli 411 B -27 B (-6.2%) 411 B -27 B (-6.2%)
@module-federation/node 9.2 kB -30 B (-0.3%) 9.2 kB -30 B (-0.3%)
@module-federation/runtime 687 B no change 687 B no change
@module-federation/runtime-core 15.2 kB no change 15.0 kB no change
@module-federation/sdk 4.5 kB no change 5.4 kB no change
@module-federation/storybook-addon 1.9 kB -26 B (-1.3%) 1.7 kB -26 B (-1.4%)
@module-federation/utilities 2.6 kB -34 B (-1.3%) 2.6 kB -34 B (-1.3%)

Consumer scenarios

Scenario Web output (gzip) Delta Node output (gzip) Delta Gap (node-web) Delta
Enhanced remoteEntry 21.4 kB -13 B (-0.1%) 22.5 kB -10 B (-0.0%) +1.1 kB +3 B

Total dist (raw): 6.80 MB (+289 B (+0.0%))
Total ESM gzip: 78.3 kB (-2 B (-0.0%))
Total web bundle (gzip): 206.5 kB (-316 B (-0.1%))
Total node bundle (gzip): 207.0 kB (-314 B (-0.1%))
Tracked ./bundler entry gzip: 556 B (no change)
Tracked ./bundler web bundle (gzip): 4.8 kB (no change)
Tracked ./bundler node bundle (gzip): 4.8 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.

@ScriptedAlchemy ScriptedAlchemy merged commit b9b3b8c into main May 29, 2026
14 checks passed
@ScriptedAlchemy ScriptedAlchemy deleted the fix/dts-plugin-windows-url-join branch May 29, 2026 02:52
@2heal1 2heal1 mentioned this pull request Jun 4, 2026
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.

dts-plugin fails to download types archive from localhost on windows

2 participants