codesandbox / codesandbox/codesandbox-client
Missing essential files in dependencies
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 13.6k
- Forks
- 2.4k
- Avg merge
- 6d 19h
- Merged PRs (30d)
- 2
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/x-data-grid-pro@8.0.0-beta.3/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 |
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked CodeSandbox reproduction and inspect the dependency response for the missing nested esm/package.json mentioned in the report. Trace the dependency bundler's handling of that file and the ESM-to-CJS resolution transition. Done means the required package metadata is included and the linked sandbox no longer resolves the dependency incorrectly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100