Description
🐛 bug report
Preflight Checklist
- I have read the Contributing Guidelines for this project.
- I agree to follow the Code of Conduct that this project
adheres to. - I have searched the issue tracker for an issue that matches the one I want
to file, without success.
Description of the problem
At MUI, we're using codesandbox on our docs. In our latest reease we noticed some sandboxes that are broken. e.g. https://codesandbox.io/embed/yj3yn5
Yet downloaded and running locally, or in a devbox, this code works.
I'm looking a bit at the stacktrace that is produced and I notice something odd:
When resolving mui/x-data-grid
from mui/x-data-grid-pro
, it seems to switch from esm to cjs. It's noticable because the ESM sources of all of our packages live under a /esm folder, yet at some point in the stacktrace this segment disappears.
The sources are marked as ESM because the folder also contains a package.json with "type": "module"
.
I dig a bit deeper in the network tab and look through the response that seems to contain the dependency files. And I notice this specific package.json is missing:
However, it does exist in the package: https://cdn.jsdelivr.net/npm/@mui/[email protected]/esm/package.json
Could it be that your dependency bundler is omitting nested json files? It would definitely explain why the stacktraces switches from esm to cjs on the first import of another internal package. Which in turn could explain the singleton being loaded twice, which could lead to the error we see. It's all a bit speculative, but the sandboxes can be so hard to debug when you have no access to the underlying node_modules folder.
How has this issue affected you? What are you trying to accomplish?
Many of our demos are broken in our upcoming release.
To Reproduce
Link to sandbox: link (optional)
Your Environment
Software | Name/Version |
---|---|
Сodesandbox | |
Browser | |
Operating System |