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 plugins not working #7381

Closed
HeartyPorridge opened this issue May 12, 2023 · 4 comments
Closed

SWC plugins not working #7381

HeartyPorridge opened this issue May 12, 2023 · 4 comments
Labels

Comments

@HeartyPorridge
Copy link

Describe the bug

Hello! I really like SWC. I am much more comfortable developing a website.

I need a plugin and I'm ready to start developing.
But Next js crashes when I include my plugin.

After reviewing the discussions on github, I think the problem is with the Rust version. I've tried all the versions you suggested.
nightly-2022-09-20 / nightly-2022-09-23 / nightly-2022-09-25 / nightly-2022-09-27 / nightly-2023-03-13 / nightly-2023-03-20

I didn't write the code. I just installed "getting-started" from the documentation.
Here are ALL my steps.

  1. rustup default nightly-2023-03-20
  2. cargo install swc_cli
  3. swc plugin new --target-type wasm32-wasi my-first-plugin
  4. cd my-first-plugin
  5. rustup target add wasm32-wasi
  6. cargo build-wasi --release

I repeated this many times changing the version of Rust
I also changed many versions of Next js
I installed virtualbox and did all these steps on virtual windows and ubuntu. Same error.

I am sure that if you repeat my steps, you will get the same error.
What to do? What is the current development version of Rust?

Input code

I didn't write the code

Config

I don't know where the ".swcrc" file is. If it matters tell me where it is

Playground link

No response

Expected behavior

I expect the wasm plugin I created will not break Next js

Actual behavior

Panic: PanicInfo { payload: Any { .. }, message: Some(failed to invoke plugin: failed to invoke plugin on 'Some("C:\Users\HeartyPorridge\WebstormProjects\nextDev\first\node_modules\next\dist\client\app-next-dev.js")'

Caused by:
0: failed to invoke C:\Users\HeartyPorridge\WebstormProjects\nextDev\first\my_first_plugin.wasm as js transform plugin at C:\Users\HeartyPorridge\WebstormProjects\nextDev\first
\my_first_plugin.wasm
1: RuntimeError: out of bounds memory access
at swc_ecma_ast::typescript::::<impl rkyv::Deserialize<swc_ecma_ast::typescript::TsType,__D> for <swc_ecma_ast::typescript::TsType as rkyv::Archive>::A
rchived>::deserialize::h15948e84f191c2a5.7798 ([638]:0xbf32d)
at swc_ecma_ast::pat::
::<impl rkyv::Deserialize<swc_ecma_ast::pat::Pat,__D> for <swc_ecma_ast::pat::Pat as rkyv::Archive>::Archived>::deserialize::h9b8
591634f3f81ff.7778 ([618]:0xbc298)
at rkyv::impls::core::<impl rkyv::DeserializeUnsized<[U],D> for [T]>::deserialize_unsized::hd273df1fb6f0ef26 ([86]:0x1e282)
at swc_ecma_ast::decl::::<impl rkyv::Deserialize<swc_ecma_ast::decl::Decl,__D> for <swc_ecma_ast::decl::Decl as rkyv::Archive>::Archived>::deserialize:
:h2b9efeca55b3e3d1 ([83]:0x1cb57)
at swc_ecma_ast::stmt::
::<impl rkyv::Deserialize<swc_ecma_ast::stmt::Stmt,__D> for <swc_ecma_ast::stmt::Stmt as rkyv::Archive>::Archived>::deserialize:
:hf10ffad9ec180e2b ([142]:0x3128d)
at rkyv::impls::core::<impl rkyv::DeserializeUnsized<[U],D> for [T]>::deserialize_unsized::hac6425138ec0bbab ([50]:0xa0b3)
at __transform_plugin_process_impl ([234]:0x4d669)
at __transform_plugin_process_impl.command_export ([956]:0x106ec5)
2: heap_get_oob

Stack backtrace:
0: napi_register_module_v1
1: napi_register_module_v1
2: napi_register_module_v1
3: napi_register_module_v1
4: napi_register_module_v1
5: BrotliDecoderVersion
6: BrotliDecoderVersion
7: canonical_abi_free
8: canonical_abi_free
9: canonical_abi_free
10: canonical_abi_free
11: canonical_abi_free
12: canonical_abi_free
13: canonical_abi_free
14: v8::base::TimeDelta::TimeDelta
15: uv_queue_work
16: uv_poll_stop
17: inflateValidate
18: BaseThreadInitThunk
19: RtlUserThreadStart), location: Location { file: "C:\Users\runneradmin\.cargo\registry\src\index.crates.io-6f17d22bba15001f\swc-0.260.41\src\plugin.r
s", line: 219, col: 14 }, can_unwind: true }
Backtrace: 0: napi_register_module_v1
1: napi_register_module_v1
2: canonical_abi_free
3: napi_register_module_v1
4: napi_register_module_v1
5: napi_register_module_v1
6: napi_register_module_v1
7: napi_register_module_v1
8: napi_register_module_v1
9: BrotliDecoderVersion
10: canonical_abi_free
11: canonical_abi_free
12: canonical_abi_free
13: canonical_abi_free
14: canonical_abi_free
15: canonical_abi_free
16: canonical_abi_free
17: v8::base::TimeDelta::TimeDelta
18: uv_queue_work
19: uv_poll_stop
20: inflateValidate
21: BaseThreadInitThunk
22: RtlUserThreadStart

Version

swc_core = 0.75.* and swc_core = 0.76.0

Additional context

Considering that I tried this on different virtual computers, I assume that everyone has the problem

@kdy1 kdy1 closed this as not planned Won't fix, can't repro, duplicate, stale May 12, 2023
@kdy1
Copy link
Member

kdy1 commented May 12, 2023

See the pinned issue

@HeartyPorridge
Copy link
Author

See the pinned issue

I understand correctly? Next js version is v13.3.1-canary.12. swc_core version is 0.75.0. I am getting this same error. Help me please. I've been in pain for many days

@kdy1
Copy link
Member

kdy1 commented May 13, 2023

Did you really read https://swc.rs/docs/plugin/selecting-swc-core ? I'm not sure, but maybe the cause is that you used swc_core@v0.76.0

@swc-bot
Copy link
Collaborator

swc-bot commented Jun 12, 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 12, 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

3 participants