vitejs/vite-plugin-react-swc

Failed to invoke as js transfrom plugin

d4mr opened this issue · 3 comments

Using @swc/core version 1.3.107, I get this error when I try to use @swc-jotai/react-refresh.

failed to handle: failed to invoke plugin: failed to invoke plugin on 'Some("[...]/src/main.tsx")'

Caused by:
    0: failed to invoke `[...]/node_modules/.pnpm/@swc-jotai+react-refresh@0.1.0/node_modules/@swc-jotai/react-refresh/swc_jotai_react_refresh.wasm` as js transform plugin at [...]/node_modules/.pnpm/@swc-jotai+react-refresh@0.1.0/node_modules/@swc-jotai/react-refresh/swc_jotai_react_refresh.wasm
    1: RuntimeError: unreachable
[...]/src/main.tsx

Downgrading @swc/core to version 1.3.101, I no longer get this error, and everything seems to work.
I am unsure whether I should file an issue there or here, please let me know if I should create one there instead.

Yes this is clearly an issue with SWC, maybe an incompatibility between the plugin version and the core version

I'm facing the same issue. However, I'm not sure to get how to handle this. I forced @swc/core in my project's package.json to ~1.3.107, and "deduped" my dep tree (using pnpm dedupe).

I still get the same error as @d4mr reported, on my dev computer.
On stackblitz (https://stackblitz.com/edit/vitejs-vite-sqthkz?file=package.json,vite.config.ts,src%2Fmain.tsx,src%2FApp.tsx&terminal=dev) , it's working even with the latest versions, but the plugin does not seems to be run at all.

Is there any working sample somewhere, combining vite-plugin-react-swc and jotai plugin ?

Found a workaround here: pmndrs/swc-jotai#23 (comment)

I added in my package.json file:

{
     "pnpm": {
		"overrides": {
			"@swc/core": "1.3.105"
		}
	}
}

This way, it forces vite-plugin-react-swc to downgrade its swc dependency.