Skip to content

fix(dts): preserve source root in temporary type-generation projects #4948

Description

@zackarychapple

TAP/Zephyr workflow audit item 20: Fix temporary DTS project root inference and preserve diagnostics

Target: Module Federation DTS package owner
Type: Bug
Priority: P1
Suggested labels: bug, dts, typescript, diagnostics

Problem

The DTS plugin writes a temporary TypeScript project under node_modules/.federation. When the source project omits an explicit rootDir, TypeScript can infer the temporary directory as the project root and report TS6059 for exposed files under the real src directory. Default temporary-config deletion also removes the most useful reproduction evidence.

Reproduction

Use an Rsbuild remote with an exposed src component, DTS enabled, and a TypeScript config without explicit rootDir. Trigger type generation and inspect the generated temporary config and listFilesOnly/TYPE-001 path.

Proposed change

Carry the source project’s effective root semantics into the temporary project or compute a safe common source root. Preserve diagnostic artifacts automatically when generation fails.

Acceptance criteria

  • An exposed source file outside .federation does not fail solely because the temporary config lives under .federation.
  • Explicit user rootDir behavior remains unchanged.
  • Projects without rootDir receive a deterministic effective root that includes all exposed and dependent source files.
  • Windows paths, symlinks, workspace packages, and paths outside the package root are covered.
  • The exact compiler command, effective temporary config, TypeScript version, and diagnostic log are preserved after failure.
  • deleteTsConfig: true deletes successful temporary state but retains or copies failed-run diagnostics to a documented location.
  • The error identifies the fatal compiler diagnostic separately from any fallback warning.
  • Tests cover TypeScript 5.x and supported 7.x peer ranges.
  • Existing successful @mf-types.zip generation remains unchanged.
  • Troubleshooting documentation describes the retained artifacts and reproduction command.

Verification evidence

Attach a regression fixture reproducing the original TS6059 shape before the fix and passing after it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions