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

SWC 4.0.1 plugin panics on latest @swc/core version 1.3.60 #61

Closed
2 tasks
chrischen opened this issue May 26, 2023 · 8 comments
Closed
2 tasks

SWC 4.0.1 plugin panics on latest @swc/core version 1.3.60 #61

chrischen opened this issue May 26, 2023 · 8 comments

Comments

@chrischen
Copy link

chrischen commented May 26, 2023

Describe the bug
If I have @swc/core 1.3.60 I get a panic and server fails to start. Forcing 1.3.49 fixes the issue and it works. 1.3.56 seems to be the highest version that still works.

@lingui/swc-plugin 4.0.1 does not work with any version (I tried @swc/core 1.3.49 up to 1.3.60).
@lingui/swc-plugin 4.0.0 works with up to @swc/core 1.3.56.

To Reproduce
Install @swc/core 1.3.60 and run project with @lingui/swc-plugin.

Adding this to package.json and reinstalling fixes the issue, suggesting it is just the new swc version causing the problem.

  "resolutions": {
    "@swc/core": "1.3.49"
  },

Expected behavior
It should not panic and crash.

Additional context
Add any other context about the problem here.

  • jsLingui version 4.1.2
  • Babel version 7.21.8
  • Macro support:
  • [X ] I'm using SWC with @lingui/swc-plugin
  • I'm using Babel with babel-macro-plugin
  • I'm not using macro
  • Your Babel config (e.g. .babelrc) or framework you use (Create React App, NextJs, Vite)
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react-swc";
import linaria from "@linaria/vite";
import { lingui } from "@lingui/vite-plugin";

export default defineConfig({
  plugins: [
    react({
      plugins: [
        [
          "@lingui/swc-plugin", {}
        ],
      ],
    }),
    linaria(),
    lingui(),
  ],
});
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: LayoutError', /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rkyv-0.7.41/src/impls/core/mod.rs:266:67
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread '<unnamed>' panicked at 'failed to invoke plugin: failed to invoke plugin on 'Some("/Users/[redacted]/src/entry/server.tsx")'

Caused by:
    0: failed to invoke `/Users/[redacted]/node_modules/@lingui/swc-plugin/target/wasm32-wasi/release/lingui_macro_plugin.wasm` as js transform plugin at /Users/[redacted]/node_modules/@lingui/swc-plugin/target/wasm32-wasi/release/lingui_macro_plugin.wasm
    1: RuntimeError: unreachable', /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc-0.261.25/src/plugin.rs:152:14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
node:internal/process/promises:288
            triggerUncaughtException(err, true /* fromPromise */);
            ^

[Error: failed to handle: failed to invoke plugin: failed to invoke plugin on 'Some("/Users/[redacted]/src/entry/server.tsx")'

Caused by:
    0: failed to invoke `/Users/[redacted]/node_modules/@lingui/swc-plugin/target/wasm32-wasi/release/lingui_macro_plugin.wasm` as js transform plugin at /Users/[redacted]/node_modules/@lingui/swc-plugin/target/wasm32-wasi/release/lingui_macro_plugin.wasm
    1: RuntimeError: unreachable] {
  code: 'GenericFailure',
  plugin: 'vite:react-swc',

@chrischen chrischen changed the title SWC plugin panics on latest @swc/core version 1.3.60 SWC 4.0.1 plugin panics on latest @swc/core version 1.3.60 May 26, 2023
@timofei-iatsenko
Copy link
Collaborator

That is strange. 4.0.1 just built with latest available swc-core, which should support @swc/[email protected] and up.
I noticed swc project uses different version of rust compiler, may be this is an issue, will check that.

@stovmascript
Copy link
Contributor

stovmascript commented May 30, 2023

@thekip I tried building after updating swc_core to 0.76.18 and using it with Next.js 13.4.4, which uses the same swc_core version, but am also getting errors when running the dev server, albeit with similar output only sometimes.

Edit: Will try with same compiler versions.

@stovmascript
Copy link
Contributor

stovmascript commented May 30, 2023

@thekip Tried building with nightly-2023-03-20, but getting the same result.

@timofei-iatsenko
Copy link
Collaborator

It's getting annoying. Did you try this with a bare swc/core? There might be something broken in nextjs as it was recently.

@stovmascript
Copy link
Contributor

stovmascript commented May 30, 2023

Yeah, I get ya... Not sure, I updated swc_core version in Cargo.toml and the rust-toolchain file and ran build and test. It seems to have updated stuff and did what I would expect, but I'm not ample with Rust yet, so might have missed something. Sorry.

@timofei-iatsenko
Copy link
Collaborator

I've created an issue in upstream repo, I have nothing actionable from my side. I played with swc-core and rust versions with no luck.

@bigint
Copy link

bigint commented May 31, 2023

Yes happened the same here heyxyz/hey#2975

@timofei-iatsenko
Copy link
Collaborator

4.0.2 version is now working with latest next-swc and bare @swc/core.

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

No branches or pull requests

4 participants