Skip to content

fix: prevent dts build crash#1

Closed
Nsttt wants to merge 6 commits intomainfrom
fix/dts-build-no-crash
Closed

fix: prevent dts build crash#1
Nsttt wants to merge 6 commits intomainfrom
fix/dts-build-no-crash

Conversation

@Nsttt
Copy link
Owner

@Nsttt Nsttt commented Jan 22, 2026

Summary

  • guard dts build normalization/validation to avoid crash
  • add regression test for invalid dts options

Testing

  • pnpm test -- --run

Copilot AI review requested due to automatic review settings January 22, 2026 10:11
@Nsttt Nsttt closed this Jan 22, 2026
Copy link

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

This PR adds DTS (TypeScript definitions) plugin integration to the Vite Module Federation plugin to prevent build crashes when DTS options are invalid. The change guards DTS build normalization and validation with try-catch blocks and includes a regression test.

Changes:

  • Adds @module-federation/dts-plugin dependency for TypeScript definition generation and consumption
  • Implements error handling around DTS option normalization to prevent build crashes
  • Updates pnpm version to 9.14.2 across all CI workflows for consistency

Reviewed changes

Copilot reviewed 12 out of 13 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/utils/normalizeModuleFederationOptions.ts Adds comprehensive TypeScript interfaces for DTS plugin options (PluginDtsOptions, DtsRemoteOptions, DtsHostOptions, RemoteTypeUrl, RemoteTypeUrls)
src/plugins/pluginDts.ts New plugin implementation with error guards around normalizeDtsOptions, normalizeConsumeTypesOptions, and normalizeGenerateTypesOptions calls to prevent crashes
src/plugins/tests/pluginDts.test.ts Regression test verifying that invalid DTS options don't throw errors during build
src/index.ts Integrates the new pluginDts into the main plugin array
package.json Adds @module-federation/dts-plugin@^0.21.6 dependency and bumps version to 1.9.6
pnpm-lock.yaml Updates lockfile with new dts-plugin dependencies and their transitive dependencies
examples/vite-vite/vite-remote/vite.config.js Adds DTS configuration example for remote with generateTypes enabled
examples/vite-vite/vite-host/vite.config.js Adds DTS configuration example for host with consumeTypes enabled
examples/vite-vite/vite-remote/tsconfig.json New TypeScript configuration for the remote example
examples/vite-vite/vite-host/tsconfig.json New TypeScript configuration for the host example
.github/workflows/unit-test.yml Updates pnpm version to 9.14.2
.github/workflows/linter.yml Updates pnpm version to 9.14.2
.github/workflows/e2e-test.yml Updates pnpm version to 9.14.2
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

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

} as ResolvedConfig;

buildPlugin?.configResolved?.(config);
await expect(buildPlugin?.generateBundle?.()).resolves.toBeUndefined();
Copy link

Copilot AI Jan 22, 2026

Choose a reason for hiding this comment

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

The generateBundle hook should be called with the proper Vite/Rollup plugin parameters. According to the Rollup plugin API, generateBundle receives two parameters: options and bundle. While the implementation doesn't use these parameters, the test should call the method with the expected signature to properly simulate how Vite would invoke this hook. Consider updating the test to call it as buildPlugin?.generateBundle?.({}, {}) to match the actual plugin API.

Suggested change
await expect(buildPlugin?.generateBundle?.()).resolves.toBeUndefined();
await expect(buildPlugin?.generateBundle?.({}, {})).resolves.toBeUndefined();

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants