parcel-bundler / parcel

The zero configuration build tool for the web. 📦🚀
https://parceljs.org
MIT License
43.37k stars 2.26k forks source link

@parcel/optimizer-swc: Bindings not found #9844

Open dagnelies-elo opened 1 month ago

dagnelies-elo commented 1 month ago

🐛 bug report

Fails to build with parcel build --no-cache --public-url ./ src/*.html

🚨 Build failed.
@parcel/optimizer-swc: Bindings not found.
  Error: Bindings not found.
      at Compiler.<anonymous> 
  (/builds/.../node_modules/@swc/core/index.js:227:19)
      at Generator.next (<anonymous>)
      at /builds/.../node_modules/@swc/core/index.js:31:71
      at new Promise (<anonymous>)
      at __awaiter 
  (/builds/.../node_modules/@swc/core/index.js:27:12)
      at Compiler.transform 
  (/builds/.../node_modules/@swc/core/index.js:203:16)
      at transform 
  (/builds/.../node_modules/@swc/core/index.js:352:21)
      at Object.optimize 
  (/builds/.../node_modules/@parcel/optimizer-swc/lib/SwcOptimizer.js:84:44)
      at process.processTicksAndRejections 
  (node:internal/process/task_queues:95:5)
      at async PackagerRunner.optimize 
  (/builds/.../node_modules/@parcel/core/lib/PackagerRunner.js:342:20)

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

Running on node 22, nothing fancy in the package.json:

"devDependencies": {
    "@parcel/transformer-vue": "^2.12.0",
    "parcel": "^2.12.0"
  },
  "scripts": {
    "build": "parcel build --no-cache --public-url ./ src/*.html",
  },
  "dependencies": {
    ...
    "vue": "^3.4.31"
  },
  "optionalDependencies": {
    "@parcel/watcher-linux-x64-glibc": "^2.4.2-alpha.0"
  }

The optional dependency was needed, otherwise it would result in another bug reported here.

And the typescript config looks as follows:

{
  "compilerOptions": {
    "lib": [
      "dom",
      "es2016"
    ]
  }
}

🤔 Expected Behavior

It compiles

😯 Current Behavior

It throws that error

💁 Possible Solution

🔦 Context

💻 Code Sample

🌍 Your Environment

Software Version(s)
Parcel 2.12.0
Node 22
npm/Yarn npm
Operating System Linux

...but it works on Windows!

dagnelies-elo commented 1 month ago

After a lot of difficult search, the following workaround seems to do the trick:

npm install -O @swc/core-linux-x64-glibc
npm install -O @swc/core-linux-x64-gnu
isitgeorge commented 1 month ago

After a lot of difficult search, the following workaround seems to do the trick:

npm install -O @swc/core-linux-x64-glibc
npm install -O @swc/core-linux-x64-gnu

@dagnelies-elo Had this issue when building Parcel on a DigitalOcean App Platform instance, this fixed it. Any idea why these dependencies aren't automatically installed if required?

dagnelies-elo commented 1 month ago

...sorry ...I have no clue about the logic behind these optional dependencies