Repository navigation
[code-infra] Keep reference lib directives in build-new declarations - #2170
Conversation
rolldown-plugin-dts drops a `/// <reference lib="..." />` directive when an import or a re-export follows it. The new dtsLibReferencesPlugin moves each lib directive to the top of its module's declarations, in the ESM and the CJS declaration passes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Deploy previewBundle sizeTotal Size Change: 0B(0.00%) - Total Gzip Change: 0B(0.00%) Show details for 79 more bundles@mui/internal-docs-infra/abstractCreateDemo parsed: 0B(0.00%) gzip: 0B(0.00%) PerformanceNo regressions in 12 benchmarks · precise to ±14.6% (±35.1% at worst) · ran 1m 17s · details Check out the code infra dashboard for more information about this PR. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
code-infra build-newdrops a/// <reference lib="..." />directive from the declarations when an import or a re-export follows it. rolldown-plugin-dts keeps onlypathandtypesreferences (REFERENCE_REinsrc/fake-js/utils.ts, unchanged in v0.30.4). Alibdirective stays only as the leading comment of a declaration. The upstream issue is sxzz/rolldown-plugin-dts#395.This breaks the Menu2 PR mui/material-ui#48823. Its
Unstable_Menu2/index.tsstarts with/// <reference lib="es2020.intl" preserve="true" />, because the Base UI menu types useIntl.LocalesArgumentand the documented minimum config is"lib": ["es6", "dom"]. The build has no directive, so themenu2ThemeOnlymodule augmentation test fails with TS2694.The new
dtsLibReferencesPluginremoves thelibdirectives from each declaration module before rolldown-plugin-dts transforms it. Then it adds them back at the top of the module's.d.tsand.d.mtsoutput. The removal prevents a duplicate where rolldown-plugin-dts keeps a directive.Verification
On the head of mui/material-ui#48823 (f3b58f0123):
@mui/materialbuild differs from the0.1.1-canary.41build only by the directive on line 1 ofUnstable_Menu2/index.d.tsandindex.d.mts.menu2ThemeOnlyfails with the TS2694 errors from CI.Generated with Claude Code