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

fix: update readme and contributing #44

Merged
merged 1 commit into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 91 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Welcome!

This project hopes to be simple to contribute to. It's written in Rust and Typescript, and uses [Bun](https://bun.sh/) to manage the VsCode build process.

## Dev Setup

### Install Dependencies

Please install the following dependencies:

- Pre-reqs:

| Dependency | Version |
| ---------- | ------- |
| Node | >20 |
| Bun | > 1.0.0 |
| Rust + Cargo | Edition 2021 |
| wasm-pack | > 0.10.0 |

> rustup is recommended - https://rustup.rs/

----

- after installing the above, please run the following:

```bash
bun install
```

- install wasm-pack:

```bash
cargo install wasm-pack
```

### Notes on Bun

Why both package-lock and bun.lockb? The `@vscode/vsce` package uses npm under the hood to list dependencies. It's important that we keep both package-lock and bun.lock in sync.


### VsCode - How it works (for now)

The main entry point of the project is of course the `package.json`. The `package.json` contains a `scripts` section that defines the build process.

To run the build process, simply run:

```bash
bun run build
```

To run the build process in watch mode, simply run:

```bash
bun run watch
```

Both of these scripts run `build.ts`, which executes `wasm-pack` on any `.rs` change, and `esbuild` on any `.ts` change.

> We're using `esbuild` for bundling until Bun can completely support CJS, which is required by VsCode's internal LSP Node servers.

After running `build.ts`, the `out` files are copied to the `server/src/rust` dir and also `server/out` directories. This is so that the TS can pick up the types generated by wasm-pack and the WebAssembly module can be loaded by the LSP server after `vsce` packages the extension.


### VsCode - Debugging

After you run the watch mode in a terminal, you can press `F5` to start debugging the extension. This will open a new VsCode window with the extension running in debug mode.


## Rust - How it works (for now)

There are two crates in this project:
- does-it-throw
- does-it-throw-wasm

The `does-it-throw` crate is a library crate that contains the core logic of the extension. It's a library crate because it can be used across other LSPs and the WebAssembly module.

To run integration tests on the library crate, simply run the following at the project root:

```bash
cargo test
```

`does-it-throw-wasm` is a binary crate that contains the WebAssembly module. It's a binary crate because it's compiled to WebAssembly. It depends on the `does-it-throw` crate.

To run unit tests on the WebAssembly module, simply run the following at the project root:

```bash
cargo test
```


13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,22 @@ Untyped `throw` statements can be a pain for those who come from languages like
- Currently, it only supports ECMAScript files and the following file types: `.ts`, `.js`, `.tsx` and `.jsx`.
- Call expression tracing (Aka "Calls to Throws") is now set to one level deep. Hope to make this configurable in the future!

> To view all known limitations, please see the [issues](https://github.com/michaelangeloio/does-it-throw/issues) page.


## Contributing
Contributions are certainly welcome! Please open an issue or submit a PR. If you find a use case that isn't supported yet, please search the open issues and open a new one if it doesn't exist.

### Dev Setup
Everything can be found in the [CONTRIBUTING.md](./CONTRIBUTING.md) file!

## Feedback & Suggestions
Please use the GitHub discussions tab to provide feedback and suggestions. Thanks!

### Development & Technical Details
Everything can be found in the [CONTRIBUTING.md](./CONTRIBUTING.md) file!
## Acknowledgements

- [SWC](https://swc.rs/) - The blazing fast javascript compiler written in Rust.
- [Oso Vscode Extension](https://github.com/osohq/oso) - For the WASM inspiration. Excellent article [here](https://www.osohq.com/post/building-vs-code-extension-with-rust-wasm-typescript).

## License
MIT
MIT - See [LICENSE](./LICENSE) for more information.
Loading