fix: generate root barrel file in multi-target codegen#875
Merged
pyramation merged 1 commit intomainfrom Mar 21, 2026
Merged
Conversation
generateMulti() was generating per-target barrel files (admin/index.ts, auth/index.ts, etc.) but never creating the root src/index.ts that re-exports all targets as namespaces. The pregenerate script deletes src/index.ts via rimraf, and the codegen never recreated it, causing downstream packages like @constructive-io/node to fail with TS2307: Cannot find module '@constructive-io/sdk'. Adds generateMultiTargetBarrel() which creates: export * as admin from './admin'; export * as auth from './auth'; export * as public_ from './public'; // reserved word alias Called from generateMulti() after all targets complete.
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
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.
Summary
generateMulti()creates per-target barrel files (admin/index.ts,auth/index.ts, …) but never generated the rootsrc/index.tsthat re-exports all targets as namespaces. The SDK'spregeneratescript deletessrc/index.tsviarimraf, and codegen never recreated it — so after any schema propagation run,@constructive-io/nodefails to build:Fix: Add
generateMultiTargetBarrel()to the codegen barrel module, and call it fromgenerateMulti()after all targets complete. It writes:The output root is derived from the first successful target's output path (
path.dirname(firstOutput)).Review & Testing Checklist for Human
path.dirname(firstOutput)is correct for your codegen configs — this assumes all targets share the same parent directory (e.g../src/admin,./src/auth→./src). If any consumer configures targets with divergent roots, the barrel would land in the wrong place.src/index.ts— specifically thatexport * as public_ from './public'is produced (the_suffix for JS reserved words). Runpnpm generateinsdk/constructive-sdkand diff the output against what was onmainbefore.@constructive-io/nodebuilds after codegen. Localpnpm buildpassed on this branch, but CI codegen uses a different path (the hub workflow).Notes
JS_RESERVEDset is comprehensive but static — covers ES2015+ reserved words plus future reserved words in strict mode.generateMultiTargetBarrel(). Consider adding one if the codegen test suite is easy to extend.Cannot find module 'grafast'error seen when runninggenerate-sdk.tslocally — that's a pnpm peer-dependency hoisting issue with@graphile-contrib/pg-many-to-manyand is unrelated.Link to Devin session: https://app.devin.ai/sessions/5d550def7a314c97854ec12fa09dd4ca
Requested by: @pyramation