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

Add local development instructions to README #39

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
58 changes: 58 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -333,3 +333,61 @@ sql:
runtime: node
driver: better-sqlite3 # npm package name
```

## Development

If you want to build and test sqlc-gen-typescript locally, follow these steps:

1. Clone the repository and install dependencies:
```
git clone https://github.com/sqlc-dev/sqlc-gen-typescript.git
cd sqlc-gen-typescript
npm install
```

2. Make your desired changes to the codebase. The main source files are located in the `src` directory.

3. If you've made changes that require updating dependencies, run:
```
npm install
```

4. Build the WASM plugin:
Check the `Makefile` for details.
```
make out.js

# Ensure you have Javy installed and available in your PATH
make examples/plugin.wasm
```

5. To test your local build, create a test project with a `sqlc.yaml` file containing:

```yaml
version: '2'
plugins:
- name: ts
wasm:
url: file://{path_to_your_local_wasm_file}
sha256: {sha256_of_your_wasm_file}
sql:
- schema: "schema.sql"
queries: "query.sql"
engine: {your_database_engine}
codegen:
- out: db
plugin: ts
options:
runtime: node
driver: {your_database_driver}
```

Replace the placeholders with appropriate values for your setup.

6. Run sqlc in your test project to generate TypeScript code using your local plugin build:
```
sqlc generate
```

For more details on sqlc development, refer to the sqlc core development guide. This guide provides additional information on setting up and working with sqlc in general, which may be useful for contributors to this project.
https://docs.sqlc.dev/en/latest/guides/development.html