codesandbox / codesandbox/codesandbox-client
Unexpected Token - optional chaining in an npm package
@DeMoorJasper is already working on this.
Since Jan 4, 2023.
- Dominant language
- JavaScript
- Stars
- 13.6k
- Forks
- 2.4k
- Avg merge
- 6d 19h
- Merged PRs (30d)
- 2
Description
Bug report
Packages affected
- sandpack-client
- sandpack-react
Description of the problem
When I import an npm package which uses optional chaining it throws an error "Unexpected token":
/node_modules/@swedbankpay/design-guide/src/scripts/main/dropdown/index.js: Unexpected token (17:51)
15 | const toggleMenu = container => isOpen(container) ? closeMenu(container) : openMenu(container);
16 |
> 17 | const toggleBtnListener = e => toggleMenu(e.target?.closest(".dropdown"));
| ^
18 |
19 | const listenToToggleBtn = toggleBtn => {
20 | try {
I tried adding environment: "parcel" to cutomSetup,
and/or bundlerURL: "https://sandpack-bundler.codesandbox.io" (and I also tried with bundlerURL: "https://83c59996.sandpack-bundler.pages.dev/" as seen in this other bug discussion https://github.com/codesandbox/sandpack/issues/481 ),
but it did not fix it. I would get theError message "too much recursion" on Firefox and "Maximum call stack size exceeded" on Chromium.
What were you doing when the problem occurred?
What steps can we take to reproduce the problem?
- use npm package
"@swedbankpay/design-guide": "10.5.1" - in code: add:
import dg from "@swedbankpay/design-guide";
Link to sandbox: link (optional)
https://codesandbox.io/s/quirky-carlos-1mw0b6?file=/src/index.js
Your Environment
| Software | Name/Version |
|---|---|
| Sandpack-client version | |
| Sandpack-react version | 1.18.4 |
| Browser | FF 109 & Edge 109 |
| Operating System | Win 10 |
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.
Assessment
This issue has not been assessed yet.