Skip to content

Bump root Babel deps to 8, fix a preset-typescript 8 parse bug - #49162

Draft
brijeshb42 wants to merge 9 commits into
mui:masterfrom
brijeshb42:babel-8
Draft

brijeshb42 wants to merge 9 commits into
mui:masterfrom
brijeshb42:babel-8

Conversation

@brijeshb42

@brijeshb42 brijeshb42 commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Companion to mui/mui-public#1875. Material-ui's root babel dependencies must also bump from 7.x to 8.x to avoid API version mismatches when @mui/internal-code-infra consumes Babel 8.

Fixed 1 preset-typescript@8 parse bug (trailing comma in generic defaults for .ts files).

Test results

Babel 8 migration validated locally:

  • ✓ pnpm test:node: 6663 tests pass
  • ✓ pnpm test:browser: 6446 tests pass
  • ✓ babel-plugin-optimize-clsx: works in prod builds
  • ✓ babel-plugin-transform-react-remove-prop-types: works in prod builds

Not mergeable until mui-public#1875 merges and publishes real Babel-8 releases.

🤖 Generated with Claude Code

@code-infra-dashboard

code-infra-dashboard Bot commented Sep 18, 2026

Copy link
Copy Markdown

Deploy preview

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

Bundle size

Bundle Parsed size Gzip size
@mui/material 🔺+71B(+0.01%) 🔺+27B(+0.02%)
@mui/lab 0B(0.00%) 0B(0.00%)
@mui/private-theming 0B(0.00%) 0B(0.00%)
@mui/system 🔺+5B(+0.01%) ▼-1B(0.00%)
@mui/utils 0B(0.00%) 0B(0.00%)

Details of bundle changes


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

@github-actions github-actions Bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Sep 21, 2026
@github-actions github-actions Bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Sep 21, 2026
brijeshb42 and others added 3 commits September 21, 2026 15:04
Companion to mui/mui-public#1875, which migrates @mui/internal-
code-infra (and the rest of the mui-public babel toolchain) to
Babel 8. Bumps this repo's own root @babel/core, @babel/node, and
@babel/plugin-transform-react-constant-elements to match - once
code-infra pulls in @babel/core 8, a mismatched local Babel 7
plugin throws BABEL_VERSION_UNSUPPORTED.

Also works around a real @babel/preset-typescript@8.0.1 bug: its
per-extension disallowAmbiguousJSXLike value is swapped for .ts
vs .mts, so a plain .ts file's generic arrow function with a
default type param (`<T = unknown>(...)`) gets misparsed as a JSX
open tag once @babel/preset-react is also in the pipeline (which
this repo's babel.config.mjs always includes). The standard TS
disambiguation fix - a trailing comma, `<T = unknown,>` - avoids
it; only one call site in the repo hits the pattern (function
declarations and interfaces with the same generic-default shape
aren't ambiguous, only bare arrow-function expressions are).

## Not independently mergeable yet
`@mui/internal-code-infra` on npm is still Babel-7-based until
mui-public#1875 merges and publishes. This PR alone will fail CI
until then.

## Test plan
Verified locally against mui-public#1875's pkg.pr.new build
(`@mui/internal-code-infra`, `@mui/internal-test-utils`,
`@mui/internal-netlify-cache`, and the three internal babel plugin
packages), with this change applied on top:
- `pnpm --filter "@mui/material..." run build` - @mui/material
  (656 files), @mui/system, @mui/utils, @mui/private-theming,
  @mui/styled-engine, @mui/material-pigment-css, @mui/types all
  compile and emit types cleanly
- `pnpm --filter "@mui/material..." run typescript` - clean
- babel-plugin-transform-react-remove-prop-types confirmed working:
  Button.js source has 28 PropTypes. references, built output has 0
- babel-plugin-optimize-clsx ran without error across the whole
  build (auto-enabled since @mui/material depends on clsx)
- vitest (node/jsdom scope) across @mui/material + @mui/system +
  @mui/utils: 5619/5619 tests pass

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Makes this PR's own CI actually exercise the Babel 8 packages
instead of just asserting compatibility. Overrides @mui/internal-
code-infra, @mui/internal-test-utils, @mui/internal-netlify-cache,
and the three internal babel plugin packages to mui-public#1875's
pkg.pr.new build, and disables blockExoticSubdeps since code-infra
pulls those babel plugins in as pkg.pr.new URL subdeps.

To drop once mui-public#1875 merges and publishes: remove this
override block, restore blockExoticSubdeps: true, and bump the
@mui/internal-* versions in package.json normally.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Prettier removed the trailing comma which is needed for Babel 8
parser strictness with TypeScript generics
Use 'import type' for type-only imports to prevent
Babel stripping types that are used only in type annotations
Babel 8 strips type-only exports, so imports of Interpolation, Theme,
ColorSystemOptions, and GlobalStylesProps must use the \`type\` keyword.

Fixed in:
- packages/mui-material/src/styles/overrides.ts
- packages/mui-material/src/styles/variants.ts
- packages/mui-material/src/zero-styled/index.tsx
- packages/mui-material/src/utils/memoTheme.ts
- packages/mui-material/src/styles/createTheme.ts

Fixes test_types, test_static, and test_bundle_size_monitor CI failures.
The new build restores full type-only import elision under Babel 8.

traverseBreakpoints kept a `<T = unknown,>` trailing comma that Babel 8
requires but prettier strips on every run. A function declaration
parses fine without it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant