Bump root Babel deps to 8, fix a preset-typescript 8 parse bug - #49162
Draft
brijeshb42 wants to merge 9 commits into
Draft
brijeshb42 wants to merge 9 commits into
brijeshb42 wants to merge 9 commits into
Conversation
Deploy previewBundle size
Check out the code infra dashboard for more information about this PR. |
3 tasks
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
Not mergeable until mui-public#1875 merges and publishes real Babel-8 releases.
🤖 Generated with Claude Code