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

Plugins built with swc_core >= 0.76.0 doesn't work in the next-swc and @swc/core #7470

Closed
thekip opened this issue May 30, 2023 · 6 comments
Closed

Comments

@thekip
Copy link

thekip commented May 30, 2023

Describe the bug

Related issue on plugin repo: lingui/swc-plugin#61

Plugin is built with swc_core@0.76.0 and nightly-2023-03-09 and it doesn't work with "@swc/core": "1.3.61" which according to "Selecting version" should do.

I also tried swc_core@0.76.37 and nightly-2023-03-20 and have the same result.

I'm getting issue RuntimeError: uninitialized element:

thread '<unnamed>' panicked at 'failed to invoke plugin: failed to invoke plugin on 'Some("/Users/tim/projects/js-lingui/examples/vite-project-react-swc/src/main.tsx")'

Caused by:
    0: failed to invoke `/Users/tim/projects/lingui-macro-plugin/target/wasm32-wasi/release/lingui_macro_plugin.wasm` as js transform plugin at /Users/tim/projects/lingui-macro-plugin/target/wasm32-wasi/release/lingui_macro_plugin.wasm
    1: RuntimeError: uninitialized element

Stack backtrace:
   0: _napi_register_module_v1
   1: _wasmer_vm_imported_memory32_atomic_notify
   2: _napi_register_module_v1
   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: <unknown>
   9: _worker
  10: __pthread_joiner_wake', /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc-0.261.31/src/plugin.rs:152:14

Input code

No response

Config

No response

Playground link

No response

Expected behavior

It should work

Actual behavior

No response

Version

swc_core@0.76.0

Additional context

No response

@thekip thekip added the C-bug label May 30, 2023
@kwonoj
Copy link
Member

kwonoj commented May 30, 2023

Quick checking, same occurs on debug build / turning off lto from release build?

@thekip
Copy link
Author

thekip commented May 31, 2023

@kwonoj i've tested only with release build cargo build --target wasm32-wasi --release

[profile.release]
# This removes more dead code
codegen-units = 1
lto = true
# Optimize for size
opt-level = "s"
# Optimize for performance, this is default so you don't need to specify it
# opt-level = "z"

@kwonoj
Copy link
Member

kwonoj commented May 31, 2023

Yes, requesting to test with debug / or lto off.

@thekip
Copy link
Author

thekip commented Jun 1, 2023

It seems it works with lto = false in bare @swc/core, but still doesn't work in next-swc there is a different issue

  • error ./node_modules/next/dist/client/dev/amp-dev.js
    Error: Filesystem cache is not enabled, cannot read plugin from phsyical path

Which is happened only if swc plugins are enabled. The more details described here vercel/next.js#36078 (comment)

Regarding lto = false is there any doable from swc side? or this setting should become a default for swc plugins?

@kwonoj
Copy link
Member

kwonoj commented Jun 1, 2023

  1. next.js side error is a regression we need to fix. fix(next-swc): reenable filesystem cache vercel/next.js#50651
  2. enabling lto is not something swc itself directly controls, it is side effect after we upgraded plugin runtime. We hope to resolve it, but do not have a foreseeable ETA or root cause.

I'd consider this issue itself is resolved for now.

@swc-bot
Copy link
Collaborator

swc-bot commented Jul 2, 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 Jul 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

3 participants