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

Cannot use SWC plugins in Webpack loader #48

Closed
aegooby opened this issue Jul 4, 2022 · 7 comments
Closed

Cannot use SWC plugins in Webpack loader #48

aegooby opened this issue Jul 4, 2022 · 7 comments

Comments

@aegooby
Copy link

aegooby commented Jul 4, 2022

When using swc-loader in Webpack with the following .swcrc,

{
    "sync": true,
    "jsc": {
        "parser": {
            "syntax": "typescript",
            "tsx": true,
            "decorators": true,
            "dynamicImport": true
        },
        "transform": {
            "decoratorMetadata": true,
            "react": {
                "runtime": "automatic",
                "pragma": "React.createElement",
                "pragmaFrag": "React.Fragment",
                "throwIfNamespace": true,
                "useBuiltins": false,
                "refresh": true
            }
        },
        "experimental": {
            "plugins": [
                ["@swc/plugin-jest", {}]
            ]
        }
    }
}

I get the following error:

thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: LayoutError', /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/rkyv-0.7.37/src/impls/core/mod.rs:265:67
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread '<unnamed>' panicked at 'failed to invoke plugin: failed to invoke `@swc/plugin-jest` as js transform plugin at ../node_modules/@swc/plugin-jest/swc_plugin_jest.wasm

Caused by:
    0: RuntimeError: call stack exhausted
    1: stk_ovf

Stack backtrace:
   0: _wasmer_vm_raise_trap
   1: _wasmer_vm_raise_trap
   2: _napi_register_module_v1
   3: _napi_register_module_v1
   4: <unknown>
   5: <unknown>
   6: <unknown>
   7: <unknown>
   8: <unknown>
   9: <unknown>
  10: <unknown>
  11: <unknown>
  12: <unknown>
  13: <unknown>
  14: <unknown>
  15: <unknown>', crates/swc/src/plugin.rs:212:14
stack backtrace:
   0:        0x121b410b0 - _wasmer_vm_raise_trap
   1:        0x121b600cc - _wasmer_vm_raise_trap
   2:        0x121b3cd18 - _wasmer_vm_raise_trap
   3:        0x121b42848 - _wasmer_vm_raise_trap
   4:        0x121b425b0 - _wasmer_vm_raise_trap
   5:        0x121b42cdc - _wasmer_vm_raise_trap
   6:        0x121b42c10 - _wasmer_vm_raise_trap
   7:        0x121b4158c - _wasmer_vm_raise_trap
   8:        0x121b42968 - _wasmer_vm_raise_trap
   9:        0x121c0a4b8 - _wasmer_vm_raise_trap
  10:        0x121c0a55c - _wasmer_vm_raise_trap
  11:        0x120752914 - <unknown>
  12:        0x1205bff20 - <unknown>
  13:        0x1206c2430 - <unknown>
  14:        0x120818b00 - <unknown>
  15:        0x1206c3420 - <unknown>
  16:        0x120817ad8 - <unknown>
  17:        0x1202a3fa0 - <unknown>
  18:        0x1202a9900 - <unknown>
  19:        0x1201d6a24 - <unknown>
  20:        0x1202a0f04 - <unknown>
asset main@8c45e7d8.js 2.32 KiB [emitted] [immutable] [javascript module] (name: main)
./src/entry/bundle.tsx 39 bytes [built] [code generated] [1 error]

If I remove the plugin from the .swcrc file, the whole process runs fine. As soon as I add in a plugin (I have tried Relay and Jest), this issue occurs.

@kdy1
Copy link
Member

kdy1 commented Jul 4, 2022

cc @kwonoj

@kwonoj
Copy link
Member

kwonoj commented Jul 4, 2022

I think we need an example input file can reproduce. Or is it occurs on any source as an input?

@aegooby
Copy link
Author

aegooby commented Jul 4, 2022

I made a demo here: https://github.com/aegooby/swc-webpack-with-plugins

@alekangelov
Copy link

alekangelov commented Aug 5, 2022

I have a repo with storybook that builds fine, but doesn't work when storybook tries to run. Maybe connected with this as storybook uses webpack as it's bundler.

Caused by:
    0: failed to invoke `@swc/plugin-emotion` as js transform plugin at node_modules/@swc/plugin-emotion/swc_plugin_emotion.wasm
    1: RuntimeError: out of bounds memory access
    2: heap_get_oob

here's the repo, very minimal - one component

https://github.com/alekangelov/emotion-swc-storybook-bug

yarn storybook fails, but
yarn storybook:build succeeds, which is weird

@kwonoj
Copy link
Member

kwonoj commented Aug 6, 2022

heap_get_oob

this issue is a separate one, upstream issue filed at swc-project/swc#5406

@alekangelov
Copy link

alekangelov commented Aug 6, 2022

I saw you already deduced that I've got apple silicon. If there's anything I can do, I will 👍

meanwhile will try to repro on: Windows 11 and Ubuntu (WSL and Vanilla)

@kwonoj
Copy link
Member

kwonoj commented Apr 25, 2023

This is old issue and we've updated lot of internals. Please try with the latest, and report new if it still occurs.

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

Successfully merging a pull request may close this issue.

4 participants