[core] Remove `'use client'` from index files and useAutocomplete reexport
Remove 'use client' from:
- index files
- useAutocomplete material-ui reexport file. This required a minor modification of the
buildRscscript.
This is to avoid an issue with Next.js that surfaced in https://github.com/mui/material-ui/pull/41596:
Error: It's currently unsupported to use "export *" in a client boundary. Please use named exports instead.
Also suggested in https://github.com/mui/material-ui/pull/40358#issuecomment-1872254225.
There's no use of 'use client' in index files.
Netlify deploy preview
https://deploy-preview-41956--material-ui.netlify.app/
Bundle size report
Details of bundle changes (Toolpad) Details of bundle changes
Generated by :no_entry_sign: dangerJS against 32d0f0a671c430e6ec76e655261c38c23adde505
Nice, a continuation of https://github.com/mui/material-ui/pull/40663.
I'm confused to why Next.js can't properly handle "use client" in barrel files, it sounds off. But in any cases, it makes sense to me to toggle between client and server bundles at the lowest possible level.
I proposed the same change for Base UI: https://github.com/mui/base-ui/issues/330
@DiegoAndai I'm adding the following to the no-restricted-syntax rule in eslint to prevent the pattern from re-entering in the future:
{
message: "The 'use client' pragma can't be used with export * in the same module. This is not supported by Next.js.",
selector: 'ExpressionStatement[expression.value="use client"] ~ ExportAllDeclaration',
},
Thanks @Janpot 😊