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

buiild(bindings/wasm): Fix Wasm build #7666

Merged
merged 3 commits into from
Jul 18, 2023
Merged

buiild(bindings/wasm): Fix Wasm build #7666

merged 3 commits into from
Jul 18, 2023

Conversation

kdy1
Copy link
Member

@kdy1 kdy1 commented Jul 18, 2023

Description:

Related issue:

@kdy1 kdy1 added this to the Planned milestone Jul 18, 2023
@kdy1 kdy1 self-assigned this Jul 18, 2023
@kdy1 kdy1 modified the milestones: Planned, v1.3.70 Jul 18, 2023
@kdy1 kdy1 marked this pull request as ready for review July 18, 2023 00:50
@kdy1 kdy1 enabled auto-merge (squash) July 18, 2023 00:50
Copy link
Member Author

@kdy1 kdy1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

swc-bump:

  • dbg-swc

@kdy1 kdy1 changed the title buiild(bindings/wasm): FIx Wasm build buiild(bindings/wasm): Fix Wasm build Jul 18, 2023
@kdy1 kdy1 disabled auto-merge July 18, 2023 00:50
@kdy1 kdy1 enabled auto-merge (squash) July 18, 2023 00:50

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Copy link
Collaborator

@swc-bot swc-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment generated by auto-rebase script

@kdy1 kdy1 merged commit dc5135f into main Jul 18, 2023
@kdy1 kdy1 deleted the ci-wasm branch July 18, 2023 03:33
@magic-akari
Copy link
Member

@magic-akari
Copy link
Member

I changed the compilation target from wasm32-unknown-unknown to wasm32-wasi to avoid the compilation error.

@Jack-Works
Copy link

still have error for my plugin:

Error: failed to handle: failed to invoke plugin: failed to invoke plugin on 'Some("virtual-module.js")'

Caused by:
    0: failed to invoke `swc_transformer_static_module_record.wasm` as js transform plugin at swc_transformer_static_module_record.wasm
    1: Error while importing "__wbindgen_placeholder__"."__wbg_crypto_c48a774b022d20ac": unknown import. Expected Function(FunctionType { params: [I32], results: [I32] })

@kdy1
Copy link
Member Author

kdy1 commented Jul 30, 2023

@Jack-Works It's completely unrelated

@Jack-Works
Copy link

@Jack-Works It's completely unrelated

I found I need getrandom = { version = "0.2", features = ["js"] } to build the wasm, and it cause the Error while importing "__wbindgen_placeholder__"."__wbg_crypto_c48a774b022d20ac": unknown import. Expected Function(FunctionType { params: [I32], results: [I32] }) error.

If I remove this feature, it directly fails to compile:

> cargo build --release --target wasm32-unknown-unknown

   Compiling getrandom v0.2.10
error: the wasm*-unknown-unknown targets are not supported by default, you may need to enable the "js" feature. For more information see: https://docs.rs/getrandom/#webassembly-support
   --> getrandom-0.2.10/src/lib.rs:285:9
    |
285 | /         compile_error!("the wasm*-unknown-unknown targets are not supported by \
286 | |                         default, you may need to enable the \"js\" feature. \
287 | |                         For more information see: \
288 | |                         https://docs.rs/getrandom/#webassembly-support");
    | |________________________________________________________________________^

error[E0433]: failed to resolve: use of undeclared crate or module `imp`
   --> getrandom-0.2.10/src/lib.rs:341:9
    |
341 |         imp::getrandom_inner(dest)?;
    |         ^^^ use of undeclared crate or module `imp`

For more information about this error, try `rustc --explain E0433`.

But I did not use getrandom. Here is my dependency list:

[dependencies]
serde = "1"
serde_json = "1"
swc_core = { version = "0.79.16", features = [
    "ecma_ast",
    "ecma_utils",
    "ecma_visit",
    "ecma_plugin_transform",
    "swc_atoms",
    "swc_plugin",
    "testing_transform",
] }
testing = "0.33.5"
tracing = { version = "0.1.37", features = ["release_max_level_off"] }

is there anything unneeded for a wasm plugin?

@Jack-Works
Copy link

I opened a new issue #7729

@swc-project swc-project locked as resolved and limited conversation to collaborators Aug 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

@swc/wasm releases are missing since 1.3.66
4 participants