This repository has been archived by the owner on Feb 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
playground crate, basic WASM/TS setup #14
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmichi
reviewed
Sep 24, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The project name is "ink!" (with the exclamation mark). Could you replace other occurrences of the name without !
as well? For example in the repo readme.
Co-authored-by: Michael Müller <michi@parity.io>
Co-authored-by: Michael Müller <michi@parity.io>
Co-authored-by: Michael Müller <michi@parity.io>
Co-authored-by: Michael Müller <michi@parity.io>
Co-authored-by: Michael Müller <michi@parity.io>
Co-authored-by: Michael Müller <michi@parity.io>
thought2
suggested changes
Oct 6, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm! just the small things that I comment we should discuss...
nmauersberg
added a commit
to nmauersberg/ink-playground
that referenced
this pull request
Oct 7, 2021
Was not applied because of changed paths
7 tasks
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Introduction
The ink Playground runs Rust Analyzer in the Browser. To do this, we need to compile certain Rust Analyzer Crates to WebAssembly to make them available in the Browser. This PR adds a new Crate
playground
to the repo which intends to serve this feature in future iterations. We provide with this PR the basic required tools and components for the desired setup, together with the corresponding testing frameworks and CI configurations.Usage
To test this PR, you need to install
wasm-pack
together with the required nightly toolchain, cd into the crate directory and run yarn start:curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
rustup component add rust-src --toolchain nightly-2021-07-29-x86_64-unknown-linux-gnu
cd crates/playground
yarn start
Used components/packages
On the Rust side of the
playground
crate:wasm-pack
for creating a hybrid rust/typescript applicationwasm-bindgen
to allow JavaScript bindings for the Rust/WASM fucntionsrayon
for multithreadingwasm-bindgen-rayon
allows to access the multithreading functionalieties from within the browserOn the TypeScript side:
wasm-pack-plugin
takes care of executing wasm-pack build commands when running yarn build. It also provides watch script functionalities when running yarnstart end
, when editing the rust source-code, it then re-compiles it to WebAssemblycomlink
reduces the complexity in handling WebWorkers, especially the WebWorkers which are providing the Rust Analyzer functionalitiesCode structure
There are two directories containing source-code in this crate:
src
contains the Rust code which gets compiled to WebAssemblyjs
contains the JS/TS code which serves the Frontend app. It references thepkg
directory to which the Rust code from thesrc
directory gets compiled to p[rovide the WebAssembly Webworkers through the Comlink plugin.Currently the App does one call to a Webworker which invokes the evaluation of a WebAssembly function
greet()
, which is provided by the compiled Rust code. It is only added to test the interaction between the different WASM/TS tools of this crate.The package provides unit testing with jest and React testing library and unit testing of the Wasm part by
wasm-pack test
. It contains the WebAssembly tests in thetests
dir, while the tests executed by jest are located underjs/__tests__
. We configured yarn in a way such that runningyarn test
is running both the WebAssembly and the jest tests.We configured the CI in a way such that it runs all the provided tests in this crate and installs the required tooling and toolchain first.