feat: import consumer spec/FS types instead of replicating them (package mode)#18
Merged
Merged
Conversation
…age mode) In package mode (`generators.types`), each target kind's generated module replicated every consumer kind's Spec + FS interface inline, so a change to a widely-consumed spec (e.g. ServiceSpec / SubscriberSpec) regenerated every kind that accepts it as a consumer — a one-field change produced a many-file diff. Instead, import each consumer's Spec + FS from the consumer's own module and re-export them (so the consumer's dependent hooks keep importing `<Consumer>Spec` / `<Consumer>FS` from the target module). Inline mode (single-file output) is unchanged — it still replicates. The consumer's own module already exports its spec as `<Consumer>Spec` and its FS as `FS`; the per-file tsc (`--moduleResolution bundler`) resolves the relative cross-module import, exactly like the shared `./host` module. Verified against the api repo: regenerating all kind types shrinks them ~1575 lines with zero change to any rendered `_infra` and a green hook typecheck.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
In package mode (
generators.types), each target kind's generated module replicates every consumer kind'sSpec+FSinterface inline (so its dependent-hook context/hook are concretely typed). A change to a widely-consumed spec —ServiceSpec,SubscriberSpec— therefore regenerates every kind that accepts it as a consumer: a one-field change (e.g. addinghpato the subscriber spec) produces a ~12-file diff.The shared
./hostmodule already established the fix: emit an import instead of replicating.What
dependentInterfaces(package mode) no longer inlines the consumerSpec/FS.VeilTypesinstead emits, per consumer kind:*DependentHookContext/*DependentHook.<Consumer>Spec/<Consumer>FSfrom this (target) module, so they must stay exported (an un-re-exported aliased import is TS2459).Inline (single-file) mode is untouched — still replicates. The consumer's own module already exports its spec as
<Consumer>Specand FS asFS; veil's per-file tsc (--moduleResolution bundler) resolves the relative cross-module import, same as./host.Validation
pkg/build/graph_test.go): package mode imports + re-exports and does not replicate; inline mode still replicates; no-consumer kinds emit nothing.go test ./...green.platform/types/*.tsshrinks ~1,575 lines (12 files), the hook typecheck stays green, and every rendered_infrais byte-identical.🤖 Generated with Claude Code