Skip to content

Commit

Permalink
Document how to use multiple plugin options (#436)
Browse files Browse the repository at this point in the history
  • Loading branch information
timostamm authored Mar 24, 2023
1 parent 8748217 commit ebd06ff
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions packages/protoc-gen-es/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,18 @@ npm install @bufbuild/protobuf
```

We use peer dependencies to ensure that code generator and runtime library are
compatible with each other. Note that yarn and pnpm only emit a warning in this case.
compatible with each other. Note that npm installs them automatically, but yarn
and pnpm do not.


## Generating code

### With buf

```bash
npm install --save-dev @bufbuild/buf
```

Add a new configuration file `buf.gen.yaml`:

```yaml
Expand All @@ -32,26 +37,15 @@ plugins:
# This will invoke protoc-gen-es and write output to src/gen
- name: es
out: src/gen
opt: target=ts
```
Add the following script to your `package.json`:

```json
{
"name": "your-package",
"version": "1.0.0",
"scripts": {
"generate": "buf generate"
},
// ...
}
opt:
# Add more plugin options here
- target=ts
```
To generate code for all protobuf files within your project, simply run:
```bash
npm run generate
npx buf generate
```

Note that `buf` can generate from various [inputs](https://docs.buf.build/reference/inputs),
Expand Down

0 comments on commit ebd06ff

Please sign in to comment.