@aptre/common 0.32.4 → 0.32.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +64 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -185,6 +185,70 @@ The generator uses sensible defaults but can be customized:
|
|
|
185
185
|
- **ToolsDir**: Plugin binary location (default: `.tools`)
|
|
186
186
|
- **Cache**: Manifest file (default: `.protoc-manifest.json`)
|
|
187
187
|
|
|
188
|
+
### `package.json` Configuration
|
|
189
|
+
|
|
190
|
+
When a repo has a `package.json`, `aptre generate` also reads an optional
|
|
191
|
+
top-level `aptre` config object from it.
|
|
192
|
+
|
|
193
|
+
Example:
|
|
194
|
+
|
|
195
|
+
```json
|
|
196
|
+
{
|
|
197
|
+
"name": "spacewave",
|
|
198
|
+
"private": true,
|
|
199
|
+
"aptre": {
|
|
200
|
+
"tsImportBoundaries": ["auth", "bldr", "db", "forge", "identity", "net"]
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### `aptre.tsImportBoundaries`
|
|
206
|
+
|
|
207
|
+
`tsImportBoundaries` configures how generated TypeScript protobuf imports are
|
|
208
|
+
rewritten inside a monorepo.
|
|
209
|
+
|
|
210
|
+
By default, same-module generated imports stay relative. That is usually what
|
|
211
|
+
you want in a single-package repo.
|
|
212
|
+
|
|
213
|
+
For monorepos that generate protobuf TypeScript into multiple top-level members,
|
|
214
|
+
relative imports can break when a build system mirrors sources into another tree
|
|
215
|
+
or when each member needs a stable repo-root import path. In that case, define
|
|
216
|
+
module-relative boundary prefixes in `aptre.tsImportBoundaries`.
|
|
217
|
+
|
|
218
|
+
When a generated `*.pb.ts` file imports another generated protobuf file:
|
|
219
|
+
|
|
220
|
+
- If the import stays within the same configured boundary, it remains relative.
|
|
221
|
+
- If the import crosses from one configured boundary to another, `aptre`
|
|
222
|
+
rewrites it to an `@go/...` import.
|
|
223
|
+
- Imports that resolve outside the current module are still rewritten to
|
|
224
|
+
`@go/...` from `vendor/` as before.
|
|
225
|
+
|
|
226
|
+
Given:
|
|
227
|
+
|
|
228
|
+
```json
|
|
229
|
+
{
|
|
230
|
+
"aptre": {
|
|
231
|
+
"tsImportBoundaries": ["bldr", "db"]
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
an import like:
|
|
237
|
+
|
|
238
|
+
```ts
|
|
239
|
+
import { VolumeInfo } from '../../db/volume/volume.pb.js'
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
in `bldr/plugin/plugin.pb.ts` becomes:
|
|
243
|
+
|
|
244
|
+
```ts
|
|
245
|
+
import { VolumeInfo } from '@go/github.com/yourorg/yourrepo/db/volume/volume.pb.js'
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
Boundary entries are matched against paths relative to the Go module root, so
|
|
249
|
+
they should name repo directories such as `bldr`, `db`, or `net`, not full
|
|
250
|
+
module paths.
|
|
251
|
+
|
|
188
252
|
## Related Projects
|
|
189
253
|
|
|
190
254
|
- [starpc](https://github.com/aperturerobotics/starpc) — Streaming RPC for Go, TypeScript, and Rust
|