Repository navigation
📝 docs(graphql-codegen-client-preset): monorepo paths - #692
Jakub Kopřiva (koprivajakub) wants to merge 1 commit into
Conversation
Document that Turbopack passes its workspace root to SWC as cwd, so relative artifactDirectory values must be written from that root in monorepos. Edits README.tmpl.md, which README.md is generated from. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
This repository accepts pull requests from approved contributors, users with write access, and bot accounts. Your account is not currently on the approved contributor list, so this pull request is being closed automatically. Thank you for your interest in contributing to SWC. This notice intentionally asks you to open an issue instead of contacting the maintainers. We do not add new accounts to the approved contributor list unless there are truly exceptional circumstances, so please do not leave comments or send messages that ask us to add your account. Also, our repository guidelines tell us not to use code from forks or fixes linked in comments, and reviewing such code takes a large amount of maintainer time. Because of this, links to forks or fixes do not help the project, so please do not post them in issues or pull requests. We appreciate your understanding. Please open an issue describing the bug or proposed improvement instead of submitting a pull request. |
Supersedes #627, which edited the generated
README.mdinstead ofREADME.tmpl.md. This PR applies the same docs change to the template.Problem Statement
In a Turborepo / pnpm workspace where the Next.js app lives below the workspace root, the README's Next.js example resolves
artifactDirectoryagainst the workspace root rather than the Next app directory. The build then fails with:and the error message doesn't point to the artifact path as the cause.
Root cause: Turbopack passes its root directory (by default, the directory containing the lockfile) to SWC as the
cwd. The plugin joins relativeartifactDirectoryvalues onto thatcwd, so"./src/gql"lands at<workspace-root>/src/gqlinstead of<workspace-root>/apps/web/src/gql.Reproduced with Next 16.2.6 + Turbopack + Yarn workspaces, plugin 0.24.0.
Solution
Add a callout under the Next.js section of
README.tmpl.mdexplaining the workspace-root anchoring, plus a copy-pasteable monorepo example withartifactDirectory: "apps/web/src/gql". Docs only.Compared to #627, this also addresses the review feedback there:
cwd. Webpack builds, or setups that pinturbopack.rootto the app directory, keep the app-relative path.export default nextConfig;so it works when pasted asnext.config.mjs.Test Plan
Verified the config end-to-end in a Turborepo (Yarn 4 workspaces, Next 16.2.6 + Turbopack, plugin 0.24.0): with the workspace-root-relative
artifactDirectory, the build succeeds and the resulting chunks no longer contain the GraphQL operation strings (tree-shaking works as the plugin advertises).🤖 Generated with Claude Code