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

Support for Wasm builds #137

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

SebastienGllmt
Copy link

Closes #136

@CLAassistant
Copy link

CLAassistant commented Dec 6, 2024

CLA assistant check
All committers have signed the CLA.

Copy link
Author

Choose a reason for hiding this comment

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

I had to move this project to be a Cargo workspace so that it can host the Rust+WASM projects in the same repo

Copy link
Member

Choose a reason for hiding this comment

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

It should work to have the rust code still in the root directory and that would be preferable. There's an example in https://github.com/denoland/deno_graph/blob/a63963643a56fb664c980149bc20d17484d9513c/Cargo.toml#L13

@@ -1,3 +1,3 @@
[toolchain]
channel = "1.76.0"
channel = "1.78.0"
Copy link
Author

Choose a reason for hiding this comment

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

cargo make only supports >1.78.0. Although there are more recent Rust versions, I wanted to make the minimum version bump required in this PR to play it safe

description = "Build WASM target for deno_task_shell"
command = "wasm-pack"
install_crate = { crate_name = "wasm-pack", binary = "wasm-pack", test_arg = "-V" }
args = ["build", "--target", "deno", "--scope", "@deno/deno_task_shell"]
Copy link
Author

Choose a reason for hiding this comment

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

One open question is what the name of this WASM question should be. I think the name @deno/deno_task_shell is okay, but in reality we're only exposing the task parsing API so maybe it should be something that better conveys the scope like @deno/shell-cmd-processing

Copy link
Author

Choose a reason for hiding this comment

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

I took this file as-is from dax. I'm not sure if there is anything in this file that should be changed, so I left it as-is to start

Copy link
Member

Choose a reason for hiding this comment

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

We should remove console_static_text and once_cell.

@@ -0,0 +1,5 @@
[tasks.wasm-build]
description = "Build WASM target for deno_task_shell"
command = "wasm-pack"
Copy link
Author

Choose a reason for hiding this comment

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

Although my PR properly generates a WASM file, it's not clear to me what the best way to publish it would be given the new WASM support in Deno 2.1

I created an issue on JSR & wasm-pack to try and clarify this: rustwasm/wasm-pack#1454

@dsherret dsherret changed the title Support for WASM builds Support for Wasm builds Dec 6, 2024
Copy link
Member

@dsherret dsherret left a comment

Choose a reason for hiding this comment

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

Probably we should pattern off https://github.com/denoland/deno_graph/tree/main for this. We use https://github.com/denoland/wasmbuild and not wasmpack.

Also, for the name, maybe @deno/task-shell-parser or something like that?

CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true

[tasks.wasm-build]
# see wasm/Makefile.toml for task definition
Copy link
Member

Choose a reason for hiding this comment

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

Can you remove this file and instead use a deno.json with tasks? We'd rather not have to add cargo install cargo-make to the setup instructions.

Copy link
Author

@SebastienGllmt SebastienGllmt Dec 6, 2024

Choose a reason for hiding this comment

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

I tried wasmbuild but it only generates a single JS file that gets instantiated which felt like the old way to generate things given rustwasm/wasm-bindgen#4287

I'm not sure if the plan is to update wasmbuild in some way, but I believe this is the issue tracking this: denoland/wasmbuild#145

@@ -19,3 +19,7 @@ let exit_code = deno_task_shell::execute(
Default::default(), // custom commands
).await;
```

## WASM
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
## WASM
## Wasm

Copy link
Member

Choose a reason for hiding this comment

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

We should remove console_static_text and once_cell.

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

Successfully merging this pull request may close these issues.

Publish WASM as NPM/JSR package?
3 participants