fix(rslib): align isolated dts diagnostics#14143
Conversation
There was a problem hiding this comment.
Pull request overview
Aligns RslibPlugin’s isolated .d.ts reference-completion diagnostics with existing module-build error formatting (matching swc-loader), while preventing duplicate diagnostics for TS sources already present in the normal module graph.
Changes:
- Collect and attach reference-completion
.d.tsgeneration failures asModuleBuildErrordiagnostics on the compilation (instead of returning early), with request-formatteddiagnostic.file. - Avoid generating reference-completion diagnostics for TS sources already in the normal module graph by seeding a completed-resource set from module resources.
- Extend the existing stats output case to cover both direct and referenced isolated-dts failures (now expecting 3 errors).
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/rspack-test/statsOutputCases/rslib-emit-isolated-dts-error/sum.ts | Adds a TS module that triggers isolated declarations diagnostics. |
| tests/rspack-test/statsOutputCases/rslib-emit-isolated-dts-error/foo.ts | Adds a type-only referenced TS source that fails isolated declarations. |
| tests/rspack-test/statsOutputCases/rslib-emit-isolated-dts-error/reference.ts | Adds an entry that type-references foo.ts to exercise reference completion. |
| tests/rspack-test/statsOutputCases/rslib-emit-isolated-dts-error/rspack.config.js | Switches to multi-entry to ensure both direct and referenced failures appear in stats. |
| tests/rspack-test/statsOutputCases/rslib-emit-isolated-dts-error/snapshots/stats.txt | Updates snapshot to assert module-build formatted errors for both paths (3 total). |
| crates/rspack_plugin_rslib/src/plugin.rs | Collects module resources, runs completion with dedupe inputs, and extends compilation diagnostics. |
| crates/rspack_plugin_rslib/src/isolated_dts.rs | Returns assets + diagnostics, formats diagnostic file paths via absolute_to_request, and emits ModuleBuildError diagnostics for reference-completion failures. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Rsdoctor Bundle Diff AnalysisFound 5 projects in monorepo, 5 projects with changes. 📊 Quick Summary
📋 Detailed Reports (Click to expand)📁 popular-libsPath:
📁 react-10kPath:
📁 react-1kPath:
📁 react-5kPath:
📁 ui-componentsPath:
Generated by Rsdoctor GitHub Action |
📦 Binary Size-limit
❌ Size increased by 4.00KB from 61.75MB to 61.75MB (⬆️0.01%) |
Merging this PR will not alter performance
Comparing Footnotes
|
Summary
Fixes isolated dts reference-completion diagnostics in RslibPlugin so failures are collected into stats with the same module-build formatting as swc-loader while avoiding duplicate diagnostics for TypeScript sources already present in the normal module graph. The diagnostic file path now uses the existing request formatting helper, and the stats output case covers both direct and referenced dts failures.
Checklist