fix(generate): lazy-load dart renderer so it can't 500 all languages - #8
Merged
Conversation
The dart renderer was required at module top level, so when Vercel's file tracer omitted the mispublished codama-renderers-dart package from the serverless bundle, the require threw at import time and 500'd /api/generate for ALL languages, not just dart. Move the require into the dart switch case so a resolution failure is caught by the route handler and only affects dart. Add outputFileTracingIncludes to force the package's files into the generate route's bundle so dart works too.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Caution Review failedAn error occurred during the review process. Please try again later. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
dev-jodee
added a commit
that referenced
this pull request
Jul 17, 2026
#8 stopped the total outage but dart itself still 500'd: its CJS build (loaded via createRequire) requires the .cjs variants of a large @codama/@solana/@noble tree that Next only bundles as .mjs, so @codama/visitors-core/dist/index.node.cjs was missing from the lambda. Load dart's real ESM build by path instead (bundler-ignored so Turbopack leaves it a runtime import, avoiding its "expression too dynamic" error), which reuses the already-bundled .mjs deps. Broaden outputFileTracingIncludes to guarantee dart's ESM closure (@codama/@solana/@noble) is present.
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.
Fixes a production outage: /api/generate 500'd for ALL languages after the Dart deploy. codama-renderers-dart was required at module top level; its mispublished exports (import -> missing .mjs) defeat Vercel's file tracer, so the package was omitted from the serverless bundle and the top-level require threw at import time, taking down every language. Fix: lazy-load the require inside the dart case (failure now caught, only affects dart) + outputFileTracingIncludes to force the package into the /api/generate lambda. Verified locally: prettier/lint/tests(25)/build green; isolation test (package removed) -> typescript 200, dart caught error, no crash; package present -> dart 200 with 12 .dart files.