Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build failed: @parcel/optimizer-swc: Expected unicode escape #9370

Closed
chdominguez opened this issue Nov 9, 2023 · 2 comments · Fixed by #9389
Closed

Build failed: @parcel/optimizer-swc: Expected unicode escape #9370

chdominguez opened this issue Nov 9, 2023 · 2 comments · Fixed by #9389

Comments

@chdominguez
Copy link

🐛 bug report

After updating to macOS Sonoma, parcel stopped building one of my projects that contains the plotly.js library

🎛 Configuration (.babelrc, package.json, cli command)

"dependencies": {
    "@dnd-kit/core": "^6.0.8",
    "@dnd-kit/modifiers": "^6.0.1",
    "@dnd-kit/sortable": "^7.0.2",
    "@headlessui/react": "^1.7.14",
    "@heroicons/react": "^2.0.18",
    "@types/react-plotly.js": "^2.6.0",
    "ag-grid-community": "^30.0.3",
    "ag-grid-react": "^30.0.4",
    "animejs": "^3.2.1",
    "bootstrap": "^5.2.3",
    "chonky": "^2.3.2",
    "chonky-icon-fontawesome": "^2.3.2",
    "downloadjs": "^1.4.7",
    "i18next": "^22.4.15",
    "i18next-browser-languagedetector": "^7.0.1",
    "immutability-helper": "^3.1.1",
    "jsme-react": "^0.0.9",
    "molstar": "^3.34.0",
    "plotly.js": "^2.24.3",
    "react": "^18.2.0",
    "react-bootstrap": "^2.7.4",
    "react-console-emulator": "^5.0.2",
    "react-dnd": "^16.0.1",
    "react-dnd-html5-backend": "^16.0.1",
    "react-dom": "^18.2.0",
    "react-i18next": "^12.2.2",
    "react-plotly.js": "^2.6.0",
    "react-resizable-panels": "^0.0.51",
    "react-router": "^6.11.2",
    "react-router-dom": "^6.11.2",
    "react-xarrows": "^2.0.2",
    "socket.io": "^4.6.1",
    "socket.io-client": "^4.6.1",
    "styled-components": "^5.3.10",
    "yarn": "^1.22.19"
  },
  "devDependencies": {
    "@parcel/packager-raw-url": "^2.9.3",
    "@parcel/transformer-sass": "^2.8.3",
    "@parcel/transformer-webmanifest": "^2.9.3",
    "@typescript-eslint/eslint-plugin": "^5.62.0",
    "autoprefixer": "^10.4.14",
    "buffer": "^5.7.1",
    "eslint": "^8.48.0",
    "eslint-config-standard-with-typescript": "^37.0.0",
    "eslint-plugin-import": "^2.28.0",
    "eslint-plugin-n": "^16.0.1",
    "eslint-plugin-promise": "^6.1.1",
    "eslint-plugin-react": "^7.33.2",
    "parcel": "^2.8.3",
    "postcss": "^8.4.23",
    "prettier": "2.8.8",
    "process": "^0.11.10",
    "run-script-os": "^1.1.6",
    "tailwindcss": "^3.3.2",
    "typescript": "^5.1.6"
  }

🤔 Expected Behavior

My project should build fine. In fact, if I setup a virtual machine with macOS Big Sur, the project compiles just fine. Moreover, in an Apple Silicon mac with the same macOS version, it works again as expected.

😯 Current Behavior

The compilation fails with the following error message:

(node:56636) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
🚨 Build failed.

@parcel/optimizer-swc: Expected unicode escape

  /Users/cdominguez/Developer/horus/node_modules/plotly.js/dist/plotly.js:123965:4
    123964 |       dy: dy
  > 123965 |     };
  >        |    ^
    123966 |   }
    123967 |   d3.random = {

💁 Possible Solution

🔦 Context

💻 Code Sample

🌍 Your Environment

Software Version(s)
Parcel 2.10.2
Node v21.1.0
npm 10.2.0
Operating System macOS Sonoma 14.1 Intel
@mischnic
Copy link
Member

The problem is that for

function p(µ, σ) {}
console.log(p);

Parcel outputs

(() => {
function $32aa4caf798866a8$var$p(\xb5, \u03C3) {}
console.log($32aa4caf798866a8$var$p);
})();

which is indeed invalid JS and then the swc optimiser complains

@maximgeerinck
Copy link

maximgeerinck commented Jan 18, 2024

Still getting this issue in v2.11.0

@parcel/optimizer-swc: Expected unicode escape

  /<my workspace>/node_modules/@reach/popover/dist/reach-popover.esm.js:308:4
    307 |     // we're assuming the popover will never contain the first tabbable
  > 308 |     // element, and it better not, because the trigger needs to be tabbable!
  >     |    ^
    309 |     return event.target === tabbable(ownerDocument)[0];
    310 |   }

Pinning @swc/core to 1.3.104 didn't fix it

Turns out in this case, the library has a é with accent, replacing that works (patch)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants