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

[Bug]: Use swc-plugin-jsx-control-statements Plugin error #5975

Closed
Zian502 opened this issue Mar 20, 2024 · 8 comments
Closed

[Bug]: Use swc-plugin-jsx-control-statements Plugin error #5975

Zian502 opened this issue Mar 20, 2024 · 8 comments
Assignees
Labels
bug Something isn't working

Comments

@Zian502
Copy link

Zian502 commented Mar 20, 2024

System Info

System:
    OS: macOS 10.15.7
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 416.02 MB / 16.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 16.15.1 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 6.14.18 - /usr/local/bin/npm
    pnpm: 8.6.11 - /usr/local/bin/pnpm
  Browsers:
    Chrome: 122.0.6261.129
    Safari: 15.6.1

Details

trying to use https://github.com/intpp/swc-plugin-jsx-control-statements in my rsbuild project.

running rsbuild build:

Message:  Cannot start a runtime from within a runtime. This happens because a function (like `block_on`) attempted to block the current thread while the thread is being used to drive asynchronous tasks.
Location: /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmer-wasix-0.9.0/src/runtime/task_manager/mod.rs:323

Run with COLORBT_SHOW_HIDDEN=1 environment variable to disable frame filtering.
Run with RUST_BACKTRACE=full to include source snippets.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 1: _napi_register_module_v1
    at <unknown source file>
 2: _napi_register_module_v1
    at <unknown source file>
 3: _napi_register_module_v1
    at <unknown source file>
 4: _napi_register_module_v1
    at <unknown source file>
 5: _napi_register_module_v1
    at <unknown source file>
 6: _wasmer_vm_imported_memory32_atomic_notify
    at <unknown source file>
 7: _napi_register_module_v1
    at <unknown source file>
 8: _napi_register_module_v1
    at <unknown source file>
 9: _napi_register_module_v1
    at <unknown source file>
10: _napi_register_module_v1
    at <unknown source file>
11: _napi_register_module_v1
    at <unknown source file>
zsh: abort      fap dev

Reproduce link

No response

Reproduce Steps

  1. yarn create rsbuild

  2. update rsbuild.config.ts to:

import { defineConfig } from '@rsbuild/core';
import { pluginReact } from '@rsbuild/plugin-react';

export default defineConfig({
  plugins: [pluginReact()],
  tools: {
    swc: {
      jsc: {
        experimental: {
          plugins: [
            ['swc-plugin-jsx-control-statements', {}],
          ],
        },
      },
    },
  },
});

3.run rsbuild build and it will show the error

@Zian502 Zian502 added bug Something isn't working pending triage The issue/PR is currently untouched. labels Mar 20, 2024
@h-a-n-a h-a-n-a removed the pending triage The issue/PR is currently untouched. label Mar 20, 2024
@h-a-n-a h-a-n-a self-assigned this Mar 20, 2024
@Zian502
Copy link
Author

Zian502 commented Mar 27, 2024

May I ask when this will be repaired? Can you give me an idea of when

@h-a-n-a
Copy link
Contributor

h-a-n-a commented Mar 27, 2024

May I ask when this will be repaired? Can you give me an idea of when

This might be related to not matched version. For your reference: #5921

@h-a-n-a
Copy link
Contributor

h-a-n-a commented Mar 28, 2024

Followup, the swc_core version of this plugin is 0.79, which is not compatible with current rspack. Check out this for more info. Only plugins in https://github.com/swc-project/plugins are recommended. Otherwise, you need to fork the original repo and update the swc_core on your own to use it with the latest version of rspack.

@h-a-n-a h-a-n-a closed this as completed Mar 28, 2024
@Zian502
Copy link
Author

Zian502 commented Apr 1, 2024

Followup, the swc_core version of this plugin is 0.79, which is not compatible with current rspack. Check out this for more info. Only plugins in https://github.com/swc-project/plugins are recommended. Otherwise, you need to fork the original repo and update the swc_core on your own to use it with the latest version of rspack.

I can use swc-core version 0.90.*?Other versions will report errors

@Zian502
Copy link
Author

Zian502 commented Apr 1, 2024

Followup, the swc_core version of this plugin is 0.79, which is not compatible with current rspack. Check out this for more info. Only plugins in https://github.com/swc-project/plugins are recommended. Otherwise, you need to fork the original repo and update the swc_core on your own to use it with the latest version of rspack.

I can use swc-core version 0.90.*?Other versions will report errors

Compiling swc_ecma_transforms_testing v0.139.6
error[E0308]: mismatched types
--> /Users/zian/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/swc_ecma_transforms_testing-0.139.6/src/lib.rs:976:67
|
976 | println!("SourceMap: {}", visualizer_url(&actual_src, sourcemap));
| -------------- ^^^^^^^^^ expected sourcemap::SourceMap, found sourcemap::types::SourceMap
| |
| arguments to this function are incorrect
|
= note: sourcemap::types::SourceMap and sourcemap::SourceMap have similar names, but are actually distinct types
note: sourcemap::types::SourceMap is defined in crate sourcemap
--> /Users/zian/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/sourcemap-8.0.0/src/types.rs:481:1
|
481 | pub struct SourceMap {
| ^^^^^^^^^^^^^^^^^^^^
note: sourcemap::SourceMap is defined in crate sourcemap
--> /Users/zian/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/sourcemap-6.4.1/src/types.rs:459:1
|
459 | pub struct SourceMap {
| ^^^^^^^^^^^^^^^^^^^^
= note: perhaps two different versions of crate sourcemap are being used?
note: function defined here
--> /Users/zian/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/swc_ecma_transforms_testing-0.139.6/src/lib.rs:999:4
|
999 | fn visualizer_url(code: &str, map: &sourcemap::SourceMap) -> String {
| ^^^^^^^^^^^^^^ --------------------------

For more information about this error, try rustc --explain E0308.
error: could not compile swc_ecma_transforms_testing (lib) due to 1 previous error

@h-a-n-a
Copy link
Contributor

h-a-n-a commented Apr 1, 2024

Followup, the swc_core version of this plugin is 0.79, which is not compatible with current rspack. Check out this for more info. Only plugins in https://github.com/swc-project/plugins are recommended. Otherwise, you need to fork the original repo and update the swc_core on your own to use it with the latest version of rspack.

I can use swc-core version 0.90.*?Other versions will report errors

Compiling swc_ecma_transforms_testing v0.139.6 error[E0308]: mismatched types --> /Users/zian/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/swc_ecma_transforms_testing-0.139.6/src/lib.rs:976:67 | 976 | println!("SourceMap: {}", visualizer_url(&actual_src, sourcemap)); | -------------- ^^^^^^^^^ expected sourcemap::SourceMap, found sourcemap::types::SourceMap | | | arguments to this function are incorrect | = note: sourcemap::types::SourceMap and sourcemap::SourceMap have similar names, but are actually distinct types note: sourcemap::types::SourceMap is defined in crate sourcemap --> /Users/zian/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/sourcemap-8.0.0/src/types.rs:481:1 | 481 | pub struct SourceMap { | ^^^^^^^^^^^^^^^^^^^^ note: sourcemap::SourceMap is defined in crate sourcemap --> /Users/zian/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/sourcemap-6.4.1/src/types.rs:459:1 | 459 | pub struct SourceMap { | ^^^^^^^^^^^^^^^^^^^^ = note: perhaps two different versions of crate sourcemap are being used? note: function defined here --> /Users/zian/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/swc_ecma_transforms_testing-0.139.6/src/lib.rs:999:4 | 999 | fn visualizer_url(code: &str, map: &sourcemap::SourceMap) -> String { | ^^^^^^^^^^^^^^ --------------------------

For more information about this error, try rustc --explain E0308. error: could not compile swc_ecma_transforms_testing (lib) due to 1 previous error

Remove swc related lock files and reinstall

@Zian502
Copy link
Author

Zian502 commented Apr 2, 2024

Followup, the swc_core version of this plugin is 0.79, which is not compatible with current rspack. Check out this for more info. Only plugins in https://github.com/swc-project/plugins are recommended. Otherwise, you need to fork the original repo and update the swc_core on your own to use it with the latest version of rspack.

I can use swc-core version 0.90.*?Other versions will report errors

Compiling swc_ecma_transforms_testing v0.139.6 error[E0308]: mismatched types --> /Users/zian/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/swc_ecma_transforms_testing-0.139.6/src/lib.rs:976:67 | 976 | println!("SourceMap: {}", visualizer_url(&actual_src, sourcemap)); | -------------- ^^^^^^^^^ expected sourcemap::SourceMap, found sourcemap::types::SourceMap | | | arguments to this function are incorrect | = note: sourcemap::types::SourceMap and sourcemap::SourceMap have similar names, but are actually distinct types note: sourcemap::types::SourceMap is defined in crate sourcemap --> /Users/zian/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/sourcemap-8.0.0/src/types.rs:481:1 | 481 | pub struct SourceMap { | ^^^^^^^^^^^^^^^^^^^^ note: sourcemap::SourceMap is defined in crate sourcemap --> /Users/zian/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/sourcemap-6.4.1/src/types.rs:459:1 | 459 | pub struct SourceMap { | ^^^^^^^^^^^^^^^^^^^^ = note: perhaps two different versions of crate sourcemap are being used? note: function defined here --> /Users/zian/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/swc_ecma_transforms_testing-0.139.6/src/lib.rs:999:4 | 999 | fn visualizer_url(code: &str, map: &sourcemap::SourceMap) -> String { | ^^^^^^^^^^^^^^ --------------------------
For more information about this error, try rustc --explain E0308. error: could not compile swc_ecma_transforms_testing (lib) due to 1 previous error

Remove swc related lock files and reinstall

Delete lock file, re-cargo build, still get the same error
image

@xc2
Copy link
Collaborator

xc2 commented Apr 5, 2024

Followup, the swc_core version of this plugin is 0.79, which is not compatible with current rspack. Check out this for more info. Only plugins in https://github.com/swc-project/plugins are recommended. Otherwise, you need to fork the original repo and update the swc_core on your own to use it with the latest version of rspack.

I can use swc-core version 0.90.*?Other versions will report errors

Compiling swc_ecma_transforms_testing v0.139.6 error[E0308]: mismatched types --> /Users/zian/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/swc_ecma_transforms_testing-0.139.6/src/lib.rs:976:67 | 976 | println!("SourceMap: {}", visualizer_url(&actual_src, sourcemap)); | -------------- ^^^^^^^^^ expected sourcemap::SourceMap, found sourcemap::types::SourceMap | | | arguments to this function are incorrect | = note: sourcemap::types::SourceMap and sourcemap::SourceMap have similar names, but are actually distinct types note: sourcemap::types::SourceMap is defined in crate sourcemap --> /Users/zian/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/sourcemap-8.0.0/src/types.rs:481:1 | 481 | pub struct SourceMap { | ^^^^^^^^^^^^^^^^^^^^ note: sourcemap::SourceMap is defined in crate sourcemap --> /Users/zian/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/sourcemap-6.4.1/src/types.rs:459:1 | 459 | pub struct SourceMap { | ^^^^^^^^^^^^^^^^^^^^ = note: perhaps two different versions of crate sourcemap are being used? note: function defined here --> /Users/zian/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/swc_ecma_transforms_testing-0.139.6/src/lib.rs:999:4 | 999 | fn visualizer_url(code: &str, map: &sourcemap::SourceMap) -> String { | ^^^^^^^^^^^^^^ --------------------------
For more information about this error, try rustc --explain E0308. error: could not compile swc_ecma_transforms_testing (lib) due to 1 previous error

Remove swc related lock files and reinstall

Delete lock file, re-cargo build, still get the same error image

@zakuru need specific version of swc_common

  • swc_common near 0.33.22 for swc_core@0.90.*
  • swc_common near 0.33.15 for swc_core@0.89.*
  • swc_common near 0.33.14 for swc_core@0.88.*

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants