material-ui icon indicating copy to clipboard operation
material-ui copied to clipboard

[POC][Do not merge] ESM module distribution improvements

Open DiegoAndai opened this issue 1 year ago • 2 comments

POC for improving the ESM module distribution of the packages.

  • Add exports key pointing to import and require files
  • Add file extensions with babel-plugin-add-import-extension

Missing:

  • Types
  • UMD build broke, have to figure out why, removed it for the POC

DiegoAndai avatar Feb 14 '24 21:02 DiegoAndai

Netlify deploy preview

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

@material-ui/core: parsed: -3.37% :heart_eyes:, gzip: -2.61% :heart_eyes: @material-ui/lab: parsed: -4.09% :heart_eyes:, gzip: -3.18% :heart_eyes: @material-ui/system: parsed: +0.62% , gzip: +0.57% @material-ui/unstyled: parsed: +0.40% , gzip: +0.42% @material-ui/utils: parsed: +3.44% , gzip: +3.24% @mui/material-next: parsed: -4.26% :heart_eyes:, gzip: -2.70% :heart_eyes: @mui/joy: parsed: +0.10% , gzip: +0.17%

Bundle size report

Details of bundle changes (Toolpad) Details of bundle changes

Generated by :no_entry_sign: dangerJS against ea4973c27bcc1c426a91a72db6cfa464b01336ee

mui-bot avatar Feb 14 '24 21:02 mui-bot

The first test is working as expected ✅

The next step is to sort out the CI test suite.

DiegoAndai avatar Feb 14 '24 22:02 DiegoAndai

All of this looks reasonable to me 👍

Janpot avatar Feb 19 '24 11:02 Janpot

Regarding the CI issues. It looks like the snapshot size test is looking for the umd build. Which was removed in this PR. We can also get rid of it in snapshot collection.

diff --git a/scripts/sizeSnapshot/create.js b/scripts/sizeSnapshot/create.js
index b8b68e60b4..1ed2f343e1 100644
--- a/scripts/sizeSnapshot/create.js
+++ b/scripts/sizeSnapshot/create.js
@@ -56,11 +56,7 @@ async function getWebpackSizes(webpackEnvironment) {
 async function run(argv) {
   const { analyze, accurateBundles } = argv;
 
-  const rollupBundles = [path.join(workspaceRoot, 'packages/mui-material/size-snapshot.json')];
-  const bundleSizes = lodash.fromPairs([
-    ...(await getWebpackSizes({ analyze, accurateBundles })),
-    ...lodash.flatten(await Promise.all(rollupBundles.map(getRollupSize))),
-  ]);
+  const bundleSizes = lodash.fromPairs(await getWebpackSizes({ analyze, accurateBundles }));
 
   await fse.writeJSON(snapshotDestPath, bundleSizes, { spaces: 2 });
 }

Janpot avatar Mar 14 '24 09:03 Janpot