Skip to content

[code-infra] Build packages with tsdown - #49802

Merged
brijeshb42 merged 8 commits into
mui:masterfrom
brijeshb42:brijesh/build-new
Nov 30, 2026
Merged

brijeshb42 merged 8 commits into
mui:masterfrom
brijeshb42:brijesh/build-new

Conversation

@brijeshb42

@brijeshb42 brijeshb42 commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Builds all packages except @mui/codemod with code-infra build-new (tsdown), from @mui/internal-code-infra@0.1.1-canary.41.

All packages are in alpha, so migrating now leaves time to find and fix any gaps in the new build before the stable release.

@mui/codemod stays on code-infra build: it loads transforms by file path at runtime, and build-new only emits files reachable from entries.

Changes

  • zero-styled: styled and useTheme are exported as local bindings. Otherwise the bundler points importers at ../styles/*, and Pigment CSS, which only transforms imports from a zero-styled path, skips the component styles.
  • Popover types: PopoverVirtualElement, PopoverRootProps and PopoverPaperProps are exported explicitly. tsdown appends export {} to Popover.d.ts, which turns off implicit exports.
  • Icons: "./_virtual/*": null is added to the exports map. A script keeps the license banner only in index files (~4 MB smaller).
  • @mui/internal-core-docs:
    • standardNavIcons has an explicit type.
    • VersionsContext is converted to TypeScript.
    • JSON imports are inlined.
    • The build info file is no longer published.

Verification

  • Exports, declaration names and runtime loading match a code-infra build of master, and @mui/material emits 186 fewer files.
  • pnpm release:build, pnpm docs:build and pnpm typescript (@mui/material) pass.
  • Pigment examples (Vite and Next.js) extract the same CSS as the published @mui/material@next.

Known gaps

Part of mui/mui-public#413

@code-infra-dashboard

code-infra-dashboard Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Deploy preview

https://deploy-preview-49802--material-ui.netlify.app/
QR code for https://deploy-preview-49802--material-ui.netlify.app/

Bundle size

Bundle Parsed size Gzip size
@mui/material 🔺+56B(+0.01%) ▼-227B(-0.14%)
@mui/lab 🔺+4B(+0.01%) ▼-6B(-0.07%)
@mui/private-theming 0B(0.00%) 0B(0.00%)
@mui/system 🔺+29B(+0.04%) 🔺+171B(+0.69%)
@mui/utils 0B(0.00%) 0B(0.00%)

Details of bundle changes

Performance

No regressions in 32 benchmarks · precise to ±9.1% (±14.8% at worst) · ran 4m 57s · details


Check out the code infra dashboard for more information about this PR.

@brijeshb42 brijeshb42 added the scope: code-infra Involves the code-infra product (https://www.notion.so/mui-org/5562c14178aa42af97bc1fa5114000cd). label Nov 16, 2026
@brijeshb42
brijeshb42 requested a review from a team November 16, 2026 11:27
@brijeshb42
brijeshb42 force-pushed the brijesh/build-new branch 3 times, most recently from cdbef70 to e9d37ed Compare November 17, 2026 05:37
@github-actions github-actions Bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Nov 17, 2026
@github-actions github-actions Bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Nov 17, 2026
@brijeshb42
brijeshb42 force-pushed the brijesh/build-new branch 2 times, most recently from d21c6c3 to a0efde0 Compare November 18, 2026 08:48
@brijeshb42

Copy link
Copy Markdown
Contributor Author

known diff in declarations: bare side-effect imports like import "../styles/index.js"; (142 .d.ts files in @mui/material, 58 .d.ts + .d.mts files in @mui/system). rolldown points import { Theme } from '../styles' at the declaring file (../styles/createThemeNoVars.js) and keeps the barrel as a side-effect import. types are unchanged and theme augmentation still works. details in mui/mui-public#2061

@github-actions github-actions Bot added PR: out-of-date The pull request has merge conflicts and can't be merged. and removed PR: out-of-date The pull request has merge conflicts and can't be merged. labels Nov 18, 2026
@@ -0,0 +1,31 @@
/* eslint-disable no-console */

@brijeshb42 brijeshb42 Nov 20, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is optional to strip banners from each file to reduce the package size due to the huge number of redundant files in the package.

