Skip to content

[code-infra] Keep reference lib directives in build-new declarations - #2170

Merged
LukasTy merged 2 commits into
mui:masterfrom
LukasTy:claude/build-new-dts-lib-references-8feb48
Dec 4, 2026
Merged

LukasTy merged 2 commits into
mui:masterfrom
LukasTy:claude/build-new-dts-lib-references-8feb48

Conversation

@LukasTy

@LukasTy LukasTy commented Dec 4, 2026 •

Copy link
Copy Markdown
Member

code-infra build-new drops a /// <reference lib="..." /> directive from the declarations when an import or a re-export follows it. rolldown-plugin-dts keeps only path and types references (REFERENCE_RE in src/fake-js/utils.ts, unchanged in v0.30.4). A lib directive 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.ts starts with /// <reference lib="es2020.intl" preserve="true" />, because the Base UI menu types use Intl.LocalesArgument and the documented minimum config is "lib": ["es6", "dom"]. The build has no directive, so the menu2ThemeOnly module augmentation test fails with TS2694.

The new dtsLibReferencesPlugin removes the lib directives from each declaration module before rolldown-plugin-dts transforms it. Then it adds them back at the top of the module's .d.ts and .d.mts output. The removal prevents a duplicate where rolldown-plugin-dts keeps a directive.

Verification

On the head of mui/material-ui#48823 (f3b58f0123):

  • The @mui/material build differs from the 0.1.1-canary.41 build only by the directive on line 1 of Unstable_Menu2/index.d.ts and index.d.mts.
  • All 37 module augmentation fixtures pass. Without this PR, menu2ThemeOnly fails with the TS2694 errors from CI.

Generated with Claude Code

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>
@LukasTy LukasTy added type: bug It doesn't behave as expected. scope: code-infra Involves the code-infra product (https://www.notion.so/mui-org/5562c14178aa42af97bc1fa5114000cd). labels Dec 4, 2026
@code-infra-dashboard

code-infra-dashboard Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Deploy preview

https://deploy-preview-2170--mui-internal.netlify.app/
QR code for https://deploy-preview-2170--mui-internal.netlify.app/

Bundle size

Total Size Change: 0B(0.00%) - Total Gzip Change: 0B(0.00%)
Files: 79 total (0 added, 0 removed, 0 changed)

Show details for 79 more bundles

@mui/internal-docs-infra/abstractCreateDemo parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/abstractCreateDemoClient parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/abstractCreateStream parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/abstractCreateTypes parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/ChunkProvider parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/cli parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/CodeControllerContext parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/CodeExternalsContext parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/CodeHighlighter parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/CodeHighlighter/errors parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/CodeHighlighter/types parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/CodeProvider parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/CoordinatedLazy parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/CoordinatedLazy/types parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/createDemoData parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/createDemoData/types parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/createSitemap parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/createSitemap/types parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/resolvePageUrl parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/routeGroups parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useCode parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useCodeWindow parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useCoordinated parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useCopier parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useDemo parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useDemoController parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useErrors parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useLocalStorageState parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/usePreference parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useScrollAnchor parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useSearch parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useSearch/types parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useStream parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useStream/types parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useType parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useTypes parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useUrlHashState parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/withDocsInfra parsed: 0B(0.00%) gzip: 0B(0.00%)
addLineGutters parsed: 0B(0.00%) gzip: 0B(0.00%)
applyCodeTransformWithComments parsed: 0B(0.00%) gzip: 0B(0.00%)
BuildEngine parsed: 0B(0.00%) gzip: 0B(0.00%)
CodeEditor parsed: 0B(0.00%) gzip: 0B(0.00%)
CodeHighlighterChunk parsed: 0B(0.00%) gzip: 0B(0.00%)
CodeHighlighterClient parsed: 0B(0.00%) gzip: 0B(0.00%)
CodeInitialSourceLoader parsed: 0B(0.00%) gzip: 0B(0.00%)
CodeSourceLoader parsed: 0B(0.00%) gzip: 0B(0.00%)
compileCssWithPostcss parsed: 0B(0.00%) gzip: 0B(0.00%)
computeHastDeltas parsed: 0B(0.00%) gzip: 0B(0.00%)
createFrame parsed: 0B(0.00%) gzip: 0B(0.00%)
createParseSourceWorkerClient parsed: 0B(0.00%) gzip: 0B(0.00%)
embedTransforms parsed: 0B(0.00%) gzip: 0B(0.00%)
enhanceCodeEmphasis parsed: 0B(0.00%) gzip: 0B(0.00%)
findExpandingRanges parsed: 0B(0.00%) gzip: 0B(0.00%)
frameVisibility parsed: 0B(0.00%) gzip: 0B(0.00%)
getHastTextContent parsed: 0B(0.00%) gzip: 0B(0.00%)
grammarCache parsed: 0B(0.00%) gzip: 0B(0.00%)
grammarLoaders parsed: 0B(0.00%) gzip: 0B(0.00%)
grammarMaps parsed: 0B(0.00%) gzip: 0B(0.00%)
grammars parsed: 0B(0.00%) gzip: 0B(0.00%)
hastUtils parsed: 0B(0.00%) gzip: 0B(0.00%)
isFrameSpan parsed: 0B(0.00%) gzip: 0B(0.00%)
loadCodeFallback parsed: 0B(0.00%) gzip: 0B(0.00%)
loadIsomorphicCodeVariant parsed: 0B(0.00%) gzip: 0B(0.00%)
parseSource parsed: 0B(0.00%) gzip: 0B(0.00%)
rolldown-runtime parsed: 0B(0.00%) gzip: 0B(0.00%)
source.css parsed: 0B(0.00%) gzip: 0B(0.00%)
source.diff parsed: 0B(0.00%) gzip: 0B(0.00%)
source.js parsed: 0B(0.00%) gzip: 0B(0.00%)
source.json parsed: 0B(0.00%) gzip: 0B(0.00%)
source.mdx parsed: 0B(0.00%) gzip: 0B(0.00%)
source.shell parsed: 0B(0.00%) gzip: 0B(0.00%)
source.ts parsed: 0B(0.00%) gzip: 0B(0.00%)
source.tsx parsed: 0B(0.00%) gzip: 0B(0.00%)
source.yaml parsed: 0B(0.00%) gzip: 0B(0.00%)
SourceEditingEngine parsed: 0B(0.00%) gzip: 0B(0.00%)
text.html.basic parsed: 0B(0.00%) gzip: 0B(0.00%)
text.md parsed: 0B(0.00%) gzip: 0B(0.00%)
TransformEngine parsed: 0B(0.00%) gzip: 0B(0.00%)
transpileSource parsed: 0B(0.00%) gzip: 0B(0.00%)

Details of bundle changes

Performance

No 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>
@LukasTy
LukasTy marked this pull request as ready for review December 4, 2026 13:39
@Janpot
Janpot requested a review from brijeshb42 December 4, 2026 14:24

@brijeshb42 brijeshb42 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the fix

@LukasTy
LukasTy merged commit 4c78870 into mui:master Dec 4, 2026
17 checks passed
@LukasTy
LukasTy deleted the claude/build-new-dts-lib-references-8feb48 branch December 4, 2026 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: code-infra Involves the code-infra product (https://www.notion.so/mui-org/5562c14178aa42af97bc1fa5114000cd). type: bug It doesn't behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants