[docs-infra] Fix import of cjs react-simple-code-editor in esm#48349
Conversation
Bundle size
Deploy previewhttps://deploy-preview-48349--material-ui.netlify.app/ Check out the code infra dashboard for more information about this PR. |
This is needed to make the package work correctly in mui-x
|
Is it possible to align bundler configurations such that the import can be consistent? |
Not sure I understand. We maye be consuming all kinds of packages. One may have This would have worked fine if the library also had esm. I see that @oliviertassinari is maintainer of the package, so maybe its possible. |
I can publish changes indeed to |
|
I think we can live with this one-line hack till then. |
|
I guess my point is, importing CJS from ESM is not uncommon and now supported under node.js. I'm just surprised we can't configure our docs bundlers to behave the same way. It's not like our bundles are shipping raw ESM to the browsers, so why isn't it possible to make it do synthetic default import for this case? And why is it happining on MUI X and not on material-ui? Is it because we're transpiling the package with Next.js on core repo?
Sure, but if it's a one-liner in a bundler configuration on the MUI X side that fixes it for all future cases, then I think I'd prefer that. Otherwise, yes, we can live with it. |
Yes. mui core docs: next.config.ts aliases @mui/internal-core-docs → src/. Webpack rule runs babel on everything under workspace root. So the code gets compiled by babel with default interop which makes it work. mui-x docs: consumes published @mui/internal-core-docs from node_modules. Next 15 externalizes node_modules packages for server bundle. That's why the build was failing on X during the page pre-rendering phase, with React's |
There was a problem hiding this comment.
mui-x docs: consumes published @mui/internal-core-docs from node_modules.
I suppose one solution then could be to compile in the synthetic default import with our build tooling then? Can it be whitelisted only for a specific package? Maybe that makes our build tooling harder to port?
|
I think its better to just patch the package on our side to also add I already tried adding the package to next's |
This is needed to make the package work correctly in mui-x.
Also -