Skip to content

Comments

[code-infra] Setup flat build for packages#47670

Merged
brijeshb42 merged 2 commits intomui:masterfrom
brijeshb42:flat-build
Feb 23, 2026
Merged

[code-infra] Setup flat build for packages#47670
brijeshb42 merged 2 commits intomui:masterfrom
brijeshb42:flat-build

Conversation

@brijeshb42
Copy link
Contributor

@brijeshb42 brijeshb42 commented Jan 23, 2026

  1. No more esm subdirectory inside build for es module files
  2. Output is as per package.json's type value
  3. For module, js files corresponds to esm and cjs files correspond to
    commonjs.
  4. For commonjs or no value, js files are commonjs and mjs files
    correspond to module/esm.
  5. Same for dts file, it'll be d.ts and d.mts for commonjs and
    d.ts and d.cts for module.
  6. Special handling had to be done for @mui/icons-material since it already has the prebuilt files. I built the files again into lib and removed old lib directory. Updated its scripts to output mjs and d.mts files as well.
  7. All globs in package.json are now expanded to point to the files directly to have maximum bundler support (including codesandbox and stackblitz).
  8. Exports in some of the packages have been updated to point to the exact file sine we can have only one of "./*": "./src/*/index.ts" or "./*": "./src/*/index.js"

While reviewing, please ignore the last commit has it has auto-generated files from icons package.

@brijeshb42 brijeshb42 requested a review from a team January 23, 2026 10:16
@brijeshb42 brijeshb42 added the scope: code-infra Involves the code-infra product (https://www.notion.so/mui-org/5562c14178aa42af97bc1fa5114000cd). label Jan 23, 2026
@mui-bot
Copy link

mui-bot commented Jan 23, 2026

Netlify deploy preview

https://deploy-preview-47670--material-ui.netlify.app/

Bundle size report

Bundle Parsed size Gzip size
@mui/material 0B(0.00%) 0B(0.00%)
@mui/lab 0B(0.00%) 0B(0.00%)
@mui/system 0B(0.00%) 0B(0.00%)
@mui/utils 0B(0.00%) 0B(0.00%)

Details of bundle changes

Generated by 🚫 dangerJS against 029f7af

@brijeshb42 brijeshb42 force-pushed the flat-build branch 2 times, most recently from 538021a to ffaafcb Compare January 23, 2026 17:31
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Jan 24, 2026
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Jan 26, 2026
@brijeshb42 brijeshb42 force-pushed the flat-build branch 3 times, most recently from 0726c3b to 215cbb3 Compare January 27, 2026 10:32
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Jan 28, 2026
@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 Feb 10, 2026
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Feb 10, 2026
@brijeshb42 brijeshb42 force-pushed the flat-build branch 4 times, most recently from 9da8f34 to 83de605 Compare February 11, 2026 16:59
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Feb 11, 2026
@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 Feb 11, 2026
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Feb 19, 2026
@brijeshb42 brijeshb42 requested a review from a team February 19, 2026 13:33
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Feb 19, 2026
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Feb 19, 2026
- run:
name: Analyze exported typescript
command: pnpm test:attw
no_output_timeout: 20m
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It takes more time by attw since it now checks the paths individually. It used to skip the * paths.

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Feb 19, 2026
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Feb 19, 2026
"author": "MUI Team",
"description": "Codemod scripts for Material UI.",
"bin": "./codemod.js",
"bin": "./src/codemod.js",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will get transformed after build.

"test": "pnpm --workspace-root test:unit --project \"*:@mui/icons-material\"",
"typescript": "tsc -p tsconfig.json",
"attw": "attw --pack ./build --exclude-entrypoints esm --include-entrypoints Close"
"attw-icons": "attw --pack ./build"
Copy link
Contributor Author

@brijeshb42 brijeshb42 Feb 20, 2026

Choose a reason for hiding this comment

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

Changed the script name so that it does not run with pnpm test:attw since it'll take too much time to validate with so many new entries and block the CI.
Instead, it'll now run whenever the files are built again.

},
"exports": {
"./NProgressBar": "./src/NProgressBar/index.js",
"./SectionTitle": "./src/SectionTitle/index.tsx",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Explicit exports for non .ts files.

"./transitions": "./src/transitions/index.ts",
"./useLazyRipple": "./src/useLazyRipple/index.ts",
"./version": "./src/version/index.ts",
"./*": "./src/*/index.js"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Explicit listing of .ts entrypoints since they are less in number than .js entrypoints.

@brijeshb42 brijeshb42 force-pushed the flat-build branch 2 times, most recently from 43ff752 to 74f1553 Compare February 20, 2026 12:03
1. No more `esm` subdirectory inside `build` for es module files
2. Output is as per package.json's type value
3. For module, js files corresponds to esm and cjs files correspond to
commonjs.
4. For commonjs or no value, js files are commonjs and mjs files
correspond to module/esm.
5. Same for dts file, it'll be `d.ts` and `d.mts` for commonjs and
`d.ts` and `d.cts` for module.
@siriwatknp
Copy link
Member

Copy link
Member

@siriwatknp siriwatknp left a comment

Choose a reason for hiding this comment

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

👍 Two questions

  • Would this PR improve speed for bundling @mui/icons-material from the user-land in any way?
  • Is this consider a breaking change? or at least would it impact any project setup?

@brijeshb42
Copy link
Contributor Author

Would this PR improve speed for bundling @mui/icons-material from the user-land in any way?

Not really if they are using barrel imports.

Is this consider a breaking change? or at least would it impact any project setup?

Its not a breaking change. I want to test this in alpha though just in case. If everything works, we can look into back-porting it.
If someone has setup some kind of aliasing in their bundler setup to point to the esm folder directly, then they are using undocumented private paths which will break for them.

@brijeshb42 brijeshb42 merged commit 89071b1 into mui:master Feb 23, 2026
23 checks passed
@brijeshb42 brijeshb42 deleted the flat-build branch February 23, 2026 03:59
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.

3 participants