@brijeshb42
brijeshb42 marked this pull request as ready for review November 20, 2026 12:59
@github-actions github-actions Bot added PR: out-of-date The pull request has merge conflicts and can't be merged. and removed PR: out-of-date The pull request has merge conflicts and can't be merged. labels Nov 20, 2026
@brijeshb42 brijeshb42 changed the title [code-infra] Build packages with tsdown [code-infra] Build internal packages with tsdown Nov 23, 2026
@github-actions github-actions Bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Nov 23, 2026
@brijeshb42 brijeshb42 changed the title [code-infra] Build internal packages with tsdown [code-infra] Build packages with tsdown Nov 23, 2026
@github-actions github-actions Bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Nov 23, 2026
@github-actions github-actions Bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Nov 24, 2026
Switch @mui/internal-api-docs-builder, @mui/internal-core-docs and
@mui/internal-docs-utils from `code-infra build` to `code-infra
build-new`.

core-docs needs two source changes for its declarations:

- `standardNavIcons` gets an explicit type. Its inferred declaration
  pointed at `packages/mui-material/src`, a path that doesn't exist in
  the published package and that build-new refuses to bundle.
- `VersionsContext` moves from JavaScript to TypeScript. build-new
  writes declarations for TypeScript sources only, so the context was
  re-exported without a declaration.

`tsBuildInfoFile` pointed into `build/`, so build-new published the
build info file. Without it the file stays out of the package, as in
api-docs-builder.
Switch the published packages from `code-infra build` to `code-infra
build-new`, which compiles with tsdown. Material UI is in alpha, so
build regressions surface before the stable release. build-new writes
tsgo declarations and the flat layout itself, so `--tsgo`, `--flat`
and `--skipBabelRuntimeCheck` go away.

mui-icons-material builds its committed `lib/` with build-new too.
build-new has no `--skipMainCheck`, so the unused source `main` field
goes; the published package.json still gets `main` from
merge-package-json. build-new adds the license header to every file,
which would add ~4 MB to the package, so a script keeps it only in
the index files, as before. `lib/` is regenerated with the next icons
update.

mui-codemod stays on `code-infra build`: it loads transforms by file
path at runtime, which an entry-based bundle doesn't emit.
The file has no export list, so TypeScript exports these declarations
implicitly. tsdown's declaration bundling appends `export {}`, which
turns that off; explicit exports keep the same public types.
Picks up the latest canary now that mui/mui-public#2096 is merged.

@Janpot Janpot left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Compared the pkg.pr.new builds against the merge base. Exports, runtime loading and types (all 4,714 exports assignable both ways) match. Three issues:

  • Imports of styled/useTheme no longer go through zero-styled (118 + 16 in @mui/material), which Pigment's tag resolver relies on, so Pigment integration likely breaks. (how much do we care?)
  • nextFonts/index.js in core-docs inlines a localFont() call into an array; Next.js requires font loaders assigned to a const. minify: false in build-new avoids it.
  • CJS output lost "use strict"; strict: true for the cjs format restores it.

0.1.1-canary.41 includes mui/mui-public#2127: build-new output stays
unminified, so Next.js font loaders stay assigned to a const, and CJS
files start with "use strict" again.

Export styled and useTheme from zero-styled as local bindings so the
bundler keeps importers pointed at zero-styled, which Pigment CSS's tag
resolver matches on.
code-infra 0.1.1-canary.41 resolves the hoisted @babel/preset-env against
@babel/core 8.1.3, while @mui/codemod still got 8.1.2. jscodeshift's worker
loads preset-env before installing its require hook, which preloaded the
codemod's @babel/core only while both used the same version. With two
versions, the hook compiled the ESM @babel/core 8.1.2 and the codemod CLI
test failed.
@github-actions github-actions Bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Nov 26, 2026
@github-actions github-actions Bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Nov 26, 2026
@github-actions github-actions Bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Nov 30, 2026
@github-actions github-actions Bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Nov 30, 2026
@brijeshb42
brijeshb42 requested a review from Janpot November 30, 2026 07:15
@brijeshb42
brijeshb42 merged commit dfb8a12 into mui:master Nov 30, 2026
20 checks passed
@brijeshb42
brijeshb42 deleted the brijesh/build-new branch November 30, 2026 16:03
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).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants