-
Notifications
You must be signed in to change notification settings - Fork 379
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
WebAssembly #3066
Comments
Hmm, what kind of support do you expect from IDE? "Compiling" is a responsibility of, well, the compiler =) You can find an appropriate instruction about compiling Rust to wasm in wasm-pack or stdweb projects. If you know some specific wasm-related features you expect from our plugin, feel free to list them =) Btw IntelliJ-Rust works in WebStorm, and IntelliJ IDEA Ultimate also supports JavaScript. |
That is certainly true! But there is also project structure, dependency management to and from Javascript libraries, packaging, deployment, debugging an app running in the browser and interacting with the DOM. You might consider separate sub project types for WASM projects, Web Components written in WASM, single page apps written in Yew. |
It's interesting. Ok, for now we made literally nothing about WASM support. And to be honest, I know too little about it. If you can describe what exactly we can do to help wasm developers, feel free to open specific issues about it. For example, there is an issue about wasm test runners #3007. It could be a good issue "Support run Yew apps", for example. |
To run wasm-pack from run configuration like Cargo would be a start. |
The current intellij-rust does not recognize any object provided by web_sys, and that is quite annoying as that means that there is no auto-completition support. |
@SnowyCoder
UPD: IntelliJ platform has 2 file size limits. The first one can be adjusted with system property |
Hello, thanks for the great work on it so far. Just to clarify, since the plugin supports 2 out of the 3 major I tried it, but it doesn't work on my setup. Just wondering if it is not supported yet or if I'm missing some config. UPDATE: |
On a side note. I used intellij idea to develop a web project that is made 100% in rust (native + wasm). I used a multiproject setup, with common parts of the logic written in a shared project that is used as dependency on backend and frontend. Surprisingly, EVERYTHING worked really well. Code completion, code navigation, refactoring in both frontend and backend. I did not expect it. Big thanks to developer of rust plugin! If you're interested to checkout how the project is setup you may take a look here https://github.com/edvorg/rustmith, but there is nothing idea-specific there really. Just a standard cargo project. |
Thank you @edvorg , as a C# developer coming from Rider and previously VS, I'm 'spoilt' - I just want to write code, add some breakpoints and hit the 'debug' button, it's tiring having to learn so many new tools so often and I'm trying to distance myself from the ever-twisting clusterfunk that seems to be what's become of the modern JavaScript landscape. Regarding @NeverGivinUp 's original question, my interpretation of "Integrated" Development Environment is that it "Integrates" all the tools - including whatever compilers are required. Again, back to my C# point, if I add a file type that's supported, I would expect the IDE to compile it without me having to do anything (except perhaps download the compiler of my choice and perhaps make a selection in the IDE.) Now, the Rust Plugin does do this very well for what it supports, and I'm largely delighted with how easy it is to create a command-line app in Rust and be able to debug it. But one of the main points of Rust is that you can create WASM Libraries with it (it's on the rust-lang.org front page FFS) so simply not doing anything for WASM seems to me like the ball has been dropped. |
Is there a workaround for web sys? I use it regularly and it is really annoying. :( |
4734: CARGO: support items generated by build scripts r=vlad20012 a=Undin While compilation, crate's [build script](https://doc.rust-lang.org/cargo/reference/build-scripts.html) can generate some new code, `cfg` attributes, environment variables and so on. These changes are the first attempt to support them. What these changes do: * collect info about executed build scripts while refresh. Under the hood, it uses `cargo check` so it can take much more time to get info about project * use generated `cfg` options while `cfg` attribute evaluation. Should fix #4631 * use generated environment variables for path evaluation in include macro calls * extend include macro support. Now, the plugin can process calls without filename in string literals like `include!(env!("BINDINGS"))`. Should make possible to force intelliSence work for `web-sys` (see #3066) * Since recent nightly builds of cargo, it makes possible to turn on full support of `include` macro without using `cargo build --build-plan` and avoid issue about full project recompilation Note, it is under experimental feature and disabled by default. To try it just enabled `org.rust.cargo.evaluate.build.scripts` in `Help | Find Action | Experimental Features` dialog Co-authored-by: Arseniy Pendryak <a.pendryak@yandex.ru>
4734: CARGO: support items generated by build scripts r=vlad20012 a=Undin While compilation, crate's [build script](https://doc.rust-lang.org/cargo/reference/build-scripts.html) can generate some new code, `cfg` attributes, environment variables and so on. These changes are the first attempt to support them. What these changes do: * collect info about executed build scripts while refresh. Under the hood, it uses `cargo check` so it can take much more time to get info about project * use generated `cfg` options while `cfg` attribute evaluation. Should fix #4631 * use generated environment variables for path evaluation in include macro calls * extend include macro support. Now, the plugin can process calls without filename in string literals like `include!(env!("BINDINGS"))`. Should make possible to force intelliSence work for `web-sys` (see #3066) * Since recent nightly builds of cargo, it makes possible to turn on full support of `include` macro without using `cargo build --build-plan` and avoid issue about full project recompilation Note, it is under experimental feature and disabled by default. To try it just enabled `org.rust.cargo.evaluate.build.scripts` in `Help | Find Action | Experimental Features` dialog Co-authored-by: Arseniy Pendryak <a.pendryak@yandex.ru>
4734: CARGO: support items generated by build scripts r=vlad20012 a=Undin While compilation, crate's [build script](https://doc.rust-lang.org/cargo/reference/build-scripts.html) can generate some new code, `cfg` attributes, environment variables and so on. These changes are the first attempt to support them. What these changes do: * collect info about executed build scripts while refresh. Under the hood, it uses `cargo check` so it can take much more time to get info about project * use generated `cfg` options while `cfg` attribute evaluation. Should fix #4631 * use generated environment variables for path evaluation in include macro calls * extend include macro support. Now, the plugin can process calls without filename in string literals like `include!(env!("BINDINGS"))`. Should make possible to force intelliSence work for `web-sys` (see #3066) * Since recent nightly builds of cargo, it makes possible to turn on full support of `include` macro without using `cargo build --build-plan` and avoid issue about full project recompilation Note, it is under experimental feature and disabled by default. To try it just enabled `org.rust.cargo.evaluate.build.scripts` in `Help | Find Action | Experimental Features` dialog Co-authored-by: Arseniy Pendryak <a.pendryak@yandex.ru>
4734: CARGO: support items generated by build scripts r=vlad20012 a=Undin While compilation, crate's [build script](https://doc.rust-lang.org/cargo/reference/build-scripts.html) can generate some new code, `cfg` attributes, environment variables and so on. These changes are the first attempt to support them. What these changes do: * collect info about executed build scripts while refresh. Under the hood, it uses `cargo check` so it can take much more time to get info about project * use generated `cfg` options while `cfg` attribute evaluation. Should fix #4631 * use generated environment variables for path evaluation in include macro calls * extend include macro support. Now, the plugin can process calls without filename in string literals like `include!(env!("BINDINGS"))`. Should make possible to force intelliSence work for `web-sys` (see #3066) * Since recent nightly builds of cargo, it makes possible to turn on full support of `include` macro without using `cargo build --build-plan` and avoid issue about full project recompilation Note, it is under experimental feature and disabled by default. To try it just enabled `org.rust.cargo.evaluate.build.scripts` in `Help | Find Action | Experimental Features` dialog Co-authored-by: Arseniy Pendryak <a.pendryak@yandex.ru>
With the latest release (116),
[EDIT]
|
It works! Absolutely fantastic! Thank you very much to everyone involved, this made my day! |
This still isn't working for me, even with the changes @panstromek mentioned. It's not even a simple "it doesn't work" either since in some cases it is kind of working, but it's working incorrectly. I have this in my [dependencies.web-sys]
version = "0.3.36"
features = [
'CanvasRenderingContext2d',
'Document',
'Element',
'HtmlCanvasElement',
'Window',
] and here's some code that exhibits the issue: fn foo() {
let document: web_sys::Document = web_sys::window().unwrap().document().unwrap();
let document: web_sys::Document = web_sys::document(web_sys::window().unwrap()).unwrap();
} That code has three different parts:
#[wasm_bindgen]
extern "C" {
// ...
#[cfg(feature = "Document")]
# [ wasm_bindgen ( structural , method , getter , js_class = "Window" , js_name = document ) ]
#[doc = "Getter for the `document` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Window/document)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Document`, `Window`*"]
pub fn document(this: &Window) -> Option<Document>;
// ...
} My current build versions are:
I set the two options mentioned by @panstromek, I've tried this with both the default and experimental macro engines, and tried restarting IntelliJ all along the way. Note that when I look at the The relevant web_sys code
mod features;
pub use features::*;
// ...
#[cfg(feature = "Window")]
pub fn window() -> Option<Window> { The // ...
#[cfg(feature = "Window")]
#[allow(non_snake_case)]
mod gen_Window;
#[cfg(feature = "Window")]
pub use gen_Window::*;
// ... The #[wasm_bindgen]
extern "C" {
// ...
#[cfg(feature = "Document")]
# [ wasm_bindgen ( structural , method , getter , js_class = "Window" , js_name = document ) ]
#[doc = "Getter for the `document` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Window/document)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Document`, `Window`*"]
pub fn document(this: &Window) -> Option<Document>;
// ...
} |
I've managed to track down the root issue, and it seems to be caused by use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern "C" {
#[wasm_bindgen]
fn global() -> Foo;
type Foo;
/// https://rustwasm.github.io/docs/wasm-bindgen/reference/attributes/on-js-imports/constructor.html
#[wasm_bindgen(constructor)]
fn new() -> Foo;
/// https://rustwasm.github.io/docs/wasm-bindgen/reference/attributes/on-js-imports/method.html
#[wasm_bindgen(method)]
fn method(this: &Foo);
/// https://rustwasm.github.io/docs/wasm-bindgen/reference/attributes/on-js-imports/static_method_of.html
#[wasm_bindgen(static_method_of = Foo)]
fn static_foo() -> Foo;
}
/// This compiles, but go to definition on `Foo`, `new`, `method`, and `static_foo` doesn't work.
/// The `global` function resolves fine though.
fn correct() {
global();
let new_foo: Foo = Foo::new();
new_foo.method();
let static_result = Foo::static_foo();
}
/// This does not compile, but go to definition on `new`, `method`, and `static_foo` work.
/// The `Foo` type is still broken and the `global` function resolves fine.
fn incorrect() {
global();
let new_foo: Foo = new();
method(new_foo);
let static_result = static_foo();
} |
please support rust wasam in the rust plugin. I dont want to keep invoking things from the command line. There should be a build and run tests command template just like there is for cargo. |
5715: PRJ: Project generation with cargo-generate r=ortem a=avrong Currently, it is project generation using cargo-generate merged with standard cargo templates. ## CLion <img width="912" alt="image" src="https://user-images.githubusercontent.com/6342851/88849247-4baad880-d1f2-11ea-8eb6-17f8e9b178ab.png"> ## IntelliJ IDEA <img width="929" alt="Frame 1(3)" src="https://user-images.githubusercontent.com/6342851/88853074-dc37e780-d1f7-11ea-8570-bcdef26ef108.png"> Related to #3066 Additionally: Closes #5746 Co-authored-by: Aleksei Trifonov <avrong@avrong.me>
5745: RUN: Implement wasm-pack run configuration r=ortem a=avrong wasm-pack is a tool that provides building and bundling WebAssembly binary generated by Cargo and wasm-bindgen. It gives developers the ability to seamlessly interop between Rust and JS code. This request aims to provide an option to run wasm-pack commands as run configuration. Currently, it supports basic command execution within Run Configurations and installation if it doesn't exist in the system. <img width="1152" alt="Run Configurations Old" src="https://user-images.githubusercontent.com/6342851/89078539-43d36b80-d38d-11ea-9a56-eaf9af30aa76.png"> <img width="1218" src="https://user-images.githubusercontent.com/6342851/89654603-8f2bd380-d8d1-11ea-85b1-7b031ec48e44.png"> Related to #3066 Co-authored-by: Aleksei Trifonov <avrong@avrong.me>
5745: RUN: Implement wasm-pack run configuration r=ortem a=avrong wasm-pack is a tool that provides building and bundling WebAssembly binary generated by Cargo and wasm-bindgen. It gives developers the ability to seamlessly interop between Rust and JS code. This request aims to provide an option to run wasm-pack commands as run configuration. Currently, it supports basic command execution within Run Configurations and installation if it doesn't exist in the system. <img width="1152" alt="Run Configurations Old" src="https://user-images.githubusercontent.com/6342851/89078539-43d36b80-d38d-11ea-9a56-eaf9af30aa76.png"> <img width="1218" src="https://user-images.githubusercontent.com/6342851/89654603-8f2bd380-d8d1-11ea-85b1-7b031ec48e44.png"> Related to #3066 Co-authored-by: Aleksei Trifonov <avrong@avrong.me>
5846: RUN: Command completion for wasm-pack r=ortem a=avrong Provides command completion in Run Anything and Run Configurations editor dialog. <img width="1152" alt="Run Anything" src="https://user-images.githubusercontent.com/6342851/88953876-342b2880-d2a2-11ea-9fb0-03d941d918c9.png"> <img width="1152" alt="Run Configurations" src="https://user-images.githubusercontent.com/6342851/88953868-31303800-d2a2-11ea-916a-c361f07cd751.png"> Depends on #5745 Related to #3066 Co-authored-by: Aleksei Trifonov <avrong@avrong.me>
5933: Introduce line marker for wasm_bindgen attributes in WebAssembly projects r=ortem a=avrong Expected workflow: navigating from Rust statement to JS one. Then having the ability to navigate to JS parts related to it. ### Current implementation <img width="1060" src="https://user-images.githubusercontent.com/6342851/90410167-b1340b80-e0b2-11ea-9144-de4703509744.png"> ### How it works <img width="600" src="https://user-images.githubusercontent.com/6342851/90269585-856e1700-de61-11ea-9ffd-ac4067e2a80a.gif"> Related to #3066 Co-authored-by: ortem <ortem00@gmail.com> Co-authored-by: Aleksei Trifonov <avrong@avrong.me>
5939: RUN: Add build task for wasm-pack configurations r=ortem a=avrong Adds `Before launch` task for `wasm-pack` run configurations. Emulates the first part of wasm-pack process — executing `cargo build` with specific arguments like `--target wasm32-unknown-unknown`. Provides a way to show cargo build tool window before `wasm-pack` packing instead of raw printing in the terminal. The implementation is mostly similar to `CargoBuildTaskProvider`. Related to #3066 Co-authored-by: Aleksei Trifonov <avrong@avrong.me>
Would be nice to be able to debug into tests run as |
Are you planning to support or already supporting compiling to WASM? Where would I find instructional documentation? I think there already is some support for compiling Kotlin to WASM, so that could be an starting point for the WASM side. WASM requires Javascript support, to really do stuff in the browser. So this might be a compile target suited specifically for WebStorm-integration. Also: support for Yew would be great.
META TODO
Feature support list:
New project
dialogcargo-generate
templateswasm-pack
run configurationsbuild
andtest
commandswasm-pack
commands inRun Anything
wasm-bindgen
tests Custom test runner run context configuration #3007npm init wasm-app
andnpm install
npm run start
wasmtime
)watch
andserve
subcommands) Addwatch
andserve
subcommands towasm-pack
rustwasm/rfcs#10cargo-generate
wasm-pack
The text was updated successfully, but these errors were encountered: