parcel-bundler / parcel

The zero configuration build tool for the web. ๐Ÿ“ฆ๐Ÿš€
https://parceljs.org
MIT License
43.46k stars 2.27k forks source link

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

Closed chdominguez closed 11 months ago

chdominguez commented 11 months ago

๐Ÿ› 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 commented 11 months ago

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 commented 9 months ago

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)