swc-project / pkgs

node.js packages for SWC
49 stars 15 forks source link

SWC-loader not working on Apple M3 #49

Closed George-Sava closed 2 months ago

George-Sava commented 2 months ago

I've switched recently on a new Macbook with Apple M3 and I'm trying to start my React application that previously was working on my Macbook with Intel, but I get this error:

Module build failed (from ../node_modules/swc-loader/src/index.js):
Error: failed to handle: failed to invoke plugin: failed to invoke plugin on 'Some("path/to/main/file")'

Caused by:
    0: Failed to create plugin instance
    1: missing requires CPU features: "EnumSet(SSE2 | SSE3 | SSSE3 | SSE41 | SSE42 | POPCNT | AVX | BMI1 | BMI2 | AVX2 | LZCNT)"
    at Compiler.transformSync (.../node_modules/@swc/core/index.js:241:29)
    at Object.transformSync (.../node_modules/@swc/core/index.js:348:21)
    at Object.<anonymous> (.../node_modules/swc-loader/src/index.js:79:36)

What I've tried

  1. Assured that I'm using the corect ARM version of my editor.
  2. Started my terminal under Rosetta.
  3. Uninstalled and reinstalled my workspace node_modules
  4. Uninstalled and reinstalled my global node_modules

None of the above resolved my issue.

Version Used "swc-loader": "0.2.3"

kdy1 commented 2 months ago

Actually I'm using M3 macbook, so I'm not sure how can this happen

kdy1 commented 2 months ago

I think Started my terminal under Rosetta. can be the cause. You should use native arm binary.

George-Sava commented 2 months ago

Yeah, I managed to resolve it. I just updated my swc-loader and swc-core to the latest version. This lixed the issue.