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

'failed to invoke plugin: Impossible to get the node_modules path' with yarn@3.2.1 #4927

Closed
wegry opened this issue Jun 10, 2022 · 2 comments
Labels

Comments

@wegry
Copy link

wegry commented Jun 10, 2022

Describe the bug

Attempting to use a plugin with @swc/core@1.2.197 with yarn@3.2.1 and pnp enabled triggers

$ RUST_BACKTRACE=full yarn swc index.jsx
thread '<unnamed>' panicked at 'failed to invoke plugin: Impossible to get the node_modules path

Stack backtrace:
   0: _rust_eh_personality
   1: _rust_eh_personality
   2: _rust_eh_personality
   3: _rust_eh_personality
   4: _rust_eh_personality
   5: _rust_eh_personality
   6: _rust_eh_personality
   7: _rust_eh_personality
   8: <unknown>
   9: _worker
  10: __pthread_start', crates/swc/src/plugin.rs:212:14
stack backtrace:
   0:        0x3a08ffad6 - _rust_eh_personality
   1:        0x3a057c4cb - <unknown>
   2:        0x3a08cea48 - _rust_eh_personality
   3:        0x3a0900aed - _rust_eh_personality
   4:        0x3a0901bab - _rust_eh_personality
   5:        0x3a09015b4 - _rust_eh_personality
   6:        0x3a0901529 - _rust_eh_personality
   7:        0x3a09014e5 - _rust_eh_personality
   8:        0x3a19980d3 - _wasmer_vm_f64_nearest
   9:        0x3a19982c5 - _wasmer_vm_f64_nearest
  10:        0x3a0a9d168 - _rust_eh_personality
  11:        0x3a0bb7ee1 - _rust_eh_personality
  12:        0x3a0bb1650 - _rust_eh_personality
  13:        0x3a0ba6892 - _rust_eh_personality
  14:        0x3a0ba2abb - _rust_eh_personality
  15:        0x3a03bf52f - <unknown>
  16:        0x10f4c746a - _worker
  17:     0x7ff81120f4e1 - __pthread_start
failed to handle: failed to invoke plugin: Impossible to get the node_modules path

Stack backtrace:
   0: _rust_eh_personality
   1: _rust_eh_personality
   2: _rust_eh_personality
   3: _rust_eh_personality
   4: _rust_eh_personality
   5: _rust_eh_personality
   6: _rust_eh_personality
   7: _rust_eh_personality
   8: <unknown>
   9: _worker
  10: __pthread_start

Stack backtrace:
   0: _rust_eh_personality
   1: _wasmer_vm_f64_nearest
   2: <unknown>
   3: _worker
   4: __pthread_start
Error: Failed to compile 1 file with swc.
    at Object.assertCompilationResult (/Users/zachwegrzyniak/swc-pnp-plugin-trouble/.yarn/__virtual__/@swc-cli-virtual-05e854c340/0/cache/@swc-cli-npm-0.1.57-161586148e-d19f02233f.zip/node_modules/@swc/cli/lib/swc/util.js:113:15)
    at files (/Users/zachwegrzyniak/swc-pnp-plugin-trouble/.yarn/__virtual__/@swc-cli-virtual-05e854c340/0/cache/@swc-cli-npm-0.1.57-161586148e-d19f02233f.zip/node_modules/@swc/cli/lib/swc/file.js:173:18)
    at async _default (/Users/zachwegrzyniak/swc-pnp-plugin-trouble/.yarn/__virtual__/@swc-cli-virtual-05e854c340/0/cache/@swc-cli-npm-0.1.57-161586148e-d19f02233f.zip/node_modules/@swc/cli/lib/swc/file.js:192:9)

Input code

import * as ReactDOM from "react-dom/client";

const root = ReactDOM.createRoot(document.body);

root.render(<div>Hello world</div>);

Config

{
  "jsc": {
    "experimental": {
      "plugins": [["@swc/plugin-styled-jsx", {}]]
    },
    "parser": {
      "syntax": "ecmascript",
      "jsx": true
    }
  }
}

Playground link

No response

Expected behavior

Ideally, plugins would use something like the patched require.resolve that yarn provides.

Actual behavior

node_modules might be hard coded.

Version

1.2.197

Additional context

Repro repo https://github.com/wegry/swc-pnp-plugin-trouble.

Running yarn && yarn swc index.js triggers the issue.

@wegry wegry added the C-bug label Jun 10, 2022
@kwonoj
Copy link
Member

kwonoj commented Jun 10, 2022

Swc currently does not support berry / pnp module resolution.

#3247

@kwonoj kwonoj closed this as completed Jun 10, 2022
@swc-bot
Copy link
Collaborator

swc-bot commented Oct 16, 2022

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 Oct 16, 2022
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