fix(dts-plugin): normalize manifest type URLs on Windows#4774
Conversation
Fix consumeTypes manifest type URL resolution by switching to URL-based joins. Default the host family option to 0 for auto-selection.
🦋 Changeset detectedLatest commit: d7d0d91 The changes in this PR will be included in the next version bump. This PR includes changesets to release 46 packages
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 |
✅ Deploy Preview for module-federation-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
💡 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".
@module-federation/devtools
@module-federation/cli
create-module-federation
@module-federation/dts-plugin
@module-federation/enhanced
@module-federation/error-codes
@module-federation/esbuild
@module-federation/managers
@module-federation/manifest
@module-federation/metro
@module-federation/metro-plugin-rnc-cli
@module-federation/metro-plugin-rnef
@module-federation/metro-plugin-rock
@module-federation/modern-js
@module-federation/modern-js-v3
@module-federation/native-federation-tests
@module-federation/native-federation-typescript
@module-federation/nextjs-mf
@module-federation/node
@module-federation/observability-plugin
@module-federation/retry-plugin
@module-federation/rsbuild-plugin
@module-federation/rspack
@module-federation/rspress-plugin
@module-federation/runtime
@module-federation/runtime-core
@module-federation/runtime-tools
@module-federation/sdk
@module-federation/storybook-addon
@module-federation/third-party-dts-extractor
@module-federation/treeshake-frontend
@module-federation/treeshake-server
@module-federation/typescript
@module-federation/utilities
@module-federation/webpack-bundler-runtime
@module-federation/bridge-react
@module-federation/bridge-react-webpack-plugin
@module-federation/bridge-shared
@module-federation/bridge-vue3
@module-federation/inject-external-runtime-core-plugin
commit: |
Bundle Size Report14 package(s) changed, 27 unchanged. Package dist + ESM entry
Bundle targets
Consumer scenarios
Total dist (raw): 6.80 MB (+289 B (+0.0%)) Bundle sizes are generated with rslib (Rspack). Package-root metrics preserve the historical report. Tracked subpath exports such as |
Summary
This PR fixes two independent Windows bugs that together caused
dts-pluginto fail downloading type archives fromlocalhost:Bug 1: Windows backslashes corrupting HTTP URLs
DTSManager.requestRemoteManifest()usedpath.join(publicPath, manifestJson.metaData.types.zip)to construct the ZIP/API download URLs. On Windows,path.joinuses backslashes (\), which corrupts HTTP URLs:Passing this to
new URL()throwsInvalid URL.Fix: Use
new URL(relativePath, normalizedBaseUrl).hrefinstead. This correctly preserves forward slashes in URLs regardless of the host OS.Bug 2: IPv4-only forcing breaks Windows localhost connections
The
dts-plugindefaultedfamily: 4, which forces undici'sfetch()to use IPv4 only. On Windows,localhostresolves to::1(IPv6) by default, while Vite's dev server binds to::1:4173. The client then tries to connect to127.0.0.1:4173(IPv4) and getsECONNREFUSEDbecause the server is not listening on the IPv4 loopback.Fix: Change the default
familyfrom4to0(auto-select). Withfamily: 0,createDispatcherFromFamily()returnsundefined(no custom Agent), sofetch()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
family?: 4 | 6→family?: 0 | 4 | 6enum: [4, 6]→enum: [0, 4, 6]0as the defaultTest 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.mtspnpm --filter @module-federation/dts-plugin run buildpnpm --filter @module-federation/sdk run buildpnpm --filter @module-federation/enhanced run buildpnpm 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.mdgit diff --checkKnown Validation Gap
pnpm --filter @module-federation/dts-plugin run teststill fails in pre-existing unrelatedtypeScriptCompiler.test.ts/DtsWorker.spec.tsTYPE-001 cases (118 passed, 9 failed locally)Closes #4415