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

Plugin panics on release builds #7429

Closed
arlyon opened this issue May 22, 2023 · 5 comments
Closed

Plugin panics on release builds #7429

arlyon opened this issue May 22, 2023 · 5 comments
Labels

Comments

@arlyon
Copy link

arlyon commented May 22, 2023

Describe the bug

Hi!

I have been working to upgrade stailwc to a newer version of next but have been running into issues. I am on swc_core@0.76.9, testing against @swc/core@1.3.59 and against next@13.4.3.

I can run my plugin in debug mode no problem, however release mode causes panics. I have a repro branch here, simply build the plugin in debug and release modes and then have a look at examples/swc (updating the wasm path as appropriate in install.js).

git clone https://github.com/arlyon/stailwc.git -b repro/release-build-fail
cd stailwc
cargo build --target wasm32-wasi
cargo build --release --target wasm32-wasi
cd examples/swc
yarn
# override path to stailwc.wasm in install.js
yarn build

Input code

import { TailwindStyle } from "stailwc";

const Button = tw.button`content-[Hello World] px-4 py-2 bg-red-500 rounded-full text-white`;

export const App = () => (
  <div tw="w-screen h-screen">
    <TailwindStyle />
    <Button />
  </div>
);

Config

N/A

Playground link

N/A

Expected behavior

I expect release builds to also pass.

❯ yarn build 
$ node ./install.js > .swcrc && swc index.tsx -o index.js
Successfully compiled 1 file with swc.
Done in 1.35s.

Actual behavior

Panic.

❯ yarn build
$ node ./install.js > .swcrc && swc index.tsx -o index.js
thread '<unnamed>' panicked at 'failed to invoke plugin: failed to invoke plugin on 'Some("index.tsx")'

Caused by:
    0: failed to invoke `/home/arlyon/Programming/stailwc/target/wasm32-wasi/release/stailwc.wasm` as js transform plugin at /home/arlyon/Programming/stailwc/target/wasm32-wasi/release/stailwc.wasm
    1: RuntimeError: unreachable
           at __transform_plugin_process_impl (<module>[198]:0x20d49)
           at __transform_plugin_process_impl.command_export (<module>[580]:0x3e700)', /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/swc-0.261.13/src/plugin.rs:152:14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
failed to handle: failed to invoke plugin: failed to invoke plugin on 'Some("index.tsx")'

Caused by:
    0: failed to invoke `/home/arlyon/Programming/stailwc/target/wasm32-wasi/release/stailwc.wasm` as js transform plugin at /home/arlyon/Programming/stailwc/target/wasm32-wasi/release/stailwc.wasm
    1: RuntimeError: unreachable
           at __transform_plugin_process_impl (<module>[198]:0x20d49)
           at __transform_plugin_process_impl.command_export (<module>[580]:0x3e700)
Error: Failed to compile 1 file with swc.
    at Object.assertCompilationResult (/home/arlyon/Programming/stailwc/examples/swc/node_modules/@swc/cli/lib/swc/util.js:149:15)
    at files (/home/arlyon/Programming/stailwc/examples/swc/node_modules/@swc/cli/lib/swc/file.js:201:19)
    at async _default (/home/arlyon/Programming/stailwc/examples/swc/node_modules/@swc/cli/lib/swc/file.js:220:9)
error Command failed with exit code 1.

Version

swc_core@0.76.9, @swc/core@1.3.59, next@13.4.3

Additional context

No response

@arlyon arlyon added the C-bug label May 22, 2023
@kdy1
Copy link
Member

kdy1 commented May 22, 2023

https://swc.rs/docs/plugin/selecting-swc-core
I think @swc/core@1.3.59 and next@13.4.3 cannot be supported at the same time

@kwonoj
Copy link
Member

kwonoj commented May 22, 2023

@arlyon try disabling lto? wasmerio/wasmer#3764 (comment)

@arlyon
Copy link
Author

arlyon commented May 22, 2023

That did it, TY! Linking the docs PR for posterity swc-project/website#220

@kwonoj
Copy link
Member

kwonoj commented May 22, 2023

Cool, let's close as resolved for now.

@kwonoj kwonoj closed this as completed May 22, 2023
@swc-bot
Copy link
Collaborator

swc-bot commented Jun 22, 2023

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@swc-project swc-project locked as resolved and limited conversation to collaborators Jun 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

4 participants