Skip to content

Commit

Permalink
Add additional options for generating imports (#1364)
Browse files Browse the repository at this point in the history
* Add additional docs on options

Signed-off-by: Steve Ayers <[email protected]>

* Remove WKT

Signed-off-by: Steve Ayers <[email protected]>

* Format

Signed-off-by: Steve Ayers <[email protected]>

* Update MIGRATING.md

Co-authored-by: Timo Stamm <[email protected]>
Signed-off-by: Steve Ayers <[email protected]>

* Update MIGRATING.md

Co-authored-by: Timo Stamm <[email protected]>
Signed-off-by: Steve Ayers <[email protected]>

---------

Signed-off-by: Steve Ayers <[email protected]>
Co-authored-by: Timo Stamm <[email protected]>
  • Loading branch information
smaye81 and timostamm authored Dec 6, 2024
1 parent e409055 commit 84a65b9
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions MIGRATING.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ version: v2
plugins:
- local: protoc-gen-es
out: src/gen
include_imports: true
opt: target=ts
- - local: protoc-gen-connect-es
- out: src/gen
Expand All @@ -88,6 +89,7 @@ plugins:
- - remote: buf.build/bufbuild/es:v1.10.0
+ - remote: buf.build/bufbuild/es:v2.2.0
out: src/gen
include_imports: true
opt: target=ts
- - remote: buf.build/connectrpc/es
- out: src/gen
Expand All @@ -108,6 +110,7 @@ version: v2
plugins:
- local: protoc-gen-es
out: src/gen
include_imports: true
```

With this option, `buf generate` will delete the contents of `src/gen` before generating code.
Expand All @@ -123,6 +126,7 @@ version: v2
plugins:
- local: protoc-gen-es
out: src/gen
include_imports: true
opt:
- target=ts
+ - import_extension=js
Expand All @@ -137,6 +141,7 @@ version: v2
plugins:
- local: protoc-gen-es
out: src/gen
include_imports: true
opt:
- target=ts
- - import_extension=none
Expand All @@ -151,6 +156,14 @@ Now that dependencies and `buf.gen.yaml` are updated, the next step is to re-gen
migration tool does not handle code generation, so be sure to do so in whatever
way your project is configured. For example, `npx buf generate` or `npm run generate`.

> [!NOTE]
> Ensure that your `buf.gen.yaml` includes the following options to generate
> code for imports.
>
> - `include_imports: true`
See the [Gotchas](#the-new-plugins-generates-missing-imports) section for an explanation.

## Update your application code

Now that dependencies are updated and new code is generated, let's go through the
Expand Down

0 comments on commit 84a65b9

Please sign in to comment.