Script_too_large when use MUI components in Next Js app

When I use much MUI components in Next Js app, and deploy the app on cloudflare page it gives Error: Failed to publish your Function. Got error: Your Functions script is over the 1 MiB size limit (workers.api.error.script_too_large)

If I just use limited number of MUI component it works fine.

Not sure why using much MUI components increase script size, please help to fix this issue


You may have already been close to the size limit and the extra pushed you over. Mui is a relatively large library and you should really only import what you need.

I’d check all your dependencies and see which ones are taking up the most space and see if you can optimise your bundle.
You can also upgrade to Workers Paid for a limit of 10 MiB, you can see more on Workers limits here: Limits · Cloudflare Workers docs